Skip to content

fix: clear Result when Reconcile returns an error#880

Open
alliasgher wants to merge 1 commit intofluxcd:mainfrom
alliasgher:fix-reconciler-return-result-and-error
Open

fix: clear Result when Reconcile returns an error#880
alliasgher wants to merge 1 commit intofluxcd:mainfrom
alliasgher:fix-reconciler-return-result-and-error

Conversation

@alliasgher
Copy link
Copy Markdown

Summary

Both ImageRepositoryReconciler.Reconcile and ImagePolicyReconciler.Reconcile wrap the sub-reconciler with a named-return form that always emits both values:

result, retErr = r.reconcile(ctx, ...)
return

controller-runtime emits the warning referenced in #661 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 (ctrl.Result{}, retErr) and the warning no longer fires. Behaviour after the change is what controller-runtime was doing anyway (the Result was being discarded); this just avoids the log noise.

Fixes #661

Signed-off-by: Ali alliasgher123@gmail.com

@stefanprodan
Copy link
Copy Markdown
Member

We should fix this inside the reconcile func, instead of adding a bandaid.

@alliasgher alliasgher force-pushed the fix-reconciler-return-result-and-error branch from ff6331e to a61c052 Compare April 14, 2026 05:42
@stefanprodan
Copy link
Copy Markdown
Member

@alliasgher the commit should be:

fix: clear Result when Reconcile returns an error

Signed-off-by: Ali <alliasgher123@gmail.com>
Assisted-by: claude-sonnet-4-6

The fix should happen inside the r.reconcile functions, where in all places we return an error, we should do:

return nil, err

Signed-off-by: Ali <alliasgher123@gmail.com>
Assisted-by: claude-sonnet-4-6
@alliasgher alliasgher force-pushed the fix-reconciler-return-result-and-error branch from a61c052 to f49203b Compare April 14, 2026 09:00
@alliasgher
Copy link
Copy Markdown
Author

@alliasgher the commit should be:

fix: clear Result when Reconcile returns an error

Signed-off-by: Ali <alliasgher123@gmail.com>
Assisted-by: claude-sonnet-4-6

The fix should happen inside the r.reconcile functions, where in all places we return an error, we should do:

return nil, err

@stefanprodan done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

small reconciler bug (result + error returned) when error occurred

2 participants