@@ -1561,6 +1561,40 @@ func TestSelectNodesForPreemption(t *testing.T) {
1561
1561
expected : map [string ]victims {"machine1" : {pods : sets .NewString ("a" , "b" ), numPDBViolations : 1 }},
1562
1562
expectedNumFilterCalled : 3 ,
1563
1563
},
1564
+ {
1565
+ name : "preemption with violation of the pdb with pod whose eviction was processed, the victim doesn't belong to DisruptedPods" ,
1566
+ registerPlugins : []st.RegisterPluginFunc {
1567
+ st .RegisterQueueSortPlugin (queuesort .Name , queuesort .New ),
1568
+ st .RegisterPluginAsExtensions (noderesources .FitName , noderesources .NewFit , "Filter" , "PreFilter" ),
1569
+ st .RegisterBindPlugin (defaultbinder .Name , defaultbinder .New ),
1570
+ },
1571
+ nodes : []string {"machine1" },
1572
+ pod : & v1.Pod {ObjectMeta : metav1.ObjectMeta {Name : "pod1" , UID : types .UID ("pod1" )}, Spec : v1.PodSpec {Containers : veryLargeContainers , Priority : & highPriority }},
1573
+ pods : []* v1.Pod {
1574
+ {ObjectMeta : metav1.ObjectMeta {Name : "a" , UID : types .UID ("a" ), Labels : map [string ]string {"app" : "foo" }}, Spec : v1.PodSpec {Containers : mediumContainers , Priority : & midPriority , NodeName : "machine1" }},
1575
+ {ObjectMeta : metav1.ObjectMeta {Name : "b" , UID : types .UID ("b" ), Labels : map [string ]string {"app" : "foo" }}, Spec : v1.PodSpec {Containers : mediumContainers , Priority : & midPriority , NodeName : "machine1" }}},
1576
+ pdbs : []* policy.PodDisruptionBudget {
1577
+ {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 ()}}}}},
1578
+ expected : map [string ]victims {"machine1" : {pods : sets .NewString ("a" , "b" ), numPDBViolations : 1 }},
1579
+ expectedNumFilterCalled : 3 ,
1580
+ },
1581
+ {
1582
+ name : "preemption with violation of the pdb with pod whose eviction was processed, the victim belongs to DisruptedPods" ,
1583
+ registerPlugins : []st.RegisterPluginFunc {
1584
+ st .RegisterQueueSortPlugin (queuesort .Name , queuesort .New ),
1585
+ st .RegisterPluginAsExtensions (noderesources .FitName , noderesources .NewFit , "Filter" , "PreFilter" ),
1586
+ st .RegisterBindPlugin (defaultbinder .Name , defaultbinder .New ),
1587
+ },
1588
+ nodes : []string {"machine1" },
1589
+ pod : & v1.Pod {ObjectMeta : metav1.ObjectMeta {Name : "pod1" , UID : types .UID ("pod1" )}, Spec : v1.PodSpec {Containers : veryLargeContainers , Priority : & highPriority }},
1590
+ pods : []* v1.Pod {
1591
+ {ObjectMeta : metav1.ObjectMeta {Name : "a" , UID : types .UID ("a" ), Labels : map [string ]string {"app" : "foo" }}, Spec : v1.PodSpec {Containers : mediumContainers , Priority : & midPriority , NodeName : "machine1" }},
1592
+ {ObjectMeta : metav1.ObjectMeta {Name : "b" , UID : types .UID ("b" ), Labels : map [string ]string {"app" : "foo" }}, Spec : v1.PodSpec {Containers : mediumContainers , Priority : & midPriority , NodeName : "machine1" }}},
1593
+ pdbs : []* policy.PodDisruptionBudget {
1594
+ {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 ()}}}}},
1595
+ expected : map [string ]victims {"machine1" : {pods : sets .NewString ("a" , "b" ), numPDBViolations : 0 }},
1596
+ expectedNumFilterCalled : 3 ,
1597
+ },
1564
1598
}
1565
1599
labelKeys := []string {"hostname" , "zone" , "region" }
1566
1600
for _ , test := range tests {
0 commit comments