← Back to Pull requests

refactor(controller): reconcile pipeline with guaranteed status sync (canary + blue-green). Fixes #4626 #4963

Open
unknown opened this pull request with 650 lines diff across 8 files
View on GitHub
unknown unknown commented on Aug 07, 2026 20:48 UTC
Author

Summary

  • Phase 1: Guarantee syncRolloutStatusCanary() runs after every canary reconcile pass so evaluateProgressDeadlineAbort, progress deadline timeout, and requeueStuckRollout cannot be skipped when a stage errors (#4626). Ports #4962's weight-verification safety (stable scale-down hold, shouldFullPromote verified-weight check, end-of-rollout unverified-weight handling). The only exceptions are ReplicaSet-sync failures (stageFatalNoStatus), where c.newRS is unreliable and a status computed from it would persist corrupted values (e.g. clear abort state or record a pod hash for a ReplicaSet that was never created).

  • Phase 2: Replace per-pass deferral flags with persisted rollout conditions (TrafficRoutingApplied, ServicesReconciled, ReconcileSucceeded) merged during status sync; progression gates read current-pass stage condition state. A previously-False condition only recovers to True when its owning stage actually re-ran and succeeded — a pass that stopped before the stage leaves it untouched rather than reporting a phantom recovery.

  • Phase 3: Replace the hand-rolled canary stage chain with a declarative stage table + executor. All stage failures record their condition, complete the status sync, and then return the error for workqueue backoff — so persistent failures show up in reconcile-error metrics and retry with exponential backoff instead of a fixed-interval requeue. Warning events for stage failures are emitted only when the condition transitions, not on every retry pass.

  • Phase 4: Extend the guaranteed status sync to blue-green: the apply steps move to reconcileBlueGreen() and syncRolloutStatusBlueGreen() always runs afterward, closing the same #4626 wedge class for the blue-green strategy (covered by TestBlueGreenProgressDeadlineAbortNotBlockedByApplyError). awsVerifyTargetGroups now marks verification attempted-and-failed when listing TargetGroupBindings errors, so the promotion gate cannot read a failed verification as verified.
  • Additional hardening from review:

  • promote --full remains held while traffic weights are unverified or a stage failed this pass (the provider may still be routing traffic to stable); a PromoteFullHeld warning event now tells the operator why the forced promotion did not take effect.

  • Combined stage/status errors use errors.Join instead of kerrors.NewAggregate, so errors.As-based checks (k8serrors.IsNotFound in the workqueue handler) keep working.

  • Stage conditions are removed when a rollout migrates from canary to blueGreen instead of freezing a stale False condition into status forever.

  • Stage condition messages truncate on a UTF-8 rune boundary.

  • The unverified-weights predicate is centralized in weightutil.VerificationPending.

  • Cosmetic stage failures (ephemeralMetadata, revisionHistory) use a new stageContinueWithError outcome: they record ReconcileSucceeded=False and still surface the error, but no longer stop the remaining stages — services, traffic routing, and scaling still run. Blue-green gets the same treatment by ordering: both cosmetic steps run last in reconcileBlueGreen, so a denied ReplicaSet deletion can no longer block the active service switch (previously reconcileRevisionHistoryLimit ran before the service reconcile).

  • Step plugin controller-side errors (resolver/RPC failures) drop their private hasError side channel (swallowed error, fixed 30s requeue, per-pass ReconciliationError events) and flow through the stage pipeline like every other failure: ReconcileSucceeded=False condition, transition-gated event, workqueue backoff, error metrics. Plugin-protocol phases (StepPluginPhaseError backoff, StepPluginPhaseFailed abort) are unchanged.
  • Supersedes #4962 — same #4626 fix, generalized to all canary stages and to blue-green.

    Behavior changes (release note)

    1. Rollouts stuck on a persistently failing reconcile step (traffic router, service update, target group verification, analysis, etc.) now evaluate progressDeadlineAbort every reconcile and can time out / auto-abort when progressDeadlineAbort: true. Previously they could stay Progressing forever. This applies to both canary and blue-green.
    2. Traffic-routing failures now surface as reconcile errors: they count in reconcile-error metrics and retry with workqueue exponential backoff (previously a fixed ~10s requeue with no error reported). Alerting on controller error rates will now see these failures; retry cadence against a persistently failing provider backs off instead of hammering it.
    3. Canary rollouts gain three status conditions that surface reconcile failures: TrafficRoutingApplied, ServicesReconciled, and ReconcileSucceeded. They appear on failure and flip back to True when the failing stage recovers.
    4. kubectl argo rollouts promote --full is held while desired traffic weights are unverified by the provider or a stage failed during the current reconcile; a PromoteFullHeld warning event is emitted so the hold is visible.
    5. Failures in cosmetic stages (ephemeral pod metadata labeling, revision-history cleanup) no longer block the rest of the reconcile pass, for both canary and blue-green: services, traffic routing/active-service switching, and scaling still reconcile while the failure is surfaced as a reconcile error (and, on canary, via the ReconcileSucceeded condition). Step progression still holds on canary until the stage recovers. Scaling-only passes no longer prune blue-green revision history (matching canary).
    6. Step plugin controller-side errors (plugin resolution or RPC failures) now surface as reconcile errors with exponential backoff and the ReconcileSucceeded condition, instead of a fixed 30s requeue with a ReconciliationError event on every pass. Plugin-reported phases and their configured backoff behave as before.

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: agaudreault Review duration: 124934m
    All Vouch review confidence checks passed
    Residual risk 0.33 = Change Risk (0.59) × (1 − Review Confidence (0.45)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.59 · 650 lines diff across 8 files
    0.59
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    44%
    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.388
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #4963"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 44.7% 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: 59% (MEDIUM) · Higher = larger blast radius
    59%
    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: 44.7% · Lower = rushed or shallow review
    44.7%
    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: 32.6% · Safe to merge
    32.6%