-
Notifications
You must be signed in to change notification settings - Fork 69
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
Conversation
Test image based on 39cc9bf: |
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) |
There was a problem hiding this comment.
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?
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) |
There was a problem hiding this 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>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks.
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