diff --git a/pkg/scheduler/schedule_one.go b/pkg/scheduler/schedule_one.go index 67aaac59da0..74b1ed2b2fa 100644 --- a/pkg/scheduler/schedule_one.go +++ b/pkg/scheduler/schedule_one.go @@ -500,7 +500,7 @@ func (sched *Scheduler) findNodesThatFitPod(ctx context.Context, fwk framework.F // always try to update the sched.nextStartNodeIndex regardless of whether an error has occurred // this is helpful to make sure that all the nodes have a chance to be searched processedNodes := len(feasibleNodes) + len(diagnosis.NodeToStatusMap) - sched.nextStartNodeIndex = (sched.nextStartNodeIndex + processedNodes) % len(nodes) + sched.nextStartNodeIndex = (sched.nextStartNodeIndex + processedNodes) % len(allNodes) if err != nil { return nil, diagnosis, err } diff --git a/pkg/scheduler/schedule_one_test.go b/pkg/scheduler/schedule_one_test.go index 9b487b1da10..83b42556410 100644 --- a/pkg/scheduler/schedule_one_test.go +++ b/pkg/scheduler/schedule_one_test.go @@ -2431,6 +2431,33 @@ func TestSchedulerSchedulePod(t *testing.T) { // since this case has no score plugin, we'll only try to find one node in Filter stage wantEvaluatedNodes: ptr.To[int32](1), }, + { + name: "test prefilter plugin returned an invalid node", + registerPlugins: []tf.RegisterPluginFunc{ + tf.RegisterQueueSortPlugin(queuesort.Name, queuesort.New), + tf.RegisterPreFilterPlugin( + "FakePreFilter", + tf.NewFakePreFilterPlugin("FakePreFilter", &framework.PreFilterResult{ + NodeNames: sets.New("invalid-node"), + }, nil), + ), + tf.RegisterFilterPlugin("TrueFilter", tf.NewTrueFilterPlugin), + tf.RegisterBindPlugin(defaultbinder.Name, defaultbinder.New), + }, + nodes: []string{"1", "2"}, + pod: st.MakePod().Name("test-prefilter").UID("test-prefilter").Obj(), + wantNodes: nil, + wErr: &framework.FitError{ + Pod: st.MakePod().Name("test-prefilter").UID("test-prefilter").Obj(), + NumAllNodes: 2, + Diagnosis: framework.Diagnosis{ + NodeToStatusMap: framework.NodeToStatusMap{ + "1": framework.NewStatus(framework.UnschedulableAndUnresolvable, "node is filtered out by the prefilter result"), + "2": framework.NewStatus(framework.UnschedulableAndUnresolvable, "node is filtered out by the prefilter result"), + }, + }, + }, + }, } for _, test := range tests { t.Run(test.name, func(t *testing.T) {