From f49203bd06b1ce758002bdc2463db25911ad642f Mon Sep 17 00:00:00 2001 From: Ali Date: Tue, 14 Apr 2026 02:37:15 +0500 Subject: [PATCH] fix: clear Result when Reconcile returns an error Signed-off-by: Ali Assisted-by: claude-sonnet-4-6 --- internal/controller/imagepolicy_controller.go | 6 ++++++ internal/controller/imagerepository_controller.go | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/internal/controller/imagepolicy_controller.go b/internal/controller/imagepolicy_controller.go index 1b052c27..188176e0 100644 --- a/internal/controller/imagepolicy_controller.go +++ b/internal/controller/imagepolicy_controller.go @@ -280,6 +280,12 @@ func (r *ImagePolicyReconciler) reconcile(ctx context.Context, sp *patch.SerialP defer func() { rs := pkgreconcile.NewResultFinalizer(isSuccess, readyMsg) retErr = rs.Finalize(obj, result, retErr) + // controller-runtime logs a warning and ignores Result when Reconcile + // returns both a non-zero Result and a non-nil error. Clear the Result + // whenever there is an error so the log stays clean. + if retErr != nil { + result = ctrl.Result{} + } // Presence of reconciling means that the reconciliation didn't succeed. // Set the Reconciling reason to ProgressingWithRetry to indicate a diff --git a/internal/controller/imagerepository_controller.go b/internal/controller/imagerepository_controller.go index af5dffb4..f1f96f66 100644 --- a/internal/controller/imagerepository_controller.go +++ b/internal/controller/imagerepository_controller.go @@ -219,6 +219,12 @@ func (r *ImageRepositoryReconciler) reconcile(ctx context.Context, sp *patch.Ser readyMsg := fmt.Sprintf("successful scan: found %d tags with checksum %s", numFoundTags, tagsChecksum) rs := reconcile.NewResultFinalizer(isSuccess, readyMsg) retErr = rs.Finalize(obj, result, retErr) + // controller-runtime logs a warning and ignores Result when Reconcile + // returns both a non-zero Result and a non-nil error. Clear the Result + // whenever there is an error so the log stays clean. + if retErr != nil { + result = ctrl.Result{} + } // Presence of reconciling means that the reconciliation didn't succeed. // Set the Reconciling reason to ProgressingWithRetry to indicate a