mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-13 13:55:41 +00:00
Merge pull request #125039 from AxeZhan/automated-cherry-pick-of-#124933-upstream-release-1.30
Automated cherry pick of #124933: base on allNodes when calculating nextStartNodeIndex
This commit is contained in:
commit
be4afb9ef9
@ -502,7 +502,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
|
||||
}
|
||||
|
@ -2416,6 +2416,33 @@ func TestSchedulerSchedulePod(t *testing.T) {
|
||||
wantNodes: sets.New("node1", "node2"),
|
||||
wantEvaluatedNodes: ptr.To[int32](2),
|
||||
},
|
||||
{
|
||||
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 {
|
||||
|
Loading…
Reference in New Issue
Block a user