Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip error policy reconciliation if no tags are found #300

Merged
merged 1 commit into from
Aug 9, 2022
Merged

Conversation

pjbgf
Copy link
Member

@pjbgf pjbgf commented Aug 8, 2022

At controller restart, it is quite common to experience Cannot determine latest tag for policy: version list argument cannot be empty errors. This happens because the existing repository may be Ready, but all its underlying data has been lost as it resides in the controller.

Instead of erroring, this PR tries to self-heal by postponing the Policy reconciliation based on its repository set interval.

As a result, the controller will log:
{"level":"info","ts":"2022-08-08T17:37:52.544Z","logger":"controller.imagepolicy","msg":"no tags found in 'my-image-policy', retrying in 1m0s","reconciler group":"image.toolkit.fluxcd.io","reconciler kind":"ImagePolicy","name":"source-controller","namespace":"flux-system"}

And generate a Kubernetes Event with similar information.

Fixes: #299

@pjbgf
Copy link
Member Author

pjbgf commented Aug 8, 2022

Test image based on 39cc9bf: ghcr.io/fluxcd/image-reflector-controller:rc-39cc9bf6

@stefanprodan stefanprodan mentioned this pull request Aug 8, 2022
@pjbgf
Copy link
Member Author

pjbgf commented Aug 8, 2022

Test image based on 3826a42: ghcr.io/fluxcd/image-reflector-controller:rc-3826a423

@@ -180,6 +180,14 @@ func (r *ImagePolicyReconciler) Reconcile(ctx context.Context, req ctrl.Request)
var tags []string
tags, err = r.Database.Tags(repo.Status.CanonicalImageName)
if err == nil {
if len(tags) == 0 {
msg := fmt.Sprintf("no tags found in '%s', retrying in %s", repo.Name, repo.Spec.Interval.Duration)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should mention where we didn’t found them?

Suggested change
msg := fmt.Sprintf("no tags found in '%s', retrying in %s", repo.Name, repo.Spec.Interval.Duration)
msg := fmt.Sprintf("no tags found in local storage for '%s', retrying in %s", repo.Name, repo.Spec.Interval.Duration)

@pjbgf pjbgf marked this pull request as ready for review August 9, 2022 09:01
Copy link
Member

@stefanprodan stefanprodan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Signed-off-by: Paulo Gomes <paulo.gomes@weave.works>
Copy link
Contributor

@darkowlzz darkowlzz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Controller errors with version list argument cannot be empty after being restarted
3 participants