Skip to content

Commit b02aad4

Browse files
committed
Fix panic when process RunScorePlugins for cap out of range
Signed-off-by: kerthcet <[email protected]>
1 parent 4734021 commit b02aad4

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
@@ -1015,7 +1015,7 @@ func (f *frameworkImpl) RunScorePlugins(ctx context.Context, state *framework.Cy
10151015
metrics.FrameworkExtensionPointDuration.WithLabelValues(metrics.Score, status.Code().String(), f.profileName).Observe(metrics.SinceInSeconds(startTime))
10161016
}()
10171017
allNodePluginScores := make([]framework.NodePluginScores, len(nodes))
1018-
numPlugins := len(f.scorePlugins) - state.SkipScorePlugins.Len()
1018+
numPlugins := len(f.scorePlugins)
10191019
plugins := make([]framework.ScorePlugin, 0, numPlugins)
10201020
pluginToNodeScores := make(map[string]framework.NodeScoreList, numPlugins)
10211021
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)