Skip to content

Commit

Permalink
fix: images status
Browse files Browse the repository at this point in the history
  • Loading branch information
azrod committed Nov 6, 2024
1 parent a300d04 commit d6e1948
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .changelog/103.txt
Original file line number Diff line number Diff line change
@@ -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.
```
9 changes: 5 additions & 4 deletions cmd/kimup/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d6e1948

Please sign in to comment.