← Back to Pull requests

fix(utils): inject node selector requirements into existing terms #6276

Open
unknown opened this pull request with 262 lines diff across 3 files
View on GitHub
unknown unknown commented on Nov 19, 2026 21:03 UTC
Author

Ⅰ. Describe what this PR does

InjectNodeSelectorRequirements is how runAfter.affinityStrategy with policy: Require adds the node (or zone, region, custom label) of the preceding data operation to the pod affinity of the next one.

When the operation already had its own required node affinity, the function looped with for _, nodeSelectorTerm := range ...NodeSelectorTerms and appended to the loop variable. range hands out a copy of each term, so the appended requirements were discarded and the pod was not tied to the preceding operation's node.

This PR appends through the slice index so that every existing term gets the requirement (node selector terms are ORed, so each one needs it). It also treats an empty but non-nil NodeSelectorTerms slice like a nil one, so the requirement is added as a new term instead of being lost there as well.

Ⅱ. Does this pull request fix one issue?

fixes #6275

Ⅲ. List the added test cases (unit test/integration test) if any, please explain if no tests are needed.

  • pkg/utils, TestInjectNodeSelectorTermsToAffinity: "requirements are appended to every existing term" (two existing terms) and "empty but non-nil terms get a new term".

  • pkg/dataflow, TestInjectAffinityByRunAfterOp: "require policy, operation already has its own required affinity" (a GPU term plus the hostname of the preceding operation).
  • All three cases fail on master and pass with this change. The existing cases still pass.

    Ⅳ. Describe how to verify it

    go test -gcflags=all=-l ./pkg/utils/ -run TestInjectNodeSelectorTermsToAffinity
    go test -gcflags=all=-l ./pkg/dataflow/ -run TestInjectAffinityByRunAfterOp

    Ⅴ. Special notes for reviews

    The function still edits the affinity it is given in place and returns it, as before. Operations that have their own required affinity and use Require will now also carry the requirement, so if the two cannot be satisfied together the pod stays Pending, which is what Require asks for. The Prefer path and the webhook's InjectNodeSelectorTerms are untouched.

    Diff: 262 lines (+196 / -66) across 3 files Reviewer: cheyang Review duration: 4241m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.39) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.39 · 262 lines diff across 3 files
    0.39
    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%
    46%
    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
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.333
    Real PR Conversation Timeline
    1 comments
    "Review active on #6276"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.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: 39.3% (MEDIUM) · Higher = larger blast radius
    39.3%
    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: 46.7% · Lower = rushed or shallow review
    46.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: 20.9% · Safe to merge
    20.9%