Skip to content

Commit d84ee0b

Browse files
authored
Merge pull request kubernetes#121632 from kerthcet/fix/runscoreplugins
Fix panic when process RunScorePlugins for cap out of range
2 parents 947953f + b02aad4 commit d84ee0b

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

pkg/scheduler/framework/runtime/framework.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1030,7 +1030,7 @@ func (f *frameworkImpl) RunScorePlugins(ctx context.Context, state *framework.Cy
10301030
metrics.FrameworkExtensionPointDuration.WithLabelValues(metrics.Score, status.Code().String(), f.profileName).Observe(metrics.SinceInSeconds(startTime))
10311031
}()
10321032
allNodePluginScores := make([]framework.NodePluginScores, len(nodes))
1033-
numPlugins := len(f.scorePlugins) - state.SkipScorePlugins.Len()
1033+
numPlugins := len(f.scorePlugins)
10341034
plugins := make([]framework.ScorePlugin, 0, numPlugins)
10351035
pluginToNodeScores := make(map[string]framework.NodeScoreList, numPlugins)
10361036
for _, pl := range f.scorePlugins {

pkg/scheduler/framework/runtime/framework_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1385,6 +1385,22 @@ func TestRunScorePlugins(t *testing.T) {
13851385
},
13861386
},
13871387
},
1388+
{
1389+
name: "skipped prescore plugin number greater than the number of score plugins",
1390+
plugins: buildScoreConfigDefaultWeights(scorePlugin1),
1391+
pluginConfigs: nil,
1392+
skippedPlugins: sets.New(scorePlugin1, "score-plugin-unknown"),
1393+
want: []framework.NodePluginScores{
1394+
{
1395+
Name: "node1",
1396+
Scores: []framework.PluginScore{},
1397+
},
1398+
{
1399+
Name: "node2",
1400+
Scores: []framework.PluginScore{},
1401+
},
1402+
},
1403+
},
13881404
}
13891405

13901406
for _, tt := range tests {

0 commit comments

Comments
 (0)