From 335f043756c18499c995c153bb7557083414eefa Mon Sep 17 00:00:00 2001 From: Bartosz Date: Thu, 5 Mar 2026 10:36:52 +0000 Subject: [PATCH] Add Min/MaxScore to replace Min/MaxNodeScore --- pkg/scheduler/framework/runtime/framework.go | 8 ++++---- .../k8s.io/kube-scheduler/framework/interface.go | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/pkg/scheduler/framework/runtime/framework.go b/pkg/scheduler/framework/runtime/framework.go index 2c5594341e7..d06d441644a 100644 --- a/pkg/scheduler/framework/runtime/framework.go +++ b/pkg/scheduler/framework/runtime/framework.go @@ -578,10 +578,10 @@ func getValidScoreWeights(f *frameworkImpl, pluginType reflect.Type, plugins []c } // Checks totalPriority against MaxTotalScore to avoid overflow - if int64(weights[e.Name])*fwk.MaxNodeScore > fwk.MaxTotalScore-totalPriority { + if int64(weights[e.Name])*fwk.MaxScore > fwk.MaxTotalScore-totalPriority { return nil, fmt.Errorf("total score of Score plugins could overflow") } - totalPriority += int64(weights[e.Name]) * fwk.MaxNodeScore + totalPriority += int64(weights[e.Name]) * fwk.MaxScore } return weights, nil } @@ -1536,8 +1536,8 @@ func (f *frameworkImpl) RunPlacementScorePlugins(ctx context.Context, state fwk. placementScoreList := pluginToPlacementScores[pl.Name()] score := placementScoreList[index].Score - if score > fwk.MaxNodeScore || score < fwk.MinNodeScore { - err := fmt.Errorf("plugin %q returns an invalid score %v, it should in the range of [%v, %v] after normalizing", pl.Name(), score, fwk.MinNodeScore, fwk.MaxNodeScore) + if score > fwk.MaxScore || score < fwk.MinScore { + err := fmt.Errorf("plugin %q returns an invalid score %v, it should in the range of [%v, %v] after normalizing", pl.Name(), score, fwk.MinScore, fwk.MaxScore) errCh.SendWithCancel(err, cancel) return } diff --git a/staging/src/k8s.io/kube-scheduler/framework/interface.go b/staging/src/k8s.io/kube-scheduler/framework/interface.go index 329c0405e31..deb751effcf 100644 --- a/staging/src/k8s.io/kube-scheduler/framework/interface.go +++ b/staging/src/k8s.io/kube-scheduler/framework/interface.go @@ -297,10 +297,20 @@ type PlacementPluginScores struct { const ( // MaxNodeScore is the maximum score a Score plugin is expected to return. - MaxNodeScore int64 = 100 + // + // Deprecated: use MaxScore instead. + MaxNodeScore int64 = MaxScore // MinNodeScore is the minimum score a Score plugin is expected to return. - MinNodeScore int64 = 0 + // + // Deprecated: use MinScore instead. + MinNodeScore int64 = MinScore + + // MaxScore is the maximum score a Score or PlacementScore plugin is expected to return. + MaxScore int64 = 100 + + // MinScore is the minimum score a Score or PlacementScore plugin is expected to return. + MinScore int64 = 0 // MaxTotalScore is the maximum total score. MaxTotalScore int64 = math.MaxInt64