Make sure skip score plugins alwarys returned

Signed-off-by: kerthcet <kerthcet@gmail.com>
This commit is contained in:
kerthcet 2023-08-23 19:03:45 +08:00
parent fb785f1f42
commit ab01848134
2 changed files with 4 additions and 3 deletions

View File

@ -969,10 +969,11 @@ func (f *frameworkImpl) RunPreScorePlugins(
nodes []*v1.Node, nodes []*v1.Node,
) (status *framework.Status) { ) (status *framework.Status) {
startTime := time.Now() startTime := time.Now()
skipPlugins := sets.New[string]()
defer func() { defer func() {
state.SkipScorePlugins = skipPlugins
metrics.FrameworkExtensionPointDuration.WithLabelValues(metrics.PreScore, status.Code().String(), f.profileName).Observe(metrics.SinceInSeconds(startTime)) metrics.FrameworkExtensionPointDuration.WithLabelValues(metrics.PreScore, status.Code().String(), f.profileName).Observe(metrics.SinceInSeconds(startTime))
}() }()
skipPlugins := sets.New[string]()
logger := klog.FromContext(ctx) logger := klog.FromContext(ctx)
logger = klog.LoggerWithName(logger, "PreScore") logger = klog.LoggerWithName(logger, "PreScore")
// TODO(knelasevero): Remove duplicated keys from log entry calls // TODO(knelasevero): Remove duplicated keys from log entry calls
@ -991,7 +992,6 @@ func (f *frameworkImpl) RunPreScorePlugins(
return framework.AsStatus(fmt.Errorf("running PreScore plugin %q: %w", pl.Name(), status.AsError())) return framework.AsStatus(fmt.Errorf("running PreScore plugin %q: %w", pl.Name(), status.AsError()))
} }
} }
state.SkipScorePlugins = skipPlugins
return nil return nil
} }

View File

@ -952,7 +952,8 @@ func TestRunPreScorePlugins(t *testing.T) {
inj: injectedResult{PreScoreStatus: int(framework.Error)}, inj: injectedResult{PreScoreStatus: int(framework.Error)},
}, },
}, },
wantStatusCode: framework.Error, wantSkippedPlugins: sets.New("skip"),
wantStatusCode: framework.Error,
}, },
{ {
name: "all PreScore plugins returned skip", name: "all PreScore plugins returned skip",