Add Min/MaxScore to replace Min/MaxNodeScore

This commit is contained in:
Bartosz
2026-03-05 10:36:52 +00:00
parent db3c8f3a4b
commit 335f043756
2 changed files with 16 additions and 6 deletions

View File

@@ -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
}

View File

@@ -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