feat(scheduler): honor preferred nodeAffinity in node score #3298
All Vouch review confidence checks passed
Residual risk 0.18 = Change Risk (0.46) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.46 · 471 lines diff across 5 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 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
Diff Size
diff_size
0.368
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #3298"
general
weight: 0.35
blackdragoon26
What type of PR is this?
/kind feature
What this PR does / why we need it:
HAMi pick one node inside Filter, so kube-scheduler score plugins (like NodeAffinity) can not change the result.
When pod has
preferredDuringSchedulingIgnoredDuringExecution, HAMi just ignore it and only use GPU score.In my cluster the pod go to node B even node A was preferred with weight 100 (see issue).
This PR add a small bonus to HAMi node score for the node that match pod preferred nodeAffinity.
--node-affinity-score-weight(W), default0= off, so nothing change after upgrader = matched term weight / total term weight(0 ~ 1),bonus = W rscore + bonus, spread:score - bonus, so preferred node always win on both policyk8s.io/component-helpers/scheduling/corev1/nodeaffinity, same as kube-schedulercalcScoreWithOptions, then every node only do label matchOverrideScore, Filter and Bind flow is not changedscheduler.defaultSchedulerPolicy.nodeAffinityScoreWeight, README table regenerated with helm-docsPod without preferred affinity is same as before. If W is 0 the code path is skipped totally.
Which issue(s) this PR fixes:
Fixes #3062
Special notes for your reviewer:
k8s.io/component-helpersis pinned tov0.37.1, same minor as other k8s.io modules, like you asked.NodeScore.Nodecan be nil, in that case no bonus.-
pkg/scheduler/policy/node_affinity_test.go: unit test for parse + bonus (nil pref, nil node, W=0, full match binpack/spread, partial match 70/30, no match)-
pkg/scheduler/node_affinity_score_test.go: calcScore level with 2 nodes. feature off = old behavior, binpack and spread pick preferred node, many terms follow weight ratio, preferred node unfit → fallback to other node (no Pending), invalid term ignoredDoes this PR introduce a user-facing change?:
``
release-note--node-affinity-score-weightScheduler: new flag
(chart valuescheduler.defaultSchedulerPolicy.nodeAffinityScoreWeight) adds a bonus to the HAMi node score for nodes matching the Pod's preferred nodeAffinity. Default 0 keeps the current behavior.AI Assistance Disclosure:
I used Claude Code to help me investigate the code, make the changes (I reviewed and approved each one), and refine the content of this PR.
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
<!-- coderabbit-ai-generated:v1 -->
Summary by CodeRabbit
New Features
Added an optional node-affinity scoring weight to scheduling configuration. When enabled, preferred node-affinity matches influence node ranking in proportion to their weights, according to the configured binpack or spread policy. The default value of 0` disables this scoring. Configure the setting through the scheduler or Helm chart; invalid weights are rejected.
Documentation
* Clarified how node selection and affinity scoring interact, including the limits of other scheduler scoring plugins. Documented the setting’s default and scoring behavior.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->