From d6e19485cf4cb923bdbd8b88b09346e1104aff3b Mon Sep 17 00:00:00 2001 From: Mickael Stanislas Date: Wed, 6 Nov 2024 14:10:52 +0100 Subject: [PATCH] fix: images status --- .changelog/103.txt | 3 +++ cmd/kimup/scheduler.go | 9 +++++---- 2 files changed, 8 insertions(+), 4 deletions(-) create mode 100644 .changelog/103.txt diff --git a/.changelog/103.txt b/.changelog/103.txt new file mode 100644 index 0000000..b80af96 --- /dev/null +++ b/.changelog/103.txt @@ -0,0 +1,3 @@ +```release-note:bug +`image` - Now the status of the image is displayed correctly in the `image` list if the image/repository is not found in the registry. +``` \ No newline at end of file diff --git a/cmd/kimup/scheduler.go b/cmd/kimup/scheduler.go index 4ef1d44..8617008 100644 --- a/cmd/kimup/scheduler.go +++ b/cmd/kimup/scheduler.go @@ -110,9 +110,10 @@ func initScheduler(ctx context.Context, k kubeclient.Interface) { }) timerRegistry.ObserveDuration() if err != nil { - // Prometheus metrics - Increment the counter for the registry with error metrics.Registry().RequestErrorTotal.WithLabelValues(i.GetRegistry()).Inc() image.SetStatusResult(v1alpha1.ImageStatusLastSyncErrorRegistry) + k.Image().Event(&image, corev1.EventTypeWarning, "Fetch image", fmt.Sprintf("Error fetching image: %v", err)) + log.WithError(err).Error("Error fetching image") return err } @@ -123,8 +124,8 @@ func initScheduler(ctx context.Context, k kubeclient.Interface) { tagsAvailable, err := re.Tags() timerTags.ObserveDuration() if err != nil { - // Prometheus metrics - Increment the counter for the tags with error metrics.Tags().RequestErrorTotal.Inc() + image.SetStatusResult(v1alpha1.ImageStatusLastSyncErrorTags) k.Image().Event(&image, corev1.EventTypeWarning, "Fetch image tags", fmt.Sprintf("Error fetching tags: %v", err)) log.WithError(err).Error("Error fetching tags") return err @@ -161,8 +162,8 @@ func initScheduler(ctx context.Context, k kubeclient.Interface) { if err != nil { // Prometheus metrics - Increment the counter for the evaluated rule with error + image.SetStatusResult(v1alpha1.ImageStatusLastSyncError) metrics.Rules().EvaluatedErrorTotal.Inc() - log.Errorf("Error evaluating rule: %v", err) k.Image().Event(&image, corev1.EventTypeWarning, "Evaluate rule", fmt.Sprintf("Error evaluating rule %s: %v", rule.Type, err)) continue @@ -197,7 +198,7 @@ func initScheduler(ctx context.Context, k kubeclient.Interface) { if err != nil { // Prometheus metrics - Increment the counter for the executed action with error metrics.Actions().ExecutedErrorTotal.Inc() - + image.SetStatusResult(v1alpha1.ImageStatusLastSyncError) log.Errorf("Error executing action(%s): %v", action.Type, err) k.Image().Event(&image, corev1.EventTypeWarning, "Execute action", fmt.Sprintf("Error executing action %s: %v", action.Type, err)) continue