← Back to Pull requests

fix: set drain-succeeded when a custom drain completes or is skipped #2561

Closed
unknown closed this pull request without merging on Nov 27, 2026 12:09 UTC
View on GitHub
unknown unknown commented on Nov 26, 2026 15:21 UTC
Author

Summary

Fixes #2539.

When a custom drain completed, node-drainer marked the event AlreadyDrained but left the node's dgxc.nvidia.com/nvsentinel-state label at draining. fault-remediation then failed its first attempt on draining -> remediating and created no maintenance CR on that attempt. DrainOverrides.Skip had the same gap from quarantined.

  • node-drainer moves the label to drain-succeeded when a custom drain CR completes (the event's own CR, or the completed CR of another event of the node) and for DrainOverrides.Skip. The write is conditional. A completed CR replaces quarantined or draining. Skip replaces only quarantined, because a draining label then belongs to the drain of another event. A label that another module has moved on (for example remediating) or removed is never overwritten or added back. Healthy events and events covered by an earlier drain leave the label alone. A completed custom drain also takes the node out of the draining queue priority, as the built-in drain does. A deleted node has no label to move, so its event is still marked AlreadyDrained.

  • commons: StateManager.UpdateNVSentinelStateNodeLabelIfMatch, the set counterpart of RemoveNVSentinelStateNodeLabelIfMatch. The check and the write share one conflict-retried read and update.

  • fault-remediation: when the remediating write lands but reports an unexpected transition, performRemediation goes on if the node's quarantine annotation still lists the event. If the annotation no longer lists it, the attempt fails as before. fault-quarantine removes the label when a quarantine ends, and that failure is what stops a never-attempted event of an ended session, because eventResolvedInStore checks the live quarantine only after a failed attempt. The write after the CR is created fails the attempt only when the label was not written.

  • Docs: the drain-succeeded rows in docs/state-manager.md, the skip row in docs/health-event-data-model.md, the state list in docs/runbooks/cordoned-nodes.md and the label table in docs/tutorials/requesting-node-maintenance.md.
  • TestPerformRemediationWithUpdateNodeStateLabelFailures asserted that a written but unexpected label fails the attempt, which is the behaviour this issue reports (its own comment said the remediation should still succeed). TestPerformRemediation_LabelUpdateError_ContinuesOnlyWhenLabelWrittenAndEventQuarantined replaces it and keeps the failing cases: label not written, quarantine ended, live node read error.

    Not in this change:

  • Nodes already at draining with a terminal event are not repaired.

  • Events whose producer sets HealthEvent.Id (lifecycle-manager) do not match the quarantine annotation by ID. That is #2540, fixed separately. With this change, their first attempt no longer fails on the label. A retry after any other failure still hits #2540.

  • #2546 adds a UpdateNVSentinelStateNodeLabelIfMatch with the same signature that also validates the transition. node-drainer only uses valid transitions (quarantined or draining to drain-succeeded), so it works with either version. Whichever PR merges second keeps one copy. Once drain-stopped exists, the two lists of replaceable values here need a decision on it.
  • Testing

    Manual test on the custom drain demo (demos/local-slinky-drain-demo, chart v1.33.0, slinky-drainer completing the DrainRequest, XID 95 injected on the fake DCGM). The kind node runs Kubernetes 1.32, where node-drainer from main does not start (it needs resource.k8s.io/v1), so this change was applied to v1.33.0 for the run. The ConfigMap and RBAC were the v1.33.0 rendering in both runs.

  • node-drainer v1.33.0: Drain CR completed, then Deleted custom drain CR, with no label write. The label stayed draining for the 7 minutes observed.

  • node-drainer v1.33.0 with this change: Drain CR completed, then Label conditionally updated ... previousValue=draining value=drain-succeeded 9 ms later, then Deleted custom drain CR. The demo's recovery then uncordoned the node and removed the label, and node-drainer wrote no label for the recovery events.
  • fault-remediation is disabled in the demo, so its first attempt was not part of the manual run.

    go vet, golangci-lint v2.15.0 and go test -race ./... pass for commons, node-drainer and fault-remediation. The regression tests below fail against main b0e0132d9:

  • node-drainer envtest TestReconciler_CustomDrainCRCompleted_MovesDrainingLabelToDrainSucceeded: the event's own CR, or an earlier event's CR, completes and the label moves from draining (or quarantined) to drain-succeeded. A label set to remediating or removed during the drain stays as it is. The node's next event is queued at high priority.

  • node-drainer envtest TestReconciler_HealthyAndSkip_OnlySkipMovesQuarantinedToDrainSucceeded: Skip moves quarantined to drain-succeeded and keeps another drain's draining label and queue priority. A healthy event never moves the label.

  • node-drainer evaluator table: DrainSucceededFrom for every result of the custom drain, skip, healthy and covered paths.

  • commons TestUpdateNVSentinelStateNodeLabelIfMatch_: matching value, value not expected, missing label, a newer value written during a conflict, update error, node not found.

  • fault-remediation envtest TestReconcile_AlreadyDrainedEventWithStaleStateLabel_RemediatesOnlyActiveUnhealthyEvent: with the label at draining or quarantined and the event in the quarantine annotation, the first attempt creates the CR. An event whose quarantine ended before its first attempt fails without a CR. A healthy event creates no CR.

  • fault-remediation TestPerformRemediation_LabelUpdateError_ContinuesOnlyWhenLabelWrittenAndEventQuarantined.
  • 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)
  • 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
    Skipped drains and completed custom drains now set a node to drain-succeeded only from eligible states, preserving unrelated or newer states.
    Remediation now verifies that quarantine is still active before proceeding and handles state-update errors when the update took effect.
    Events whose quarantine has ended are closed without starting remediation. Events already covered by a maintenance request wait for that request or close with it.
    Documentation
    * Clarified when skipped drains and completed custom drains result in the drain-succeeded state.
    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: KaivalyaMDabhadkar Review duration: 1247m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    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.388
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #2561"
    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: 52% (MEDIUM) · Higher = larger blast radius
    52%
    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: 20.5% · Safe to merge
    20.5%