From ecf8ee6e5bbb16d9108c34eba0819eba44c51a32 Mon Sep 17 00:00:00 2001 From: Paul Laffitte Date: Thu, 11 Jul 2024 18:38:46 +0200 Subject: [PATCH] fix: handle errors in podsWithDeletingCachedImages --- internal/controller/core/pod_controller.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/internal/controller/core/pod_controller.go b/internal/controller/core/pod_controller.go index 2ed8fa5f..44de8fdf 100644 --- a/internal/controller/core/pod_controller.go +++ b/internal/controller/core/pod_controller.go @@ -161,7 +161,13 @@ func (r *PodReconciler) podsWithDeletingCachedImages(ctx context.Context, obj cl } var podList corev1.PodList - podRequirements, _ := labels.NewRequirement(LabelManagedName, selection.Equals, []string{"true"}) + podRequirements, err := labels.NewRequirement(LabelManagedName, selection.Equals, []string{"true"}) + if err != nil { + // errors cannot be handled in a better way for now (see https://github.com/kubernetes-sigs/controller-runtime/issues/1996) + // maybe we don't need to enqueue all Pods related to this CachedImage but only those in the status UsedBy + log.Error(err, "could not list pods") + return nil + } selector := labels.NewSelector() selector = selector.Add(*podRequirements) if err := r.List(ctx, &podList, &client.ListOptions{