Merge pull request #116287 from csDengh/minor_code_improvement

scheduler: get an element from the nodes slice out of the loop for the better performance
This commit is contained in:
Kubernetes Prow Robot 2023-03-06 09:24:49 -08:00 committed by GitHub
commit 89d1a7971e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -952,8 +952,8 @@ func (f *frameworkImpl) RunScorePlugins(ctx context.Context, state *framework.Cy
if len(plugins) > 0 { if len(plugins) > 0 {
// Run Score method for each node in parallel. // Run Score method for each node in parallel.
f.Parallelizer().Until(ctx, len(nodes), func(index int) { f.Parallelizer().Until(ctx, len(nodes), func(index int) {
nodeName := nodes[index].Name
for _, pl := range plugins { for _, pl := range plugins {
nodeName := nodes[index].Name
s, status := f.runScorePlugin(ctx, pl, state, pod, nodeName) s, status := f.runScorePlugin(ctx, pl, state, pod, nodeName)
if !status.IsSuccess() { if !status.IsSuccess() {
err := fmt.Errorf("plugin %q failed with: %w", pl.Name(), status.AsError()) err := fmt.Errorf("plugin %q failed with: %w", pl.Name(), status.AsError())