@@ -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,
@@ -486,6 +486,58 @@ func TestCoreResourceEnqueue(t *testing.T) {
486
486
wantRequeuedPods : sets .New ("pod2" ),
487
487
enableSchedulingQueueHint : []bool {true },
488
488
},
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
+ },
489
541
{
490
542
name : "Pods with PodTopologySpread should be requeued when a Pod with matching label is scheduled" ,
491
543
initialNodes : []* v1.Node {st .MakeNode ().Name ("fake-node" ).Label ("node" , "fake-node" ).Capacity (map [v1.ResourceName ]string {v1 .ResourceCPU : "2" }).Obj ()},
0 commit comments