@@ -1470,6 +1470,40 @@ func TestSelectNodesForPreemption(t *testing.T) {
1470
1470
expected : map [string ]victims {"machine1" : {pods : sets .NewString ("a" , "b" ), numPDBViolations : 1 }},
1471
1471
expectedNumFilterCalled : 3 ,
1472
1472
},
1473
+ {
1474
+ name : "preemption with violation of the pdb with pod whose eviction was processed, the victim doesn't belong to DisruptedPods" ,
1475
+ registerPlugins : []st.RegisterPluginFunc {
1476
+ st .RegisterQueueSortPlugin (queuesort .Name , queuesort .New ),
1477
+ st .RegisterPluginAsExtensions (noderesources .FitName , noderesources .NewFit , "Filter" , "PreFilter" ),
1478
+ st .RegisterBindPlugin (defaultbinder .Name , defaultbinder .New ),
1479
+ },
1480
+ nodes : []string {"machine1" },
1481
+ pod : & v1.Pod {ObjectMeta : metav1.ObjectMeta {Name : "pod1" , UID : types .UID ("pod1" )}, Spec : v1.PodSpec {Containers : veryLargeContainers , Priority : & highPriority }},
1482
+ pods : []* v1.Pod {
1483
+ {ObjectMeta : metav1.ObjectMeta {Name : "a" , UID : types .UID ("a" ), Labels : map [string ]string {"app" : "foo" }}, Spec : v1.PodSpec {Containers : mediumContainers , Priority : & midPriority , NodeName : "machine1" }},
1484
+ {ObjectMeta : metav1.ObjectMeta {Name : "b" , UID : types .UID ("b" ), Labels : map [string ]string {"app" : "foo" }}, Spec : v1.PodSpec {Containers : mediumContainers , Priority : & midPriority , NodeName : "machine1" }}},
1485
+ pdbs : []* policy.PodDisruptionBudget {
1486
+ {Spec : policy.PodDisruptionBudgetSpec {Selector : & metav1.LabelSelector {MatchLabels : map [string ]string {"app" : "foo" }}}, Status : policy.PodDisruptionBudgetStatus {DisruptionsAllowed : 1 , DisruptedPods : map [string ]metav1.Time {"c" : {Time : time .Now ()}}}}},
1487
+ expected : map [string ]victims {"machine1" : {pods : sets .NewString ("a" , "b" ), numPDBViolations : 1 }},
1488
+ expectedNumFilterCalled : 3 ,
1489
+ },
1490
+ {
1491
+ name : "preemption with violation of the pdb with pod whose eviction was processed, the victim belongs to DisruptedPods" ,
1492
+ registerPlugins : []st.RegisterPluginFunc {
1493
+ st .RegisterQueueSortPlugin (queuesort .Name , queuesort .New ),
1494
+ st .RegisterPluginAsExtensions (noderesources .FitName , noderesources .NewFit , "Filter" , "PreFilter" ),
1495
+ st .RegisterBindPlugin (defaultbinder .Name , defaultbinder .New ),
1496
+ },
1497
+ nodes : []string {"machine1" },
1498
+ pod : & v1.Pod {ObjectMeta : metav1.ObjectMeta {Name : "pod1" , UID : types .UID ("pod1" )}, Spec : v1.PodSpec {Containers : veryLargeContainers , Priority : & highPriority }},
1499
+ pods : []* v1.Pod {
1500
+ {ObjectMeta : metav1.ObjectMeta {Name : "a" , UID : types .UID ("a" ), Labels : map [string ]string {"app" : "foo" }}, Spec : v1.PodSpec {Containers : mediumContainers , Priority : & midPriority , NodeName : "machine1" }},
1501
+ {ObjectMeta : metav1.ObjectMeta {Name : "b" , UID : types .UID ("b" ), Labels : map [string ]string {"app" : "foo" }}, Spec : v1.PodSpec {Containers : mediumContainers , Priority : & midPriority , NodeName : "machine1" }}},
1502
+ pdbs : []* policy.PodDisruptionBudget {
1503
+ {Spec : policy.PodDisruptionBudgetSpec {Selector : & metav1.LabelSelector {MatchLabels : map [string ]string {"app" : "foo" }}}, Status : policy.PodDisruptionBudgetStatus {DisruptionsAllowed : 1 , DisruptedPods : map [string ]metav1.Time {"a" : {Time : time .Now ()}}}}},
1504
+ expected : map [string ]victims {"machine1" : {pods : sets .NewString ("a" , "b" ), numPDBViolations : 0 }},
1505
+ expectedNumFilterCalled : 3 ,
1506
+ },
1473
1507
}
1474
1508
labelKeys := []string {"hostname" , "zone" , "region" }
1475
1509
for _ , test := range tests {
0 commit comments