fix(utils): inject node selector requirements into existing terms #6276
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
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 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
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
cheyang
Ⅰ. Describe what this PR does
InjectNodeSelectorRequirementsis howrunAfter.affinityStrategywithpolicy: Requireadds 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 ...NodeSelectorTermsand appended to the loop variable.rangehands 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
NodeSelectorTermsslice 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
Requirewill now also carry the requirement, so if the two cannot be satisfied together the pod stays Pending, which is whatRequireasks for. ThePreferpath and the webhook'sInjectNodeSelectorTermsare untouched.