Skip to content

fix(controller): QMC terminal-error backstop requeue (AUTH-14 watch flake root cause) - #162

Merged
konih merged 2 commits into
mainfrom
worktree-auth14-terminal-retry
Jul 27, 2026
Merged

konih merged 2 commits into
mainfrom
worktree-auth14-terminal-retry

Conversation

@konih

@konih konih commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Root cause identified: after a 401 Unauthorized (terminal error), fail() returned ctrl.Result{}, nil — no requeue. The controller was permanently stuck until the Secret-watch fired. Under loaded kind/CI, a transient hub re-read failure in secretEnqueueMapper silently dropped the enqueue, stranding the QMC forever. This is why the spec timed out at both 3m and 5m with zero reconcile events in that window.
  • Add TerminalRetryInterval (2m default, overridable via SetTerminalRetryInterval) as a backstop requeue in the fail() terminal path. The Secret watch remains the fast path; the backstop fires if the watch enqueue was dropped.
  • Unit test updated to assert the terminal path now returns RequeueAfter = TerminalRetryInterval().
  • E2e test description and timing-helper comment updated to reflect watch-or-backstop semantics (the previous "WITHOUT any other trigger" comment was now false).

Test plan

  • task verify green ✅
  • task test:run green (internal/ 92.5%, api/ 76.3%) ✅
  • task lint green ✅
  • task format:check green ✅
  • CI e2e (kustomize) — watch-driven spec should now pass within 5m (worst-case recovery ≈ 2m backstop + ~30s overhead)

AUTH-14 watch-driven recovery flaked because a transient hub re-read
failure in secretEnqueueMapper silently dropped the enqueue, and the
fail() terminal path returned ctrl.Result{}, nil — leaving the QMC
permanently stuck until a future watch event arrived.

Add TerminalRetryInterval (2m default) backstop: the QMC reconciler now
schedules a periodic requeue on terminal errors (e.g. 401 Unauthorized)
so the controller self-heals within the retry window even if the Secret
watch enqueue was dropped. The Secret watch remains the fast path.

Update e2e test description and timing-helper comment to reflect the
watch-or-backstop semantics, and pin the new behaviour with a unit
assertion on the terminal error path.
@codecov

codecov Bot commented Jul 27, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.61538% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/controller/secret_watch.go 0.00% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

…AUTH-14)

F-01: amend ADR-0014 with the QMC auth-recovery carve-out, documenting
that QMC ping auth failures (401) are recoverable via Secret rotation
and a 2-minute backstop requeue is permitted. Fix wrong ADR-0023
citation in code comment and test → ADR-0014.

F-02: add TestSetTerminalRetryInterval covering zero/negative-ignore guard.
Wire --terminal-retry-interval CLI flag in cmd/main.go so the default
is operator-tunable (matching sibling flags for transient/connection-wait).

F-05 (P2): raise V(1).Info to Error in unionSecretRefs for non-ignorable
hub read failures so a silently-dropped union-Secret enqueue is visible
in operator logs, aiding diagnosis even though the backstop recovers it.
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
64.3% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@konih
konih merged commit fd0da61 into main Jul 27, 2026
24 of 26 checks passed
@konih
konih deleted the worktree-auth14-terminal-retry branch July 27, 2026 17:33
konih added a commit that referenced this pull request Jul 27, 2026
The 5m window is empirically too tight under post-merge CI conditions
(2 failures: cd032df, fd0da61). Worst case with the 2m TerminalRetryInterval
backstop (PR #162): if the backstop fires just before the secret rotation is
visible, the next cycle fires at T+2m again; adding ~1m reconcile overhead
under loaded runners gives 5m total. 8m gives headroom without masking a
total watch miss.
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.

1 participant