Skip to content

Commit 50e964a

Browse files
committed
scheduler: account for affinity value of zero in score normalization
If there are no affinities on a job, we don't want to count an affinity score of zero in the number of scores we divide the normalized score by. This is how we handle other scoring components like node reschedule penalties on nodes that weren't running the previous allocation. But we also exclude counting the affinity in the case where we have affinity but the value is zero. In pathological cases, this can result in a node with a low affinity being picked over a node with no affinity, because the denominator is 1 larger. Include zero-value affinities in the count of scores if the job has affinities but the value just happens to be zero. Fixes: #25621
1 parent 01cd762 commit 50e964a

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

scheduler/rank.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -972,10 +972,8 @@ func (iter *NodeAffinityIterator) Next() *RankedNode {
972972
}
973973
}
974974
normScore := totalAffinityScore / sumWeight
975-
if totalAffinityScore != 0.0 {
976-
option.Scores = append(option.Scores, normScore)
977-
iter.ctx.Metrics().ScoreNode(option.Node, "node-affinity", normScore)
978-
}
975+
option.Scores = append(option.Scores, normScore)
976+
iter.ctx.Metrics().ScoreNode(option.Node, "node-affinity", normScore)
979977
return option
980978
}
981979

0 commit comments

Comments
 (0)