From f9b650bc98fdaaa78646c85073569dcff1209c6f Mon Sep 17 00:00:00 2001 From: Abdullah Gharaibeh Date: Mon, 23 Mar 2020 10:49:19 -0400 Subject: [PATCH 1/2] Scheduler: execute PreScore right before Score instead of after Filter. --- pkg/scheduler/core/generic_scheduler.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pkg/scheduler/core/generic_scheduler.go b/pkg/scheduler/core/generic_scheduler.go index d0249027f4d..8144c8bdf2e 100644 --- a/pkg/scheduler/core/generic_scheduler.go +++ b/pkg/scheduler/core/generic_scheduler.go @@ -166,13 +166,13 @@ func (g *genericScheduler) Schedule(ctx context.Context, prof *profile.Profile, } // Run "prefilter" plugins. + startPredicateEvalTime := time.Now() preFilterStatus := prof.RunPreFilterPlugins(ctx, state, pod) if !preFilterStatus.IsSuccess() { return result, preFilterStatus.AsError() } trace.Step("Running prefilter plugins done") - startPredicateEvalTime := time.Now() filteredNodes, filteredNodesStatuses, err := g.findNodesThatFitPod(ctx, prof, state, pod) if err != nil { return result, err @@ -187,13 +187,6 @@ func (g *genericScheduler) Schedule(ctx context.Context, prof *profile.Profile, } } - // Run "prescore" plugins. - prescoreStatus := prof.RunPreScorePlugins(ctx, state, pod, filteredNodes) - if !prescoreStatus.IsSuccess() { - return result, prescoreStatus.AsError() - } - trace.Step("Running prescore plugins done") - metrics.DeprecatedSchedulingAlgorithmPredicateEvaluationSecondsDuration.Observe(metrics.SinceInSeconds(startPredicateEvalTime)) metrics.DeprecatedSchedulingDuration.WithLabelValues(metrics.PredicateEvaluation).Observe(metrics.SinceInSeconds(startPredicateEvalTime)) @@ -208,6 +201,13 @@ func (g *genericScheduler) Schedule(ctx context.Context, prof *profile.Profile, }, nil } + // Run "prescore" plugins. + prescoreStatus := prof.RunPreScorePlugins(ctx, state, pod, filteredNodes) + if !prescoreStatus.IsSuccess() { + return result, prescoreStatus.AsError() + } + trace.Step("Running prescore plugins done") + priorityList, err := g.prioritizeNodes(ctx, prof, state, pod, filteredNodes) if err != nil { return result, err From 24fe5a2f726ba203bfe8b07a68961e89f0e3b1f3 Mon Sep 17 00:00:00 2001 From: Abdullah Gharaibeh Date: Mon, 23 Mar 2020 11:08:40 -0400 Subject: [PATCH 2/2] Moved RunPreScorePlugins to inside prioritizeNodes and RunPreFilterPlugins to inside findNodesThatFitPod. --- pkg/scheduler/core/generic_scheduler.go | 26 ++++++++++++------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/pkg/scheduler/core/generic_scheduler.go b/pkg/scheduler/core/generic_scheduler.go index 8144c8bdf2e..9dcd7abe6e7 100644 --- a/pkg/scheduler/core/generic_scheduler.go +++ b/pkg/scheduler/core/generic_scheduler.go @@ -167,12 +167,6 @@ func (g *genericScheduler) Schedule(ctx context.Context, prof *profile.Profile, // Run "prefilter" plugins. startPredicateEvalTime := time.Now() - preFilterStatus := prof.RunPreFilterPlugins(ctx, state, pod) - if !preFilterStatus.IsSuccess() { - return result, preFilterStatus.AsError() - } - trace.Step("Running prefilter plugins done") - filteredNodes, filteredNodesStatuses, err := g.findNodesThatFitPod(ctx, prof, state, pod) if err != nil { return result, err @@ -201,13 +195,6 @@ func (g *genericScheduler) Schedule(ctx context.Context, prof *profile.Profile, }, nil } - // Run "prescore" plugins. - prescoreStatus := prof.RunPreScorePlugins(ctx, state, pod, filteredNodes) - if !prescoreStatus.IsSuccess() { - return result, prescoreStatus.AsError() - } - trace.Step("Running prescore plugins done") - priorityList, err := g.prioritizeNodes(ctx, prof, state, pod, filteredNodes) if err != nil { return result, err @@ -412,6 +399,11 @@ func (g *genericScheduler) numFeasibleNodesToFind(numAllNodes int32) (numNodes i // Filters the nodes to find the ones that fit the pod based on the framework // filter plugins and filter extenders. func (g *genericScheduler) findNodesThatFitPod(ctx context.Context, prof *profile.Profile, state *framework.CycleState, pod *v1.Pod) ([]*v1.Node, framework.NodeToStatusMap, error) { + s := prof.RunPreFilterPlugins(ctx, state, pod) + if !s.IsSuccess() { + return nil, nil, s.AsError() + } + filteredNodesStatuses := make(framework.NodeToStatusMap) filtered, err := g.findNodesThatPassFilters(ctx, prof, state, pod, filteredNodesStatuses) if err != nil { @@ -643,10 +635,16 @@ func (g *genericScheduler) prioritizeNodes( return result, nil } + // Run PreScore plugins. + preScoreStatus := prof.RunPreScorePlugins(ctx, state, pod, nodes) + if !preScoreStatus.IsSuccess() { + return nil, preScoreStatus.AsError() + } + // Run the Score plugins. scoresMap, scoreStatus := prof.RunScorePlugins(ctx, state, pod, nodes) if !scoreStatus.IsSuccess() { - return framework.NodeScoreList{}, scoreStatus.AsError() + return nil, scoreStatus.AsError() } // Summarize all scores.