Merge pull request #124933 from AxeZhan/fix_panic
[Scheduler] Use allNodes when calculating nextStartNodeIndex
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
@@ -2433,6 +2433,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) {
|
||||
|
@@ -480,6 +480,33 @@ func TestSchedulerInformers(t *testing.T) {
|
||||
}),
|
||||
preemptedPodIndexes: map[int]struct{}{2: {}},
|
||||
},
|
||||
{
|
||||
name: "The pod cannot be scheduled when nodeAffinity specifies a non-existent node.",
|
||||
nodes: []*nodeConfig{{name: "node-1", res: defaultNodeRes}},
|
||||
existingPods: []*v1.Pod{},
|
||||
pod: testutils.InitPausePod(&testutils.PausePodConfig{
|
||||
Name: "unschedulable-pod",
|
||||
Namespace: testCtx.NS.Name,
|
||||
Affinity: &v1.Affinity{
|
||||
NodeAffinity: &v1.NodeAffinity{
|
||||
RequiredDuringSchedulingIgnoredDuringExecution: &v1.NodeSelector{
|
||||
NodeSelectorTerms: []v1.NodeSelectorTerm{
|
||||
{
|
||||
MatchFields: []v1.NodeSelectorRequirement{
|
||||
{
|
||||
Key: "metadata.name",
|
||||
Operator: v1.NodeSelectorOpIn,
|
||||
Values: []string{"invalid-node"},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Resources: defaultPodRes,
|
||||
}),
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
|
Reference in New Issue
Block a user