Repository navigation
fix: replace deprecated reconcile.Result.Requeue with RequeueAfter - #4823
ogulcanaydogan wants to merge 1 commit into
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #4823 +/- ##
==========================================
- Coverage 54.49% 54.47% -0.03%
==========================================
Files 134 311 +177
Lines 12329 26157 +13828
==========================================
+ Hits 6719 14248 +7529
- Misses 5116 10675 +5559
- Partials 494 1234 +740
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🟡 Changes recommended
Fixed one-second retries bypass existing rate-limited backoff in multiple controllers, and one deprecated test access remains.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Replaces deprecated reconcile.Result.Requeue usage with explicit retry delays across controller reconcilers.
Changes:
- Uses
RequeueAfterfor transient retry paths. - Removes ineffective requeue metadata from the SyncSet error path.
- Updates related tests.
File summaries
| File | Summary |
|---|---|
pkg/controller/syncset/syncset_controller.go |
Removes redundant requeue metadata when returning an error. |
pkg/controller/mutatorstatus/mutatorstatus_controller.go |
Adds delayed status retry. |
pkg/controller/externaldatastatus/externaldatastatus_controller.go |
Adds delayed status retry. |
pkg/controller/export/export_connection_controller.go |
Adds delayed export retries. |
pkg/controller/export/export_connection_controller_test.go |
Updates retry assertions; one deprecated access remains. |
pkg/controller/expansionstatus/expansionstatus_controller.go |
Adds delayed status retry. |
pkg/controller/constrainttemplatestatus/constrainttemplatestatus_controller.go |
Adds delayed status retry. |
pkg/controller/constrainttemplate/constrainttemplate_controller.go |
Adds delayed persistence retry. |
pkg/controller/constrainttemplate/constrainttemplate_controller_test.go |
Updates retry expectations. |
pkg/controller/constraintstatus/constraintstatus_controller.go |
Adds delayed status retry. |
pkg/controller/constraint/constraint_controller.go |
Adds delayed persistence retry. |
pkg/controller/constraint/constraint_controller_test.go |
Updates retry expectations. |
pkg/controller/configstatus/configstatus_controller.go |
Adds delayed status retry. |
pkg/controller/config/config_controller.go |
Adds delayed cache-sync retry. |
Review details
Suppressed comments (11)
pkg/controller/config/config_controller.go:339
- This changes the retry policy, not just the deprecated field: when
updateOrCreatePodStatussucceeds, this path returns a nil error, so the workqueue's rate-limited retry/backoff is no longer used and a persistentUpsertSourcefailure will be retried every second indefinitely. During an API or cache outage, that creates sustained cache/status traffic, contrary to the claimed avoidance of hammering and the previous behavior. Please preserve an explicit backoff rather than a fixed one-second loop.
return reconcile.Result{RequeueAfter: requeueDelayOnTransientError}, r.updateOrCreatePodStatus(ctx, instance, err)
pkg/controller/configstatus/configstatus_controller.go:204
- This changes the retry policy, not just the deprecated field: because this path returns a nil error, the workqueue's rate-limited retry/backoff is no longer used and a persistent
Status().Updatefailure will be retried every second for this object indefinitely. During an API outage or permanent conflict, that creates sustained write load, contrary to the claimed avoidance of hammering and the previous behavior. Please preserve an explicit backoff (for example by propagating the update error so the controller's error rate limiter handles it, or by implementing backoff here) instead of a fixed one-second loop.
return reconcile.Result{RequeueAfter: requeueDelayOnTransientError}, nil
pkg/controller/constraint/constraint_controller.go:383
- This changes the retry policy, not just the deprecated field: when the deferred status-persistence path clears
reconcileErr, the workqueue's rate-limited retry/backoff is no longer used and this object is retried every second indefinitely. During an API outage or permanent conflict, that creates sustained status write load, contrary to the claimed avoidance of hammering and the previous behavior. Please preserve an explicit backoff rather than replacing it with a fixed one-second loop.
result = reconcile.Result{RequeueAfter: requeueDelayOnTransientError}
pkg/controller/constraintstatus/constraintstatus_controller.go:255
- This changes the retry policy, not just the deprecated field: because this path returns a nil error, the workqueue's rate-limited retry/backoff is no longer used and a persistent
Status().Updatefailure will be retried every second for this object indefinitely. During an API outage or permanent conflict, that creates sustained write load, contrary to the claimed avoidance of hammering and the previous behavior. Please preserve an explicit backoff (for example by propagating the update error so the controller's error rate limiter handles it, or by implementing backoff here) instead of a fixed one-second loop.
return reconcile.Result{RequeueAfter: requeueDelayOnTransientError}, nil
pkg/controller/constrainttemplate/constrainttemplate_controller.go:423
- This changes the retry policy, not just the deprecated field: when status persistence fails but the deferred path clears
reconcileErr, the workqueue's rate-limited retry/backoff is no longer used and this object is retried every second indefinitely. During an API outage or permanent conflict, that creates sustained status write load, contrary to the claimed avoidance of hammering and the previous behavior. Please preserve an explicit backoff rather than replacing it with a fixed one-second loop.
result = reconcile.Result{RequeueAfter: requeueDelayOnTransientError}
pkg/controller/constrainttemplatestatus/constrainttemplatestatus_controller.go:241
- This changes the retry policy, not just the deprecated field: because this path returns a nil error, the workqueue's rate-limited retry/backoff is no longer used and a persistent
Status().Updatefailure will be retried every second for this object indefinitely. During an API outage or permanent conflict, that creates sustained write load, contrary to the claimed avoidance of hammering and the previous behavior. Please preserve an explicit backoff (for example by propagating the update error so the controller's error rate limiter handles it, or by implementing backoff here) instead of a fixed one-second loop.
return reconcile.Result{RequeueAfter: requeueDelayOnTransientError}, nil
pkg/controller/expansionstatus/expansionstatus_controller.go:210
- This changes the retry policy, not just the deprecated field: because this path returns a nil error, the workqueue's rate-limited retry/backoff is no longer used and a persistent
Status().Updatefailure will be retried every second for this object indefinitely. During an API outage or permanent conflict, that creates sustained write load, contrary to the claimed avoidance of hammering and the previous behavior. Please preserve an explicit backoff (for example by propagating the update error so the controller's error rate limiter handles it, or by implementing backoff here) instead of a fixed one-second loop.
return reconcile.Result{RequeueAfter: requeueDelayOnTransientError}, nil
pkg/controller/export/export_connection_controller.go:186
- This changes the retry policy, not just the deprecated field: when
deleteStatussucceeds, this path returns a nil error, so the workqueue's rate-limited retry/backoff is no longer used and a persistentCloseConnectionfailure will be retried every second indefinitely. During an unavailable export backend, that creates sustained close/status traffic, contrary to the claimed avoidance of hammering and the previous behavior. Please preserve an explicit backoff rather than a fixed one-second loop.
return reconcile.Result{RequeueAfter: requeueDelayOnTransientError}, deleteStatus(ctx, r.writer, request.Namespace, request.Name, r.getPod)
pkg/controller/export/export_connection_controller.go:200
- This changes the retry policy, not just the deprecated field: when
updateOrCreateConnectionPodStatussucceeds, this path returns a nil error, so the workqueue's rate-limited retry/backoff is no longer used and a persistentUpsertConnectionfailure will be retried every second indefinitely. During an unavailable export backend, that creates sustained backend/status traffic, contrary to the claimed avoidance of hammering and the previous behavior. Please preserve an explicit backoff rather than a fixed one-second loop.
return reconcile.Result{RequeueAfter: requeueDelayOnTransientError}, updateOrCreateConnectionPodStatus(ctx, r.reader, r.writer, r.scheme, connObj, []*statusv1alpha1.ConnectionError{{Type: statusv1alpha1.UpsertConnectionError, Message: err.Error()}}, nil, r.getPod)
pkg/controller/externaldatastatus/externaldatastatus_controller.go:208
- This changes the retry policy, not just the deprecated field: because this path returns a nil error, the workqueue's rate-limited retry/backoff is no longer used and a persistent
Status().Updatefailure will be retried every second for this object indefinitely. During an API outage or permanent conflict, that creates sustained write load, contrary to the claimed avoidance of hammering and the previous behavior. Please preserve an explicit backoff (for example by propagating the update error so the controller's error rate limiter handles it, or by implementing backoff here) instead of a fixed one-second loop.
return reconcile.Result{RequeueAfter: requeueDelayOnTransientError}, nil
pkg/controller/mutatorstatus/mutatorstatus_controller.go:313
- This changes the retry policy, not just the deprecated field: because this path returns a nil error, the workqueue's rate-limited retry/backoff is no longer used and a persistent
Status().Updatefailure will be retried every second for this object indefinitely. During an API outage or permanent conflict, that creates sustained write load, contrary to the claimed avoidance of hammering and the previous behavior. Please preserve an explicit backoff (for example by propagating the update error so the controller's error rate limiter handles it, or by implementing backoff here) instead of a fixed one-second loop.
return reconcile.Result{RequeueAfter: requeueDelayOnTransientError}, nil
- Files reviewed: 14/14 changed files
- Comments generated: 1
- Review effort level: Lite (auto)
Note
Copilot is running an experiment and ran this review at Lite.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
fad2203 to
ab1be55
Compare
There was a problem hiding this comment.
🔵 Needs a closer look
Unresolved findings concern lost retry backoff, error paths returning RequeueAfter with errors, and a remaining deprecated test access.
Review details
Suppressed comments (15)
pkg/controller/config/config_controller.go:339
updateOrCreatePodStatuscan return errors from pod lookup or status create/update. When that happens this returns both a non-zero result and a non-nil error; controller-runtime ignoresRequeueAfterand logs a warning, so the explicit delay is not used. Handle the status error separately and returnreconcile.Result{}with it, usingRequeueAfteronly when status persistence succeeds.
return reconcile.Result{RequeueAfter: requeueDelayOnTransientError}, r.updateOrCreatePodStatus(ctx, instance, err)
pkg/controller/config/config_controller.go:339
- This fixed one-second retry resets the workqueue's rate-limit state, so a persistent cache-sync failure retries once per second for every affected Config indefinitely. The previous
Requeue: trueused controller-runtime's exponential rate limiter; please preserve backoff by returning the error or implementing an explicit exponential/jittered delay.
return reconcile.Result{RequeueAfter: requeueDelayOnTransientError}, r.updateOrCreatePodStatus(ctx, instance, err)
pkg/controller/configstatus/configstatus_controller.go:204
- This fixed one-second retry resets the workqueue's rate-limit state, so a persistent status-update failure retries once per second for every affected Config indefinitely. The previous
Requeue: trueused controller-runtime's exponential rate limiter; please preserve backoff by returning the error or implementing an explicit exponential/jittered delay.
return reconcile.Result{RequeueAfter: requeueDelayOnTransientError}, nil
pkg/controller/constraint/constraint_controller.go:383
- This fixed one-second retry resets the workqueue's rate-limit state, so a persistent status-persist failure retries once per second for every affected constraint indefinitely. The previous
Requeue: trueused controller-runtime's exponential rate limiter; please preserve backoff by returning the error or implementing an explicit exponential/jittered delay.
result = reconcile.Result{RequeueAfter: requeueDelayOnTransientError}
pkg/controller/constraintstatus/constraintstatus_controller.go:255
- This fixed one-second retry resets the workqueue's rate-limit state, so a persistent status-update failure retries once per second for every affected constraint indefinitely. The previous
Requeue: trueused controller-runtime's exponential rate limiter; please preserve backoff by returning the error or implementing an explicit exponential/jittered delay.
return reconcile.Result{RequeueAfter: requeueDelayOnTransientError}, nil
pkg/controller/constrainttemplate/constrainttemplate_controller.go:423
- This fixed one-second retry resets the workqueue's rate-limit state, so a persistent status-persist failure retries once per second for every affected template indefinitely. The previous
Requeue: trueused controller-runtime's exponential rate limiter; please preserve backoff by returning the error or implementing an explicit exponential/jittered delay.
result = reconcile.Result{RequeueAfter: requeueDelayOnTransientError}
pkg/controller/constrainttemplatestatus/constrainttemplatestatus_controller.go:241
- This fixed one-second retry resets the workqueue's rate-limit state, so a persistent status-update failure retries once per second for every affected template indefinitely. The previous
Requeue: trueused controller-runtime's exponential rate limiter; please preserve backoff by returning the error or implementing an explicit exponential/jittered delay.
return reconcile.Result{RequeueAfter: requeueDelayOnTransientError}, nil
pkg/controller/expansionstatus/expansionstatus_controller.go:210
- This fixed one-second retry resets the workqueue's rate-limit state, so a persistent status-update failure retries once per second for every affected expansion indefinitely. The previous
Requeue: trueused controller-runtime's exponential rate limiter; please preserve backoff by returning the error or implementing an explicit exponential/jittered delay.
return reconcile.Result{RequeueAfter: requeueDelayOnTransientError}, nil
pkg/controller/export/export_connection_controller.go:206
deleteStatuscan return a non-nil error. In that case this returns bothRequeueAfterand an error; controller-runtime ignores the delay and emits its warning, falling back to the error rate limiter. Split the call so the result is empty when status deletion fails, and use the explicit delay only when it succeeds.
return reconcile.Result{RequeueAfter: requeueDelayOnTransientError}, deleteStatus(ctx, r.writer, request.Namespace, request.Name, r.getPod)
pkg/controller/export/export_connection_controller.go:220
updateOrCreateConnectionPodStatusreturns errors from pod/status reads and writes. If it fails, this returns bothRequeueAfterand a non-nil error; the controller-runtime loop ignores the delay and logs a warning. Return an empty result with that status error, reserving the one-second requeue for the successful status-recording path.
return reconcile.Result{RequeueAfter: requeueDelayOnTransientError}, updateOrCreateConnectionPodStatus(ctx, r.reader, r.writer, r.scheme, connObj, []*statusv1alpha1.ConnectionError{{Type: statusv1alpha1.UpsertConnectionError, Message: err.Error()}}, nil, r.getPod)
pkg/controller/export/export_connection_controller.go:206
- This fixed one-second retry resets the workqueue's rate-limit state, so a persistent close failure retries once per second indefinitely for each deleted connection. The previous
Requeue: trueused controller-runtime's exponential rate limiter; please preserve backoff by returning the error or implementing an explicit exponential/jittered delay.
return reconcile.Result{RequeueAfter: requeueDelayOnTransientError}, deleteStatus(ctx, r.writer, request.Namespace, request.Name, r.getPod)
pkg/controller/export/export_connection_controller.go:220
- This fixed one-second retry resets the workqueue's rate-limit state, so a persistent export upsert failure retries once per second indefinitely for each connection. The previous
Requeue: trueused controller-runtime's exponential rate limiter; please preserve backoff by returning the error or implementing an explicit exponential/jittered delay.
return reconcile.Result{RequeueAfter: requeueDelayOnTransientError}, updateOrCreateConnectionPodStatus(ctx, r.reader, r.writer, r.scheme, connObj, []*statusv1alpha1.ConnectionError{{Type: statusv1alpha1.UpsertConnectionError, Message: err.Error()}}, nil, r.getPod)
pkg/controller/export/export_connection_controller_test.go:587
- The deprecated field is still read later in this same test file at line 714 (
result.Requeue, with anolint:staticcheck), so this migration still leaves an SA1019 suppression and does not fully removeResult.Requeueusage. Update that GET-error assertion to check the empty result (orRequeueAfter == 0) and remove the suppression as part of this cleanup.
g.Expect(result.RequeueAfter).Should(gomega.Equal(requeueDelayOnTransientError), "Reconcile should requeue after an error")
pkg/controller/externaldatastatus/externaldatastatus_controller.go:208
- This fixed one-second retry resets the workqueue's rate-limit state, so a persistent status-update failure retries once per second for every affected object indefinitely. The previous
Requeue: trueused controller-runtime's exponential rate limiter; please preserve backoff by returning the error or implementing an explicit exponential/jittered delay.
return reconcile.Result{RequeueAfter: requeueDelayOnTransientError}, nil
pkg/controller/mutatorstatus/mutatorstatus_controller.go:313
- A fixed one-second
RequeueAfterresets the workqueue's rate-limit state on every attempt, so a persistent status-update failure retries once per second for every affected object indefinitely. The oldRequeue: trueused controller-runtime's exponential rate limiter and backed off under sustained failures; please preserve backoff (for example by returning the error, or by implementing an explicit exponential/jittered delay) rather than claiming this fixed interval cannot hammer the API server.
return reconcile.Result{RequeueAfter: requeueDelayOnTransientError}, nil
- Files reviewed: 14/14 changed files
- Comments generated: 0 new
- Review effort level: Lite (auto)
Note
Copilot is running an experiment and ran this review at Lite.
6e93e0c to
bcc145c
Compare
JaydipGabani
left a comment
There was a problem hiding this comment.
Blocking on the retry semantics in the nil-error paths. Requeue: true used controller-runtime’s rate-limited queue; RequeueAfter: time.Second forgets failure history and creates a fixed one-second retry per object. Under persistent API, cache, or export failures this can sustain load across all affected reconcilers. Please preserve exponential backoff or use explicit bounded, jittered backoff.
The syncset cleanup is correct because its non-nil error already triggers rate-limited retry. Please also resolve the existing thread for the remaining deprecated result.Requeue test access.
|
You're right, thanks for the catch and for the concrete repro path. Confirmed in controller-runtime's reconcileHandler: the RequeueAfter case calls Queue.Forget before requeueing at a fixed delay, while the Requeue case (and the error case) uses RateLimited, so my mechanical replacement did lose exponential backoff. Fixed in the latest commit:
All existing tests updated and passing, golangci-lint clean on the changed files (remaining lint findings in these packages are pre-existing, unrelated to this PR). |
64a7dc3 to
b00b021
Compare
There was a problem hiding this comment.
The original fixed-delay retry blocker is addressed: the ordinary failure paths now return their errors, and the two intentionally nil-error paths use bounded exponential backoff. One lifecycle blocker remains in the new custom limiter state: deletion bypasses Forget, so failed-and-deleted object keys are retained and same-name recreations inherit stale delay. Please clean up both the ConstraintTemplate and Constraint limiter entries on terminal deletion and cover failure -> deletion (or recreation) in tests.
The prior export-test thread is outdated but still applies: export_connection_controller_test.go:714 remains the sole executable result.Requeue access under // nolint:staticcheck; please replace it with an empty-result assertion as part of this deprecation cleanup.
Validation: all 11 touched package tests pass on b00b021 (envtest packages serialized), go vet ./pkg/controller/... is clean, and all 24 CI checks pass. The branch is also one non-overlapping dependency commit behind master.
b00b021 to
67167ba
Compare
|
Good catch on the deletion gap. Both controllers now call Forget on the delete path (right when entering the deleted branch, before any of the cleanup steps that could early-return), so a recreated object under the same name starts fresh instead of inheriting a stale delay. Added a regression test for each controller that fails twice to build up backoff past the base delay, deletes the object, recreates it under the same name, and asserts the next failure is back at the 1s base delay rather than continuing the streak. Also swapped the last result.Requeue read in export_connection_controller_test.go for an empty-result assertion and dropped the nolint. b00b021 -> 67167ba, rebased on current master, full package tests pass locally with KUBEBUILDER_ASSETS set. |
|
@ogulcanaydogan can you fix DCO? last commit is not signed off |
JaydipGabani
left a comment
There was a problem hiding this comment.
The prior correctness findings are resolved. I re-reviewed the full diff: ordinary failure paths now return errors for controller-runtime rate limiting; the two intentionally nil-error paths use bounded per-request backoff and forget state after success and deletion; the new tests cover growth plus deletion/recreation reset; and the last deprecated Result.Requeue read is gone. I found no additional behavioral blocker.
This is still not merge-ready for two deterministic gates:
make lintfails withgoconstbecause"unknown.target"now occurs three times inconstrainttemplate_controller_test.go; define a test constant and use it at all three sites.- DCO reports commit
67167bahas noSigned-off-by. This repository disallows remediation commits, so amend that commit withgit commit --amend --signoffand force-push with lease.
The custom-namespace Helm failure was an unrelated VAPBinding readiness race at test/bats/test.bats:233, reproduced on an unrelated Dependabot branch. Its targeted rerun passed. Local validation on this head: all 11 touched controller packages pass serially, go vet ./pkg/controller/... passes, diff check is clean, and isolated P1 review found no code defect. The branch is two non-overlapping Dockerfile-only commits behind master.
| // statusPersistBackoff limiter is keyed only by request (name). | ||
| func TestReconcileDeleteResetsStatusPersistBackoff(t *testing.T) { | ||
| ct := makeReconcileConstraintTemplate("DeleteBackoffReset") | ||
| ct.Spec.Targets[0].Target = "unknown.target" |
There was a problem hiding this comment.
make lint fails with goconst: this added occurrence raises "unknown.target" to three uses in the file (lines 2380, 2402, and 2431). Please define a test constant and use it at all three sites so the required lint check passes.
67167ba to
ac4e3e6
Compare
|
Both gates fixed:
Full controller/constraint, controller/constrainttemplate and controller/export suites pass locally, gofmt clean. |
ac4e3e6 to
bc50b22
Compare
|
Rebased onto current master (it had a conflict in the constrainttemplate controller after the recent merges) and squashed into one commit. The earlier feedback is unchanged: the persist backoff is kept via the explicit rate limiter and forgotten on delete, and the test constant for unknown.target is in place. constrainttemplate, constraint and export controller tests pass locally with envtest |
|
Rebased on current master (it was behind). The earlier review points are all in: the persist backoff is kept with an explicit rate limiter and forgotten on delete, and the unknown.target test constant is defined. The constrainttemplate, constraint and export controller tests pass locally with envtest. @JaydipGabani could you take another look when you have time |
98453d7 to
280b5bb
Compare
|
@JaydipGabani when you have a moment, could you take another look? Both gates from your 28 Sep review are addressed (the unknownTarget constant for goconst, and the DCO sign-off amended without a remediation commit). The branch conflicts with master again. I'd rather not keep rebasing under you, so I'll rebase as soon as you've had a look, or right now if you prefer |
280b5bb to
471cd3e
Compare
|
@JaydipGabani rebased on current master (it had 24 commits to catch up, with conflicts in config and export). One change you should know about: master's new TestReconcileConnectionState (#4913) asserts |
There was a problem hiding this comment.
Orka review
Verdict: passed
Confidence: high
Head: 471cd3ef
Orka set the verdict to passed: no finding at P1 or above is open. The status controllers that return write errors retain queue-managed retries. The Constraint and ConstraintTemplate controllers instead introduce a second retry counter, which changes backoff across consecutive failures and can carry a stale delay into a replacement object.
Findings
- P2: Keep one retry history across read and status-write failures (
pkg/controller/constraint/constraint_controller.go:409) — The same request now has two retry counters. For example, if a status update conflicts, the next status read fails, and the following update conflicts again, eachRequeueAfterclears the workqueue’s failure count. The read errors therefore keep retrying at the queue’s initial delay even though no reconcile succeeded. Previously both failure paths advanced the same counter. The same pattern occurs inpkg/controller/constrainttemplate/constrainttemplate_controller.go:454. The new tests exercise consecutive write failures only. — Recommendation: Return the status persistence error with an empty result in both controllers and let the workqueue own the backoff, as the other status controllers do. Preserve any independent reconcile error when both operations fail. - P2: A replacement object can inherit backoff without a delete reconcile (
pkg/controller/constraint/constraint_controller.go:469) — Both controllers clear their name-keyed retry state on an observed deletion. If an object is deleted and recreated before the worker processes that key, the worker reads the replacement directly. Neither thisForgetnor the one inpkg/controller/constrainttemplate/constrainttemplate_controller.go:378runs. If the replacement’s first status write fails, its retry inherits the old delay, potentially a minute. Both new deletion tests force a reconcile while the object is absent, so they miss this case. — Recommendation: If the explicit limiters are retained, reset the entry when the observed UID changes. Test both controllers by replacing a failing object with a different UID under the same name, without reconciling an intermediate deletion, and assert that the next write failure gets the initial delay.
Tests
Status: not_run
No validation image was configured for this review.
| switch { | ||
| case baseStatusChanged: | ||
| result = reconcile.Result{Requeue: true} | ||
| result = reconcile.Result{RequeueAfter: r.baseStatusPersistBackoff.When(request)} |
There was a problem hiding this comment.
P2: Keep one retry history across read and status-write failures
The same request now has two retry counters. For example, if a status update conflicts, the next status read fails, and the following update conflicts again, each RequeueAfter clears the workqueue’s failure count. The read errors therefore keep retrying at the queue’s initial delay even though no reconcile succeeded. Previously both failure paths advanced the same counter. The same pattern occurs in pkg/controller/constrainttemplate/constrainttemplate_controller.go:454. The new tests exercise consecutive write failures only.
Recommendation: Return the status persistence error with an empty result in both controllers and let the workqueue own the backoff, as the other status controllers do. Preserve any independent reconcile error when both operations fail.
| // The persist-backoff limiter is keyed by request (kind/namespace/name), so a | ||
| // deleted object's accumulated backoff must be cleared here. Otherwise a new | ||
| // object recreated under the same name would inherit the stale delay. | ||
| r.baseStatusPersistBackoff.Forget(request) |
There was a problem hiding this comment.
P2: A replacement object can inherit backoff without a delete reconcile
Both controllers clear their name-keyed retry state on an observed deletion. If an object is deleted and recreated before the worker processes that key, the worker reads the replacement directly. Neither this Forget nor the one in pkg/controller/constrainttemplate/constrainttemplate_controller.go:378 runs. If the replacement’s first status write fails, its retry inherits the old delay, potentially a minute. Both new deletion tests force a reconcile while the object is absent, so they miss this case.
Recommendation: If the explicit limiters are retained, reset the entry when the observed UID changes. Test both controllers by replacing a failing object with a different UID under the same name, without reconciling an intermediate deletion, and assert that the next write failure gets the initial delay.
Replace the deprecated Result.Requeue with explicit rate-limited requeues that keep the previous backoff behavior, and forget the persist backoff when an object is deleted so the limiter does not leak entries. Signed-off-by: Ogulcan Aydogan <ogulcanaydogan@gmail.com>
471cd3e to
07d1298
Compare
There was a problem hiding this comment.
Orka review
Verdict: passed
Confidence: high
Head: 07d12980
Orka set the verdict to passed: no finding at P1 or above is open. The status-controller conversions still retry failed writes. The constraint and template controllers, however, split one retry history into two, and their deletion tests miss same-name replacements that the controller never observes as deleted. The export controller also retains two uses of the deprecated field.
Findings
- P2: Keep status-write failures on the controller's retry history (
pkg/controller/constraint/constraint_controller.go:409) — Previously, bothRequeue: trueand a returned error advanced the workqueue's backoff for the same request. ReturningRequeueAfterfor a failed status write clears that history. For example, after several failed reads, one failed status update makes the next failed read retry at the initial delay even though no reconciliation succeeded. The same split occurs inpkg/controller/constrainttemplate/constrainttemplate_controller.go:454. The new tests exercise consecutive write failures, not a transition between failure types. — Recommendation: Return the persistence error with an empty result in both controllers and let the workqueue own backoff, as the other changed controllers do. Preserve any simultaneous reconciliation error in the error chain and update the tests to cover a read failure followed by a write failure. - P2: A same-name replacement can bypass the backoff reset (
pkg/controller/constraint/constraint_controller.go:469) — Clearing the private limiter in the delete branch only works if a worker reconciles while the old object is absent or terminating. If deletion and recreation both happen before the worker reads the key, it sees the replacement directly. A failed first status write then inherits the old object's delay, potentially a minute. The same pattern occurs inpkg/controller/constrainttemplate/constrainttemplate_controller.go:378. Both new tests explicitly reconcile between deletion and creation, so neither exercises this sequence. — Recommendation: If retaining the private limiters and their per-object reset guarantee, track the last UID for each request and discard the prior history when the UID changes. Test both controllers by replacing the object with a different UID between reconciles, without an intervening not-found read. - P3: Finish the deprecated-field migration in the export controller (
pkg/controller/export/export_connection_controller.go:234) — Both the close failure at line 234 and the upsert failure at line 256 still rely onRequeue: truewhen the accompanying status operation succeeds. The export controller tests also readresult.Requeueat lines 812, 848, 922, 939, 1004, and 1440 ofpkg/controller/export/export_connection_controller_test.go. The checkout therefore still depends on the field this migration is intended to replace. — Recommendation: Migrate both export error paths together, preserving the retry even when the status operation returns nil, and update the six test assertions to check the replacement contract.
Tests
Status: not_run
No validation image was configured for this review.
| switch { | ||
| case baseStatusChanged: | ||
| result = reconcile.Result{Requeue: true} | ||
| result = reconcile.Result{RequeueAfter: r.baseStatusPersistBackoff.When(request)} |
There was a problem hiding this comment.
P2: Keep status-write failures on the controller's retry history
Previously, both Requeue: true and a returned error advanced the workqueue's backoff for the same request. Returning RequeueAfter for a failed status write clears that history. For example, after several failed reads, one failed status update makes the next failed read retry at the initial delay even though no reconciliation succeeded. The same split occurs in pkg/controller/constrainttemplate/constrainttemplate_controller.go:454. The new tests exercise consecutive write failures, not a transition between failure types.
Recommendation: Return the persistence error with an empty result in both controllers and let the workqueue own backoff, as the other changed controllers do. Preserve any simultaneous reconciliation error in the error chain and update the tests to cover a read failure followed by a write failure.
| // The persist-backoff limiter is keyed by request (kind/namespace/name), so a | ||
| // deleted object's accumulated backoff must be cleared here. Otherwise a new | ||
| // object recreated under the same name would inherit the stale delay. | ||
| r.baseStatusPersistBackoff.Forget(request) |
There was a problem hiding this comment.
P2: A same-name replacement can bypass the backoff reset
Clearing the private limiter in the delete branch only works if a worker reconciles while the old object is absent or terminating. If deletion and recreation both happen before the worker reads the key, it sees the replacement directly. A failed first status write then inherits the old object's delay, potentially a minute. The same pattern occurs in pkg/controller/constrainttemplate/constrainttemplate_controller.go:378. Both new tests explicitly reconcile between deletion and creation, so neither exercises this sequence.
Recommendation: If retaining the private limiters and their per-object reset guarantee, track the last UID for each request and discard the prior history when the UID changes. Test both controllers by replacing the object with a different UID between reconciles, without an intervening not-found read.
Why
`reconcile.Result.Requeue` is deprecated in `controller-runtime` in favor of `RequeueAfter`:
This surfaced while evaluating a golangci-lint version bump past the currently pinned v2.9.0 (staticcheck's SA1019 flags every usage).
Change
Nine call sites across the status/config/constraint reconcilers used `Requeue: true` to retry a transient failure (a status update or cache-sync error) whose own error was deliberately not propagated up the call stack. Replaced each with an explicit `RequeueAfter: requeueDelayOnTransientError` (a local 1-second constant per package) so the retry behavior is preserved without the deprecated field.
The `syncset-controller` call site is different: it already returns the triggering error alongside `Requeue: true`. `controller-runtime`'s own reconcile loop ignores `Requeue`/`RequeueAfter` whenever a reconcile returns a non-nil error (and logs a warning when both are set), so that `Requeue: true` was already a no-op there. Dropped it instead of replacing it, matching the sibling error-return path a few lines above in the same function.
Testing