Skip to content

Commit aeafb4d

Browse files
committed
Add integration test for NodeUnschedulable in requeueing scenarios
1 parent dddffaa commit aeafb4d

File tree

1 file changed

+53
-1
lines changed

1 file changed

+53
-1
lines changed

test/integration/scheduler/queue_test.go

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ func TestSchedulingGates(t *testing.T) {
188188
func TestCoreResourceEnqueue(t *testing.T) {
189189
tests := []struct {
190190
name string
191-
// initialNode is the Node to be created at first.
191+
// initialNodes is the list of Nodes to be created at first.
192192
initialNodes []*v1.Node
193193
// initialPods is the list of Pods to be created at first if it's not empty.
194194
// Note that the scheduler won't schedule those Pods,
@@ -486,6 +486,58 @@ func TestCoreResourceEnqueue(t *testing.T) {
486486
wantRequeuedPods: sets.New("pod2"),
487487
enableSchedulingQueueHint: []bool{true},
488488
},
489+
{
490+
name: "Pod rejected by the NodeUnschedulable plugin is requeued when the node is turned to ready",
491+
initialNodes: []*v1.Node{st.MakeNode().Name("fake-node").Unschedulable(true).Obj()},
492+
pods: []*v1.Pod{
493+
st.MakePod().Name("pod1").Container("image").Obj(),
494+
},
495+
triggerFn: func(testCtx *testutils.TestContext) error {
496+
// Trigger a NodeUpdate event to change the Node to ready.
497+
// It makes Pod1 schedulable.
498+
if _, err := testCtx.ClientSet.CoreV1().Nodes().Update(testCtx.Ctx, st.MakeNode().Name("fake-node").Unschedulable(false).Obj(), metav1.UpdateOptions{}); err != nil {
499+
return fmt.Errorf("failed to update the node: %w", err)
500+
}
501+
return nil
502+
},
503+
wantRequeuedPods: sets.New("pod1"),
504+
},
505+
{
506+
name: "Pod rejected by the NodeUnschedulable plugin is requeued when a new node is created",
507+
initialNodes: []*v1.Node{st.MakeNode().Name("fake-node1").Unschedulable(true).Obj()},
508+
pods: []*v1.Pod{
509+
st.MakePod().Name("pod1").Container("image").Obj(),
510+
},
511+
triggerFn: func(testCtx *testutils.TestContext) error {
512+
// Trigger a NodeCreated event.
513+
// It makes Pod1 schedulable.
514+
node := st.MakeNode().Name("fake-node2").Obj()
515+
if _, err := testCtx.ClientSet.CoreV1().Nodes().Create(testCtx.Ctx, node, metav1.CreateOptions{}); err != nil {
516+
return fmt.Errorf("failed to create a new node: %w", err)
517+
}
518+
return nil
519+
},
520+
wantRequeuedPods: sets.New("pod1"),
521+
},
522+
{
523+
name: "Pod rejected by the NodeUnschedulable plugin isn't requeued when another unschedulable node is created",
524+
initialNodes: []*v1.Node{st.MakeNode().Name("fake-node1").Unschedulable(true).Obj()},
525+
pods: []*v1.Pod{
526+
st.MakePod().Name("pod1").Container("image").Obj(),
527+
},
528+
triggerFn: func(testCtx *testutils.TestContext) error {
529+
// Trigger a NodeCreated event, but with unschedulable node, which wouldn't make Pod1 schedulable.
530+
node := st.MakeNode().Name("fake-node2").Unschedulable(true).Obj()
531+
if _, err := testCtx.ClientSet.CoreV1().Nodes().Create(testCtx.Ctx, node, metav1.CreateOptions{}); err != nil {
532+
return fmt.Errorf("failed to create a new node: %w", err)
533+
}
534+
return nil
535+
},
536+
wantRequeuedPods: sets.Set[string]{},
537+
// This test case is valid only when QHint is enabled
538+
// because QHint filters out a node creation made in triggerFn.
539+
enableSchedulingQueueHint: []bool{true},
540+
},
489541
{
490542
name: "Pods with PodTopologySpread should be requeued when a Pod with matching label is scheduled",
491543
initialNodes: []*v1.Node{st.MakeNode().Name("fake-node").Label("node", "fake-node").Capacity(map[v1.ResourceName]string{v1.ResourceCPU: "2"}).Obj()},

0 commit comments

Comments
 (0)