@@ -295,7 +295,7 @@ func TestCoreResourceEnqueue(t *testing.T) {
295
295
wantRequeuedPods : sets .New ("pod1" ),
296
296
},
297
297
{
298
- name : "Pod got resource scaled down requeued to activeQ " ,
298
+ name : "Pod rejected by the NodeResourcesFit plugin is requeued when the Pod is updated to scale down " ,
299
299
initialNodes : []* v1.Node {st .MakeNode ().Name ("fake-node" ).Capacity (map [v1.ResourceName ]string {v1 .ResourceCPU : "2" }).Obj ()},
300
300
pods : []* v1.Pod {
301
301
// - Pod1 requests a large amount of CPU and will be rejected by the NodeResourcesFit plugin.
@@ -311,6 +311,65 @@ func TestCoreResourceEnqueue(t *testing.T) {
311
311
},
312
312
wantRequeuedPods : sets .New ("pod1" ),
313
313
},
314
+ {
315
+ name : "Pod rejected by the NodeResourcesFit plugin is requeued when a Pod is deleted" ,
316
+ initialNodes : []* v1.Node {st .MakeNode ().Name ("fake-node" ).Capacity (map [v1.ResourceName ]string {v1 .ResourceCPU : "2" }).Obj ()},
317
+ initialPods : []* v1.Pod {
318
+ st .MakePod ().Name ("pod1" ).Req (map [v1.ResourceName ]string {v1 .ResourceCPU : "2" }).Container ("image" ).Node ("fake-node" ).Obj (),
319
+ },
320
+ pods : []* v1.Pod {
321
+ // - Pod2 request will be rejected because there are not enough free resources on the Node
322
+ st .MakePod ().Name ("pod2" ).Req (map [v1.ResourceName ]string {v1 .ResourceCPU : "2" }).Container ("image" ).Obj (),
323
+ },
324
+ triggerFn : func (testCtx * testutils.TestContext ) error {
325
+ // Trigger an assigned Pod1 delete event.
326
+ // It makes Pod2 schedulable.
327
+ if err := testCtx .ClientSet .CoreV1 ().Pods (testCtx .NS .Name ).Delete (testCtx .Ctx , "pod1" , metav1.DeleteOptions {GracePeriodSeconds : new (int64 )}); err != nil {
328
+ return fmt .Errorf ("failed to delete pod1: %w" , err )
329
+ }
330
+ return nil
331
+ },
332
+ wantRequeuedPods : sets .New ("pod2" ),
333
+ },
334
+ {
335
+ name : "Pod rejected by the NodeResourcesFit plugin is requeued when a Node is created" ,
336
+ initialNodes : []* v1.Node {st .MakeNode ().Name ("fake-node1" ).Capacity (map [v1.ResourceName ]string {v1 .ResourceCPU : "2" }).Obj ()},
337
+ pods : []* v1.Pod {
338
+ // - Pod1 requests a large amount of CPU and will be rejected by the NodeResourcesFit plugin.
339
+ st .MakePod ().Name ("pod1" ).Req (map [v1.ResourceName ]string {v1 .ResourceCPU : "4" }).Container ("image" ).Obj (),
340
+ // - Pod2 requests a large amount of CPU and will be rejected by the NodeResourcesFit plugin.
341
+ st .MakePod ().Name ("pod2" ).Req (map [v1.ResourceName ]string {v1 .ResourceCPU : "5" }).Container ("image" ).Obj (),
342
+ },
343
+ triggerFn : func (testCtx * testutils.TestContext ) error {
344
+ // Trigger a NodeCreated event.
345
+ // It makes Pod1 schedulable. Pod2 is not requeued because of having too high requests.
346
+ node := st .MakeNode ().Name ("fake-node2" ).Capacity (map [v1.ResourceName ]string {v1 .ResourceCPU : "4" }).Obj ()
347
+ if _ , err := testCtx .ClientSet .CoreV1 ().Nodes ().Create (testCtx .Ctx , node , metav1.CreateOptions {}); err != nil {
348
+ return fmt .Errorf ("failed to create a new node: %w" , err )
349
+ }
350
+ return nil
351
+ },
352
+ wantRequeuedPods : sets .New ("pod1" ),
353
+ },
354
+ {
355
+ name : "Pod rejected by the NodeResourcesFit plugin is requeued when a Node is updated" ,
356
+ initialNodes : []* v1.Node {st .MakeNode ().Name ("fake-node" ).Capacity (map [v1.ResourceName ]string {v1 .ResourceCPU : "2" }).Obj ()},
357
+ pods : []* v1.Pod {
358
+ // - Pod1 requests a large amount of CPU and will be rejected by the NodeResourcesFit plugin.
359
+ st .MakePod ().Name ("pod1" ).Req (map [v1.ResourceName ]string {v1 .ResourceCPU : "4" }).Container ("image" ).Obj (),
360
+ // - Pod2 requests a large amount of CPU and will be rejected by the NodeResourcesFit plugin.
361
+ st .MakePod ().Name ("pod2" ).Req (map [v1.ResourceName ]string {v1 .ResourceCPU : "5" }).Container ("image" ).Obj (),
362
+ },
363
+ triggerFn : func (testCtx * testutils.TestContext ) error {
364
+ // Trigger a NodeUpdate event that increases the CPU capacity of fake-node.
365
+ // It makes Pod1 schedulable. Pod2 is not requeued because of having too high requests.
366
+ if _ , err := testCtx .ClientSet .CoreV1 ().Nodes ().UpdateStatus (testCtx .Ctx , st .MakeNode ().Name ("fake-node" ).Capacity (map [v1.ResourceName ]string {v1 .ResourceCPU : "4" }).Obj (), metav1.UpdateOptions {}); err != nil {
367
+ return fmt .Errorf ("failed to update fake-node: %w" , err )
368
+ }
369
+ return nil
370
+ },
371
+ wantRequeuedPods : sets .New ("pod1" ),
372
+ },
314
373
{
315
374
name : "Updating pod condition doesn't retry scheduling if the Pod was rejected by TaintToleration" ,
316
375
initialNodes : []* v1.Node {st .MakeNode ().Name ("fake-node" ).Taints ([]v1.Taint {{Key : v1 .TaintNodeNotReady , Effect : v1 .TaintEffectNoSchedule }}).Obj ()},
0 commit comments