← Back to Pull requests

fix(fault-quarantine): stop cold-start recovery cleanly when the breaker refuses an event #2440

Closed
unknown closed this pull request without merging on Nov 18, 2026 15:50 UTC
View on GitHub
unknown unknown commented on Nov 17, 2026 08:59 UTC
Author

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 tripped per event, the first refusal sets the recovery's firstErr, 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. checkCircuitBreakerAndHalt returns coldstart.ErrBreakerRefused in 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 refused result label for fault_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


  • 🐛 Bug fix

  • ✨ New feature

  • 💥 Breaking change

  • 📚 Documentation

  • 🔧 Refactoring

  • 🔨 Build/CI
  • Component(s) Affected


  • Health Monitor

  • Core Service

  • Fault Management

  • Janitor

  • Deployment/Config

  • API/Interface

  • Preflight

  • Plugins

  • Documentation/CI

  • New Component

  • Multiple Components

  • Other
  • Testing


  • Tests pass locally

  • Manual testing completed

  • No breaking changes (or documented)
  • Three new cases in pkg/coldstart/coldstart_test.go pin 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. The pkg/reconciler suite needs the kubebuilder envtest control plane, which is not installed on this machine, so it runs in CI only.

    Checklist


  • Self-review completed

  • Documentation updated (if needed)

  • Ready for review
  • <!-- 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 -->

    Diff: 567 lines (+425 / -142) across 7 files Reviewer: KaivalyaMDabhadkar Review duration: 1851m
    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
    0.50
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 49.7% (MEDIUM) · Higher = larger blast radius
    49.7%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 19.6% · Safe to merge
    19.6%