Skip to content

fix(controller): escalate persistent completes-with-error reconcile cycles to process exit - #110

Merged
kyle-sexton merged 5 commits into
mainfrom
fix/persistent-reconcile-failure-escalation
Jul 18, 2026
Merged

kyle-sexton merged 5 commits into
mainfrom
fix/persistent-reconcile-failure-escalation

Conversation

@kyle-sexton

@kyle-sexton kyle-sexton commented Jul 18, 2026 •

Copy link
Copy Markdown
Member

Summary

The Step watchdog only catches a Step that never returns. A Step that fails fast every cycle with a globally-blocking observation error — saturated jobs index, wedged state lock — reconciled nothing for hours while the process looked alive: the completes-with-error outage class carved out of #54 as #111, observed in both the #93 and #98 incidents. Both recovered on process restart, which the scheduled task's restart-on-failure policy can supply automatically.

Change

  • ReconcileResult gains NewWorkBlocked, set from the reconciler's observation-failed state (failed resource, worker-inventory, desktop, power, desired-state, or job-index observation) — as opposed to per-target errors that leave the remaining pools reconciling.
  • New reconcileFailureStreak counts consecutive Steps that completed with an error while all new work was blocked; any clean or partial outcome resets it. Keying on the blocked flag keeps one persistently misconfigured target (which the live controller retries harmlessly forever) from consuming the scheduled task's bounded restart budget.
  • At 20 consecutive blocked failures (~10 minutes at the default reconcile cadence, sized as a fixed multiple of cadence rather than a new tunable) the controller logs a distinct reconcile-persistent-failure event and exits non-zero via a sentinel that deliberately does not match ErrControllerRestartRequested.
  • Graceful shutdown is deliberately skipped on this path: reconciler.Shutdown exercises the same failing subsystem and would hang or fail identically. A fresh process reclaims wedged in-process state and re-adopts surviving worker containers at startup.

Scope

The external health watchdog / alerting asks stay open on #54 (they live outside the controller).

Testing

  • TestReconcileFailureStreakEscalatesOnlyOnUnbrokenBlockedErrorRun, TestReconcileFailureStreakResetsOnAnyCleanStep, TestReconcileFailureStreakIgnoresPartialPerTargetFailures, TestErrReconcilePersistentlyFailingDoesNotClaimRestartExitCode.
  • go build, go vet, gofmt clean; app and controller packages green.

Related

Closes #111

🤖 Generated with Claude Code

…ycles to process exit

The Step watchdog only catches a Step that never returns; a Step failing
fast every cycle (saturated jobs index, wedged state lock) reconciled
nothing for hours while the process looked alive — the residual outage
class of #54 observed in the #93/#98 incidents, both of which recovered
on process restart.

Track an unbroken run of completed-with-error Steps; at 20 consecutive
failures (~10 minutes at the default cadence) log a distinct
reconcile-persistent-failure event and exit non-zero so the scheduled
task's restart-on-failure policy relaunches a fresh process. Any clean
Step resets the streak, so transient errors never approach the
threshold. Graceful shutdown is deliberately skipped on this path — it
exercises the same failing subsystem.

Refs #54

Co-Authored-By: Claude Fable 5 <[email protected]>

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ebdadfa261

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/app/controller_main.go Resolved
Reconciler.Step returns an error for a per-target ensure/statistics
failure even while the remaining pools keep reconciling; counting those
toward the persistent-failure exit would let one misconfigured target
consume the scheduled task's bounded restart budget and leave no
controller running (Codex review finding on #110).

Surface the observation-failed state as ReconcileResult.NewWorkBlocked
and key the escalation streak on error+blocked; any clean or partial
outcome resets it.

Co-Authored-By: Claude Fable 5 <[email protected]>
@kyle-sexton kyle-sexton reopened this Jul 18, 2026

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ae06bc0f47

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/controller/reconciler.go Resolved
…ation

A failing LoadDesired forces every listener to zero (forcedZero) yet
never set observationFailed, so NewWorkBlocked reported false and each
such cycle reset the persistent-failure streak instead of advancing it
(Codex review finding on #110).

Co-Authored-By: Claude Fable 5 <[email protected]>

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 15910e52b9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/controller/reconciler.go Resolved
Desired-state initialization failure and unsafe-observed-state early
returns produced a zero ReconcileResult, so NewWorkBlocked read false and
each such cycle reset the escalation streak despite nothing having been
reconciled (Codex review finding on #110). Context-cancellation early
return stays unmarked — that is lifecycle, not a wedge.

Co-Authored-By: Claude Fable 5 <[email protected]>

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1e6fb85350

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/controller/reconciler.go Resolved
The post-capacity-update worker refresh and job-index refresh failures
zero admission capacity and record that new work is blocked, but never
set observationFailed, so NewWorkBlocked read false and those cycles
reset the escalation streak (Codex review finding on #110). Both
mutations are safe: the earlier observationFailed consumers (resource
zeroing, the cadence goroutine's forcedZero) capture its value before
this point.

Co-Authored-By: Claude Fable 5 <[email protected]>
@kyle-sexton
kyle-sexton merged commit 067be05 into main Jul 18, 2026
1 check passed
@kyle-sexton
kyle-sexton deleted the fix/persistent-reconcile-failure-escalation branch July 18, 2026 23:39
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.

Controller stays alive but reconciles nothing when every Step completes with a blocking error (in-process half of #54)

1 participant