Skip to content

fix: replace deprecated reconcile.Result.Requeue with RequeueAfter - #4823

Open
ogulcanaydogan wants to merge 1 commit into
open-policy-agent:masterfrom
ogulcanaydogan:fix/deprecated-reconcile-requeue
Open

ogulcanaydogan wants to merge 1 commit into
open-policy-agent:masterfrom
ogulcanaydogan:fix/deprecated-reconcile-requeue

Conversation

@ogulcanaydogan

Copy link
Copy Markdown
Contributor

Why

`reconcile.Result.Requeue` is deprecated in `controller-runtime` in favor of `RequeueAfter`:

This setting is deprecated as it causes confusion and there is no good reason to use it. When waiting for an external event to happen, either the duration until it is supposed to happen or an appropriate poll interval should be used, rather than an interval emitted by a ratelimiter whose purpose it is to control retry on error.

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

  • Updated the two existing tests (`pkg/controller/constraint`, `pkg/controller/constrainttemplate`) that asserted `result == reconcile.Result{Requeue: true}` directly, and the two assertions in `pkg/controller/export` that read `result.Requeue` (both previously carried a `// nolint:staticcheck` for the same deprecation).
  • `go build ./...`, `go vet ./pkg/controller/...` clean.
  • `go test` for all 11 touched packages (using `setup-envtest` for the ones requiring a real control plane), all green.
  • `gofmt`, `gci diff`, `gofumpt -l` all clean on the changed files.

@ogulcanaydogan
ogulcanaydogan requested a review from a team as a code owner September 9, 2026 09:58
@codecov-commenter

codecov-commenter commented Sep 9, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 54.47%. Comparing base (3350319) to head (07d1298).
⚠️ Report is 962 commits behind head on master.

Files with missing lines Patch % Lines
pkg/controller/config/config_controller.go 0.00% 3 Missing ⚠️
...controller/configstatus/configstatus_controller.go 0.00% 1 Missing ⚠️
pkg/controller/constraint/constraint_controller.go 75.00% 1 Missing ⚠️
...er/constraintstatus/constraintstatus_controller.go 0.00% 1 Missing ⚠️
...ller/expansionstatus/expansionstatus_controller.go 0.00% 1 Missing ⚠️
...ntroller/mutatorstatus/mutatorstatus_controller.go 0.00% 1 Missing ⚠️
pkg/controller/syncset/syncset_controller.go 0.00% 1 Missing ⚠️
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     
Flag Coverage Δ
unittests 54.47% <50.00%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 RequeueAfter for 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 updateOrCreatePodStatus succeeds, this path returns a nil error, so the workqueue's rate-limited retry/backoff is no longer used and a persistent UpsertSource failure 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().Update failure 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().Update failure 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().Update failure 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().Update failure 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 deleteStatus succeeds, this path returns a nil error, so the workqueue's rate-limited retry/backoff is no longer used and a persistent CloseConnection failure 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 updateOrCreateConnectionPodStatus succeeds, this path returns a nil error, so the workqueue's rate-limited retry/backoff is no longer used and a persistent UpsertConnection failure 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().Update failure 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().Update failure 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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 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

  • updateOrCreatePodStatus can 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 ignores RequeueAfter and logs a warning, so the explicit delay is not used. Handle the status error separately and return reconcile.Result{} with it, using RequeueAfter only 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: true used 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: true used 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: true used 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: true used 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: true used 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: true used 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: true used 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

  • deleteStatus can return a non-nil error. In that case this returns both RequeueAfter and 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

  • updateOrCreateConnectionPodStatus returns errors from pod/status reads and writes. If it fails, this returns both RequeueAfter and 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: true used 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: true used 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 a nolint:staticcheck), so this migration still leaves an SA1019 suppression and does not fully remove Result.Requeue usage. Update that GET-error assertion to check the empty result (or RequeueAfter == 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: true used 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 RequeueAfter resets 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 old Requeue: true used 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.

@ogulcanaydogan
ogulcanaydogan force-pushed the fix/deprecated-reconcile-requeue branch from 6e93e0c to bcc145c Compare September 17, 2026 08:04

@JaydipGabani JaydipGabani left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@ogulcanaydogan

Copy link
Copy Markdown
Contributor Author

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:

  • config, configstatus, constraintstatus, constrainttemplatestatus, expansionstatus, externaldatastatus, mutatorstatus, export: these were swallowing a real error and returning nil, so now they return the actual error instead and let controller-runtime's normal rate-limited retry handle it, same as syncset already did.
  • constraint and constrainttemplate's VAPB/status-changed paths deliberately avoid surfacing the persist failure as a reconcile error (to not double-count it), so those now compute the delay from an explicit bounded exponential backoff limiter (1s to 1m) scoped to the reconciler instance, and forget it once persistence succeeds.

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).

