mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-07-19 07:25:19 +00:00
Add Min/MaxScore to replace Min/MaxNodeScore
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user