diff --git a/pkg/scheduler/framework/plugins/helper/normalize_score.go b/pkg/scheduler/framework/plugins/helper/normalize_score.go index 2c7c951c851..3d35ca30493 100644 --- a/pkg/scheduler/framework/plugins/helper/normalize_score.go +++ b/pkg/scheduler/framework/plugins/helper/normalize_score.go @@ -21,8 +21,9 @@ import ( ) // DefaultNormalizeScore generates a Normalize Score function that can normalize the -// scores to [0, maxPriority]. If reverse is set to true, it reverses the scores by -// subtracting it from maxPriority. +// scores from [0, max(scores)] to [0, maxPriority]. If reverse is set to true, it +// reverses the scores by subtracting it from maxPriority. +// Note: The input scores are always assumed to be non-negative integers. func DefaultNormalizeScore(maxPriority int64, reverse bool, scores framework.NodeScoreList) *framework.Status { var maxCount int64 for i := range scores { diff --git a/pkg/scheduler/framework/plugins/helper/normalize_score_test.go b/pkg/scheduler/framework/plugins/helper/normalize_score_test.go index 50680a65159..e3d10a3a401 100644 --- a/pkg/scheduler/framework/plugins/helper/normalize_score_test.go +++ b/pkg/scheduler/framework/plugins/helper/normalize_score_test.go @@ -61,6 +61,15 @@ func TestDefaultNormalizeScore(t *testing.T) { scores: []int64{0, 1, 1, 1}, expectedScores: []int64{100, 0, 0, 0}, }, + { + scores: []int64{0, 0, 0, 0}, + expectedScores: []int64{0, 0, 0, 0}, + }, + { + reverse: true, + scores: []int64{0, 0, 0, 0}, + expectedScores: []int64{100, 100, 100, 100}, + }, } for i, test := range tests {