@ogulcanaydogan
ogulcanaydogan force-pushed the fix/deprecated-reconcile-requeue branch from 64a7dc3 to b00b021 Compare September 19, 2026 14:40

@JaydipGabani JaydipGabani left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@ogulcanaydogan
ogulcanaydogan force-pushed the fix/deprecated-reconcile-requeue branch from b00b021 to 67167ba Compare September 22, 2026 19:02
@ogulcanaydogan

Copy link
Copy Markdown
Contributor Author

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.

@JaydipGabani

Copy link
Copy Markdown
Contributor

@ogulcanaydogan can you fix DCO? last commit is not signed off

@JaydipGabani JaydipGabani left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 lint fails with goconst because "unknown.target" now occurs three times in constrainttemplate_controller_test.go; define a test constant and use it at all three sites.
  • DCO reports commit 67167ba has no Signed-off-by. This repository disallows remediation commits, so amend that commit with git commit --amend --signoff and 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"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@ogulcanaydogan
ogulcanaydogan force-pushed the fix/deprecated-reconcile-requeue branch from 67167ba to ac4e3e6 Compare September 29, 2026 02:24
@ogulcanaydogan

Copy link
Copy Markdown
Contributor Author

Both gates fixed:

  • Introduced an unknownTarget test constant in constrainttemplate_controller_test.go and used it at all three sites, so the goconst finding is gone.
  • Amended 67167ba with --signoff (it's now ac4e3e6) rather than adding a remediation commit, and force-pushed with lease.

Full controller/constraint, controller/constrainttemplate and controller/export suites pass locally, gofmt clean.

@ogulcanaydogan
ogulcanaydogan force-pushed the fix/deprecated-reconcile-requeue branch from ac4e3e6 to bc50b22 Compare October 13, 2026 14:07
@ogulcanaydogan

Copy link
Copy Markdown
Contributor Author

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

@ogulcanaydogan

Copy link
Copy Markdown
Contributor Author

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

@ogulcanaydogan
ogulcanaydogan force-pushed the fix/deprecated-reconcile-requeue branch 2 times, most recently from 98453d7 to 280b5bb Compare October 21, 2026 20:14
@ogulcanaydogan

Copy link
Copy Markdown
Contributor Author

@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

@ogulcanaydogan
ogulcanaydogan force-pushed the fix/deprecated-reconcile-requeue branch from 280b5bb to 471cd3e Compare November 18, 2026 22:59
@ogulcanaydogan

Copy link
Copy Markdown
Contributor Author

@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 Requeue: true with a nil error on the failure paths of the export controller, so I left pkg/controller/export exactly as on master and this PR no longer touches it. The other ten controllers are unchanged from what you reviewed. I'm happy to convert the export controller too if you'd prefer, with its tests updated to match. Everything you flagged earlier is still addressed (the persist backoff, the Forget on delete, the unknownTarget constant, the sign-off), and go test -race on the eleven controller packages and golangci-lint on the new code are clean

@JaydipGabani JaydipGabani added the orka:review Opt in to Orka review of this pull request and subsequent pushes label Nov 20, 2026

@gatekeeper-orka-reviewer gatekeeper-orka-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, 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.
  • 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 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.

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)}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
@ogulcanaydogan
ogulcanaydogan force-pushed the fix/deprecated-reconcile-requeue branch from 471cd3e to 07d1298 Compare December 2, 2026 18:38

@gatekeeper-orka-reviewer gatekeeper-orka-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, 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.
  • 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 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.
  • 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 on Requeue: true when the accompanying status operation succeeds. The export controller tests also read result.Requeue at lines 812, 848, 922, 939, 1004, and 1440 of pkg/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)}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

This branch has not been deployed

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

Labels

orka:review Opt in to Orka review of this pull request and subsequent pushes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants