diff --git a/pkg/scheduler/core/generic_scheduler.go b/pkg/scheduler/core/generic_scheduler.go index bc23e63cfe3..67c50088478 100644 --- a/pkg/scheduler/core/generic_scheduler.go +++ b/pkg/scheduler/core/generic_scheduler.go @@ -203,7 +203,7 @@ func (g *genericScheduler) Schedule(ctx context.Context, state *framework.CycleS } // Run "prescore" plugins. - prescoreStatus := g.framework.RunPreScorePlugins(ctx, state, pod, filteredNodes, filteredNodesStatuses) + prescoreStatus := g.framework.RunPreScorePlugins(ctx, state, pod, filteredNodes) if !prescoreStatus.IsSuccess() { return result, prescoreStatus.AsError() } diff --git a/pkg/scheduler/core/generic_scheduler_test.go b/pkg/scheduler/core/generic_scheduler_test.go index 593c2ed3e2d..cdc636aee49 100644 --- a/pkg/scheduler/core/generic_scheduler_test.go +++ b/pkg/scheduler/core/generic_scheduler_test.go @@ -1144,11 +1144,11 @@ func TestZeroRequest(t *testing.T) { ctx := context.Background() state := framework.NewCycleState() - _, filteredNodesStatuses, err := scheduler.findNodesThatFitPod(ctx, state, test.pod) + _, _, err = scheduler.findNodesThatFitPod(ctx, state, test.pod) if err != nil { t.Fatalf("error filtering nodes: %+v", err) } - scheduler.framework.RunPreScorePlugins(ctx, state, test.pod, test.nodes, filteredNodesStatuses) + scheduler.framework.RunPreScorePlugins(ctx, state, test.pod, test.nodes) list, err := scheduler.prioritizeNodes( ctx, state, diff --git a/pkg/scheduler/framework/plugins/defaultpodtopologyspread/default_pod_topology_spread.go b/pkg/scheduler/framework/plugins/defaultpodtopologyspread/default_pod_topology_spread.go index dd78ae051b7..1de9363cccd 100644 --- a/pkg/scheduler/framework/plugins/defaultpodtopologyspread/default_pod_topology_spread.go +++ b/pkg/scheduler/framework/plugins/defaultpodtopologyspread/default_pod_topology_spread.go @@ -19,6 +19,7 @@ package defaultpodtopologyspread import ( "context" "fmt" + "k8s.io/klog" v1 "k8s.io/api/core/v1" @@ -178,7 +179,7 @@ func (pl *DefaultPodTopologySpread) ScoreExtensions() framework.ScoreExtensions } // PreScore builds and writes cycle state used by Score and NormalizeScore. -func (pl *DefaultPodTopologySpread) PreScore(ctx context.Context, cycleState *framework.CycleState, pod *v1.Pod, nodes []*v1.Node, _ framework.NodeToStatusMap) *framework.Status { +func (pl *DefaultPodTopologySpread) PreScore(ctx context.Context, cycleState *framework.CycleState, pod *v1.Pod, nodes []*v1.Node) *framework.Status { var selector labels.Selector informerFactory := pl.handle.SharedInformerFactory() selector = getSelector( diff --git a/pkg/scheduler/framework/plugins/defaultpodtopologyspread/default_pod_topology_spread_perf_test.go b/pkg/scheduler/framework/plugins/defaultpodtopologyspread/default_pod_topology_spread_perf_test.go index 36ff7fe1c7f..9f87b27ccdf 100644 --- a/pkg/scheduler/framework/plugins/defaultpodtopologyspread/default_pod_topology_spread_perf_test.go +++ b/pkg/scheduler/framework/plugins/defaultpodtopologyspread/default_pod_topology_spread_perf_test.go @@ -73,7 +73,7 @@ func BenchmarkTestSelectorSpreadPriority(b *testing.B) { for i := 0; i < b.N; i++ { state := framework.NewCycleState() - status := plugin.PreScore(ctx, state, pod, allNodes, nil) + status := plugin.PreScore(ctx, state, pod, allNodes) if !status.IsSuccess() { b.Fatalf("unexpected error: %v", status) } diff --git a/pkg/scheduler/framework/plugins/defaultpodtopologyspread/default_pod_topology_spread_test.go b/pkg/scheduler/framework/plugins/defaultpodtopologyspread/default_pod_topology_spread_test.go index 236fec6bb24..2ea075b02cf 100644 --- a/pkg/scheduler/framework/plugins/defaultpodtopologyspread/default_pod_topology_spread_test.go +++ b/pkg/scheduler/framework/plugins/defaultpodtopologyspread/default_pod_topology_spread_test.go @@ -386,7 +386,7 @@ func TestDefaultPodTopologySpreadScore(t *testing.T) { handle: fh, } - status := plugin.PreScore(ctx, state, test.pod, nodes, nil) + status := plugin.PreScore(ctx, state, test.pod, nodes) if !status.IsSuccess() { t.Fatalf("unexpected error: %v", status) } @@ -638,7 +638,7 @@ func TestZoneSelectorSpreadPriority(t *testing.T) { } state := framework.NewCycleState() - status := plugin.PreScore(ctx, state, test.pod, nodes, nil) + status := plugin.PreScore(ctx, state, test.pod, nodes) if !status.IsSuccess() { t.Fatalf("unexpected error: %v", status) } diff --git a/pkg/scheduler/framework/plugins/interpodaffinity/scoring.go b/pkg/scheduler/framework/plugins/interpodaffinity/scoring.go index 34897d669af..cc07d49f6b5 100644 --- a/pkg/scheduler/framework/plugins/interpodaffinity/scoring.go +++ b/pkg/scheduler/framework/plugins/interpodaffinity/scoring.go @@ -20,7 +20,7 @@ import ( "context" "fmt" - "k8s.io/api/core/v1" + v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/util/workqueue" "k8s.io/klog" @@ -172,7 +172,6 @@ func (pl *InterPodAffinity) PreScore( cycleState *framework.CycleState, pod *v1.Pod, nodes []*v1.Node, - _ framework.NodeToStatusMap, ) *framework.Status { if len(nodes) == 0 { // No nodes to score. diff --git a/pkg/scheduler/framework/plugins/interpodaffinity/scoring_test.go b/pkg/scheduler/framework/plugins/interpodaffinity/scoring_test.go index 2c170e315e0..6f4eb905fef 100644 --- a/pkg/scheduler/framework/plugins/interpodaffinity/scoring_test.go +++ b/pkg/scheduler/framework/plugins/interpodaffinity/scoring_test.go @@ -523,7 +523,7 @@ func TestPreferredAffinity(t *testing.T) { hardPodAffinityWeight: 1, } - status := p.PreScore(context.Background(), state, test.pod, test.nodes, nil) + status := p.PreScore(context.Background(), state, test.pod, test.nodes) if !status.IsSuccess() { t.Errorf("unexpected error: %v", status) } @@ -631,7 +631,7 @@ func TestPreferredAffinityWithHardPodAffinitySymmetricWeight(t *testing.T) { if err != nil { t.Fatal(err) } - status := p.(framework.PreScorePlugin).PreScore(context.Background(), state, test.pod, test.nodes, nil) + status := p.(framework.PreScorePlugin).PreScore(context.Background(), state, test.pod, test.nodes) if !status.IsSuccess() { t.Errorf("unexpected error: %v", status) } diff --git a/pkg/scheduler/framework/plugins/noderesources/resource_limits.go b/pkg/scheduler/framework/plugins/noderesources/resource_limits.go index abe89697001..9919d6c5e38 100644 --- a/pkg/scheduler/framework/plugins/noderesources/resource_limits.go +++ b/pkg/scheduler/framework/plugins/noderesources/resource_limits.go @@ -65,7 +65,6 @@ func (rl *ResourceLimits) PreScore( cycleState *framework.CycleState, pod *v1.Pod, nodes []*v1.Node, - _ framework.NodeToStatusMap, ) *framework.Status { if len(nodes) == 0 { // No nodes to score. diff --git a/pkg/scheduler/framework/plugins/noderesources/resource_limits_test.go b/pkg/scheduler/framework/plugins/noderesources/resource_limits_test.go index fe35bc46a2f..e48b6b9cc53 100644 --- a/pkg/scheduler/framework/plugins/noderesources/resource_limits_test.go +++ b/pkg/scheduler/framework/plugins/noderesources/resource_limits_test.go @@ -152,7 +152,7 @@ func TestResourceLimits(t *testing.T) { for i := range test.nodes { state := framework.NewCycleState() if !test.skipPreScore { - status := p.PreScore(context.Background(), state, test.pod, test.nodes, nil) + status := p.PreScore(context.Background(), state, test.pod, test.nodes) if !status.IsSuccess() { t.Errorf("unexpected error: %v", status) } diff --git a/pkg/scheduler/framework/plugins/podtopologyspread/scoring.go b/pkg/scheduler/framework/plugins/podtopologyspread/scoring.go index c87de4a384c..6b928093292 100644 --- a/pkg/scheduler/framework/plugins/podtopologyspread/scoring.go +++ b/pkg/scheduler/framework/plugins/podtopologyspread/scoring.go @@ -84,7 +84,6 @@ func (pl *PodTopologySpread) PreScore( cycleState *framework.CycleState, pod *v1.Pod, filteredNodes []*v1.Node, - _ framework.NodeToStatusMap, ) *framework.Status { allNodes, err := pl.sharedLister.NodeInfos().List() if err != nil { diff --git a/pkg/scheduler/framework/plugins/podtopologyspread/scoring_test.go b/pkg/scheduler/framework/plugins/podtopologyspread/scoring_test.go index 73604644cff..ba8c21fe941 100644 --- a/pkg/scheduler/framework/plugins/podtopologyspread/scoring_test.go +++ b/pkg/scheduler/framework/plugins/podtopologyspread/scoring_test.go @@ -476,7 +476,7 @@ func TestPodTopologySpreadScore(t *testing.T) { snapshot := cache.NewSnapshot(tt.existingPods, allNodes) p := &PodTopologySpread{sharedLister: snapshot} - status := p.PreScore(context.Background(), state, tt.pod, tt.nodes, nil) + status := p.PreScore(context.Background(), state, tt.pod, tt.nodes) if !status.IsSuccess() { t.Errorf("unexpected error: %v", status) } @@ -546,7 +546,7 @@ func BenchmarkTestPodTopologySpreadScore(b *testing.B) { snapshot := cache.NewSnapshot(existingPods, allNodes) p := &PodTopologySpread{sharedLister: snapshot} - status := p.PreScore(context.Background(), state, tt.pod, filteredNodes, nil) + status := p.PreScore(context.Background(), state, tt.pod, filteredNodes) if !status.IsSuccess() { b.Fatalf("unexpected error: %v", status) } @@ -605,7 +605,7 @@ func BenchmarkTestDefaultEvenPodsSpreadPriority(b *testing.B) { snapshot := cache.NewSnapshot(existingPods, allNodes) p := &PodTopologySpread{sharedLister: snapshot} - status := p.PreScore(context.Background(), state, pod, filteredNodes, nil) + status := p.PreScore(context.Background(), state, pod, filteredNodes) if !status.IsSuccess() { b.Fatalf("unexpected error: %v", status) } diff --git a/pkg/scheduler/framework/plugins/tainttoleration/taint_toleration.go b/pkg/scheduler/framework/plugins/tainttoleration/taint_toleration.go index 8d344912e97..75a7f3adaa1 100644 --- a/pkg/scheduler/framework/plugins/tainttoleration/taint_toleration.go +++ b/pkg/scheduler/framework/plugins/tainttoleration/taint_toleration.go @@ -100,7 +100,7 @@ func getAllTolerationPreferNoSchedule(tolerations []v1.Toleration) (tolerationLi } // PreScore builds and writes cycle state used by Score and NormalizeScore. -func (pl *TaintToleration) PreScore(ctx context.Context, cycleState *framework.CycleState, pod *v1.Pod, nodes []*v1.Node, _ framework.NodeToStatusMap) *framework.Status { +func (pl *TaintToleration) PreScore(ctx context.Context, cycleState *framework.CycleState, pod *v1.Pod, nodes []*v1.Node) *framework.Status { if len(nodes) == 0 { return nil } diff --git a/pkg/scheduler/framework/plugins/tainttoleration/taint_toleration_test.go b/pkg/scheduler/framework/plugins/tainttoleration/taint_toleration_test.go index ec1bfa6b279..c902c6562bc 100644 --- a/pkg/scheduler/framework/plugins/tainttoleration/taint_toleration_test.go +++ b/pkg/scheduler/framework/plugins/tainttoleration/taint_toleration_test.go @@ -233,7 +233,7 @@ func TestTaintTolerationScore(t *testing.T) { fh, _ := framework.NewFramework(nil, nil, nil, framework.WithSnapshotSharedLister(snapshot)) p, _ := New(nil, fh) - status := p.(framework.PreScorePlugin).PreScore(context.Background(), state, test.pod, test.nodes, nil) + status := p.(framework.PreScorePlugin).PreScore(context.Background(), state, test.pod, test.nodes) if !status.IsSuccess() { t.Errorf("unexpected error: %v", status) } diff --git a/pkg/scheduler/framework/v1alpha1/framework.go b/pkg/scheduler/framework/v1alpha1/framework.go index 937369605f4..848893ffbdd 100644 --- a/pkg/scheduler/framework/v1alpha1/framework.go +++ b/pkg/scheduler/framework/v1alpha1/framework.go @@ -22,7 +22,7 @@ import ( "reflect" "time" - "k8s.io/api/core/v1" + v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/sets" @@ -462,21 +462,19 @@ func (f *framework) runFilterPlugin(ctx context.Context, pl FilterPlugin, state } // RunPreScorePlugins runs the set of configured pre-score plugins. If any -// of these plugins returns any status other than "Success", the given pod is -// rejected. The filteredNodeStatuses is the set of filtered nodes and their statuses. +// of these plugins returns any status other than "Success", the given pod is rejected. func (f *framework) RunPreScorePlugins( ctx context.Context, state *CycleState, pod *v1.Pod, nodes []*v1.Node, - filteredNodesStatuses NodeToStatusMap, ) (status *Status) { startTime := time.Now() defer func() { metrics.FrameworkExtensionPointDuration.WithLabelValues(preScore, status.Code().String()).Observe(metrics.SinceInSeconds(startTime)) }() for _, pl := range f.preScorePlugins { - status = f.runPreScorePlugin(ctx, pl, state, pod, nodes, filteredNodesStatuses) + status = f.runPreScorePlugin(ctx, pl, state, pod, nodes) if !status.IsSuccess() { msg := fmt.Sprintf("error while running %q prescore plugin for pod %q: %v", pl.Name(), pod.Name, status.Message()) klog.Error(msg) @@ -487,12 +485,12 @@ func (f *framework) RunPreScorePlugins( return nil } -func (f *framework) runPreScorePlugin(ctx context.Context, pl PreScorePlugin, state *CycleState, pod *v1.Pod, nodes []*v1.Node, filteredNodesStatuses NodeToStatusMap) *Status { +func (f *framework) runPreScorePlugin(ctx context.Context, pl PreScorePlugin, state *CycleState, pod *v1.Pod, nodes []*v1.Node) *Status { if !state.ShouldRecordPluginMetrics() { - return pl.PreScore(ctx, state, pod, nodes, filteredNodesStatuses) + return pl.PreScore(ctx, state, pod, nodes) } startTime := time.Now() - status := pl.PreScore(ctx, state, pod, nodes, filteredNodesStatuses) + status := pl.PreScore(ctx, state, pod, nodes) f.metricsRecorder.observePluginDurationAsync(preScore, pl.Name(), status, metrics.SinceInSeconds(startTime)) return status } diff --git a/pkg/scheduler/framework/v1alpha1/framework_test.go b/pkg/scheduler/framework/v1alpha1/framework_test.go index dca0f986e36..76990a232d7 100644 --- a/pkg/scheduler/framework/v1alpha1/framework_test.go +++ b/pkg/scheduler/framework/v1alpha1/framework_test.go @@ -169,7 +169,7 @@ func (pl *TestPlugin) Filter(ctx context.Context, state *CycleState, pod *v1.Pod return NewStatus(Code(pl.inj.FilterStatus), "injected filter status") } -func (pl *TestPlugin) PreScore(ctx context.Context, state *CycleState, pod *v1.Pod, nodes []*v1.Node, filteredNodesStatuses NodeToStatusMap) *Status { +func (pl *TestPlugin) PreScore(ctx context.Context, state *CycleState, pod *v1.Pod, nodes []*v1.Node) *Status { return NewStatus(Code(pl.inj.PreScoreStatus), "injected status") } @@ -1329,7 +1329,7 @@ func TestRecordingMetrics(t *testing.T) { }, { name: "PreScore - Success", - action: func(f Framework) { f.RunPreScorePlugins(context.Background(), state, pod, nil, nil) }, + action: func(f Framework) { f.RunPreScorePlugins(context.Background(), state, pod, nil) }, wantExtensionPoint: "PreScore", wantStatus: Success, }, @@ -1385,7 +1385,7 @@ func TestRecordingMetrics(t *testing.T) { }, { name: "PreScore - Error", - action: func(f Framework) { f.RunPreScorePlugins(context.Background(), state, pod, nil, nil) }, + action: func(f Framework) { f.RunPreScorePlugins(context.Background(), state, pod, nil) }, inject: injectedResult{PreScoreStatus: int(Error)}, wantExtensionPoint: "PreScore", wantStatus: Error, diff --git a/pkg/scheduler/framework/v1alpha1/interface.go b/pkg/scheduler/framework/v1alpha1/interface.go index d606033fda0..e7a2c05cceb 100644 --- a/pkg/scheduler/framework/v1alpha1/interface.go +++ b/pkg/scheduler/framework/v1alpha1/interface.go @@ -310,9 +310,8 @@ type PreScorePlugin interface { Plugin // PreScore is called by the scheduling framework after a list of nodes // passed the filtering phase. All prescore plugins must return success or - // the pod will be rejected. The filteredNodesStatuses is the set of filtered nodes - // and their filter status. - PreScore(ctx context.Context, state *CycleState, pod *v1.Pod, nodes []*v1.Node, filteredNodesStatuses NodeToStatusMap) *Status + // the pod will be rejected + PreScore(ctx context.Context, state *CycleState, pod *v1.Pod, nodes []*v1.Node) *Status } // ScoreExtensions is an interface for Score extended functionality. @@ -439,9 +438,8 @@ type Framework interface { RunPreFilterExtensionRemovePod(ctx context.Context, state *CycleState, podToSchedule *v1.Pod, podToAdd *v1.Pod, nodeInfo *schedulernodeinfo.NodeInfo) *Status // RunPreScorePlugins runs the set of configured pre-score plugins. If any - // of these plugins returns any status other than "Success", the given pod is - // rejected. The filteredNodeStatuses is the set of filtered nodes and their statuses. - RunPreScorePlugins(ctx context.Context, state *CycleState, pod *v1.Pod, nodes []*v1.Node, filteredNodesStatuses NodeToStatusMap) *Status + // of these plugins returns any status other than "Success", the given pod is rejected. + RunPreScorePlugins(ctx context.Context, state *CycleState, pod *v1.Pod, nodes []*v1.Node) *Status // RunScorePlugins runs the set of configured scoring plugins. It returns a map that // stores for each scoring plugin name the corresponding NodeScoreList(s). diff --git a/test/integration/scheduler/framework_test.go b/test/integration/scheduler/framework_test.go index e109bb90efc..c18df3d3299 100644 --- a/test/integration/scheduler/framework_test.go +++ b/test/integration/scheduler/framework_test.go @@ -247,7 +247,7 @@ func (*PreScorePlugin) Name() string { } // PreScore is a test function. -func (pfp *PreScorePlugin) PreScore(ctx context.Context, _ *framework.CycleState, pod *v1.Pod, _ []*v1.Node, _ framework.NodeToStatusMap) *framework.Status { +func (pfp *PreScorePlugin) PreScore(ctx context.Context, _ *framework.CycleState, pod *v1.Pod, _ []*v1.Node) *framework.Status { pfp.numPreScoreCalled++ if pfp.failPreScore { return framework.NewStatus(framework.Error, fmt.Sprintf("injecting failure for pod %v", pod.Name))