@@ -188,7 +188,7 @@ func TestSchedulingGates(t *testing.T) {
188
188
func TestCoreResourceEnqueue (t * testing.T ) {
189
189
tests := []struct {
190
190
name string
191
- // initialNode is the Node to be created at first.
191
+ // initialNodes is the list of Nodes to be created at first.
192
192
initialNodes []* v1.Node
193
193
// initialPods is the list of Pods to be created at first if it's not empty.
194
194
// Note that the scheduler won't schedule those Pods,
@@ -545,6 +545,58 @@ func TestCoreResourceEnqueue(t *testing.T) {
545
545
wantRequeuedPods : sets .New ("pod2" ),
546
546
enableSchedulingQueueHint : []bool {true },
547
547
},
548
+ {
549
+ name : "Pod rejected by the NodeUnschedulable plugin is requeued when the node is turned to ready" ,
550
+ initialNodes : []* v1.Node {st .MakeNode ().Name ("fake-node" ).Unschedulable (true ).Obj ()},
551
+ pods : []* v1.Pod {
552
+ st .MakePod ().Name ("pod1" ).Container ("image" ).Obj (),
553
+ },
554
+ triggerFn : func (testCtx * testutils.TestContext ) error {
555
+ // Trigger a NodeUpdate event to change the Node to ready.
556
+ // It makes Pod1 schedulable.
557
+ if _ , err := testCtx .ClientSet .CoreV1 ().Nodes ().Update (testCtx .Ctx , st .MakeNode ().Name ("fake-node" ).Unschedulable (false ).Obj (), metav1.UpdateOptions {}); err != nil {
558
+ return fmt .Errorf ("failed to update the node: %w" , err )
559
+ }
560
+ return nil
561
+ },
562
+ wantRequeuedPods : sets .New ("pod1" ),
563
+ },
564
+ {
565
+ name : "Pod rejected by the NodeUnschedulable plugin is requeued when a new node is created" ,
566
+ initialNodes : []* v1.Node {st .MakeNode ().Name ("fake-node1" ).Unschedulable (true ).Obj ()},
567
+ pods : []* v1.Pod {
568
+ st .MakePod ().Name ("pod1" ).Container ("image" ).Obj (),
569
+ },
570
+ triggerFn : func (testCtx * testutils.TestContext ) error {
571
+ // Trigger a NodeCreated event.
572
+ // It makes Pod1 schedulable.
573
+ node := st .MakeNode ().Name ("fake-node2" ).Obj ()
574
+ if _ , err := testCtx .ClientSet .CoreV1 ().Nodes ().Create (testCtx .Ctx , node , metav1.CreateOptions {}); err != nil {
575
+ return fmt .Errorf ("failed to create a new node: %w" , err )
576
+ }
577
+ return nil
578
+ },
579
+ wantRequeuedPods : sets .New ("pod1" ),
580
+ },
581
+ {
582
+ name : "Pod rejected by the NodeUnschedulable plugin isn't requeued when another unschedulable node is created" ,
583
+ initialNodes : []* v1.Node {st .MakeNode ().Name ("fake-node1" ).Unschedulable (true ).Obj ()},
584
+ pods : []* v1.Pod {
585
+ st .MakePod ().Name ("pod1" ).Container ("image" ).Obj (),
586
+ },
587
+ triggerFn : func (testCtx * testutils.TestContext ) error {
588
+ // Trigger a NodeCreated event, but with unschedulable node, which wouldn't make Pod1 schedulable.
589
+ node := st .MakeNode ().Name ("fake-node2" ).Unschedulable (true ).Obj ()
590
+ if _ , err := testCtx .ClientSet .CoreV1 ().Nodes ().Create (testCtx .Ctx , node , metav1.CreateOptions {}); err != nil {
591
+ return fmt .Errorf ("failed to create a new node: %w" , err )
592
+ }
593
+ return nil
594
+ },
595
+ wantRequeuedPods : sets.Set [string ]{},
596
+ // This test case is valid only when QHint is enabled
597
+ // because QHint filters out a node creation made in triggerFn.
598
+ enableSchedulingQueueHint : []bool {true },
599
+ },
548
600
{
549
601
name : "Pods with PodTopologySpread should be requeued when a Pod with matching label is scheduled" ,
550
602
initialNodes : []* v1.Node {st .MakeNode ().Name ("fake-node" ).Label ("node" , "fake-node" ).Capacity (map [v1.ResourceName ]string {v1 .ResourceCPU : "2" }).Obj ()},
0 commit comments