Skip to content

Commit ff6331e

Browse files
committed
fix: clear Result when Reconcile returns an error
Both ImageRepositoryReconciler.Reconcile and ImagePolicyReconciler.Reconcile wrap the subreconciler with a named return form that always emits both values: result, retErr = r.reconcile(ctx, ...) return controller-runtime emits a warning when a Reconcile call returns both a non-zero Result and a non-nil error — the Result is ignored in that case and the object is re-queued with the error's exponential backoff. Populating a RequeueAfter and then returning an error gives the misleading impression that the caller's requested interval applies. Drop the Result when there is an error so controller-runtime sees ("", retErr) and the warning no longer fires. Fixes #661 Signed-off-by: Ali <alliasgher123@gmail.com>
1 parent 4b7a59b commit ff6331e

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

internal/controller/imagepolicy_controller.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,12 @@ func (r *ImagePolicyReconciler) Reconcile(ctx context.Context, req ctrl.Request)
241241

242242
// Call subreconciler.
243243
result, retErr = r.reconcile(ctx, serialPatcher, obj)
244+
// controller-runtime logs a warning when a Reconcile call returns both
245+
// a non-zero Result and a non-nil error; the Result is ignored in that
246+
// case. Drop the Result when we have an error to keep the log clean.
247+
if retErr != nil {
248+
result = ctrl.Result{}
249+
}
244250
return
245251
}
246252

internal/controller/imagerepository_controller.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,12 @@ func (r *ImageRepositoryReconciler) Reconcile(ctx context.Context, req ctrl.Requ
193193

194194
// Call subreconciler.
195195
result, retErr = r.reconcile(ctx, serialPatcher, obj, start)
196+
// controller-runtime logs a warning when a Reconcile call returns both
197+
// a non-zero Result and a non-nil error; the Result is ignored in that
198+
// case. Drop the Result when we have an error to keep the log clean.
199+
if retErr != nil {
200+
result = ctrl.Result{}
201+
}
196202
return
197203
}
198204

0 commit comments

Comments
 (0)