fix(fault-quarantine): stop cold-start recovery cleanly when the breaker refuses an event #2440
All Vouch review confidence checks passed
Residual risk 0.20 = Change Risk (0.50) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.50 · 567 lines diff across 7 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.379
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #2440"
general
weight: 0.35
KaivalyaMDabhadkar
Summary
Fixes #2438. When the circuit breaker re-trips mid-recovery, cold-start recovery currently fails the whole run: the gate's recovery branch returns
circuit breaker is trippedper event, the first refusal sets the recovery'sfirstErr, every further refused event increments the failure count, and the completed-with-failures recovery escalates into an application-level fatal — the process exits 1 and the kubelet restarts it into the parked state. The live event path answers the same state by parking, so one breaker trip produces a crash on one path and a graceful park on the other.The fix gives the refusal its own error class instead of letting it masquerade as a processing failure.
checkCircuitBreakerAndHaltreturnscoldstart.ErrBreakerRefusedin a recovery context (message unchanged), and the recovery treats it as a stop signal: the scan stops at the refused event, terminal results accumulated ahead of the refusal are flushed and persisted, and the refused events stay unresolved and retry on the next startup — which is what the code already documents as their intended fate ("They remain unresolved and will retry on the next startup", the comment above the healthy-recovery phase). The process then continues to the live watcher, where the first event parks on the live path exactly as designed: the same terminal state as today, without the crash and restart.Visible behavior change: resetting a tripped breaker while unresolved events exist no longer costs one fault-quarantine crash-and-restart (the repro in #2438), and refused events are no longer counted into
fault_quarantine_cold_start_events_total{result="failed"}— the failure count means processing failures only. The metric's label set is unchanged, so no doc change is needed.Why the gate keeps returning an error instead of parking in the recovery branch: the recovery iterates a store query inside a batch callback, and a
<-ctx.Done()park inside that callback releases on ordinary shutdown — a terminating pod would resume the very recovery the gate was supposed to be holding, during its deletion grace. The stop decision therefore belongs to the recovery, which can flush what it completed and return cleanly.Deliberately not done: a dedicated
refusedresult label forfault_quarantine_cold_start_events_total, which would make the stop distinguishable from unprocessed events by metric. It would make the refusal observable, but it widens the metric's label surface and the ERROR log line already records the stop with its cause; worth adding if maintainers want the signal.Type of Change
Component(s) Affected
Testing
Three new cases in
pkg/coldstart/coldstart_test.gopin the stop semantics: a refusal mid-scan returns nil and skips the healthy phase; terminal results accumulated ahead of the refusal are flushed and persisted; a refusal in the healthy phase also returns nil. The before-state — one crash-and-restart per reset while unresolved events exist — is the live repro in #2438; the fixed binary has not been run against a live cluster, so the unit tests pin the recovery's stop behavior instead. Thepkg/reconcilersuite needs the kubebuilder envtest control plane, which is not installed on this machine, so it runs in CI only.Checklist
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
<!-- coderabbit-ai-generated:v1 -->
Summary by CodeRabbit
Bug Fixes
Cold-start recovery now stops cleanly when the circuit breaker refuses processing, without treating the refusal as a recovery failure.
Events completed before a refusal are preserved, while the refused event and remaining events stay unresolved for a later recovery.
A refusal during either fault or healthy-event scanning stops recovery from proceeding to another scan phase.
* When a scan stops early, its saved cutoff no longer skips events that were not processed.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->