@@ -1496,10 +1496,28 @@ func TestSelectNodesForPreemption(t *testing.T) {
1496
1496
{ObjectMeta : metav1.ObjectMeta {Name : "a" , UID : types .UID ("a" ), Labels : map [string ]string {"app" : "foo" }}, Spec : v1.PodSpec {Containers : mediumContainers , Priority : & midPriority , NodeName : "machine1" }},
1497
1497
{ObjectMeta : metav1.ObjectMeta {Name : "b" , UID : types .UID ("b" ), Labels : map [string ]string {"app" : "foo" }}, Spec : v1.PodSpec {Containers : mediumContainers , Priority : & midPriority , NodeName : "machine1" }}},
1498
1498
pdbs : []* policy.PodDisruptionBudget {
1499
- {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 ()}}}}},
1499
+ {Spec : policy.PodDisruptionBudgetSpec {Selector : & metav1.LabelSelector {MatchLabels : map [string ]string {"app" : "foo" }}}, Status : policy.PodDisruptionBudgetStatus {DisruptionsAllowed : 1 , DisruptedPods : map [string ]metav1.Time {"b " : {Time : time .Now ()}}}}},
1500
1500
expected : map [string ]victims {"machine1" : {pods : sets .NewString ("a" , "b" ), numPDBViolations : 0 }},
1501
1501
expectedNumFilterCalled : 3 ,
1502
1502
},
1503
+ {
1504
+ name : "preemption with violation of the pdb with pod whose eviction was processed, the victim which belongs to DisruptedPods is treated as 'nonViolating'" ,
1505
+ registerPlugins : []st.RegisterPluginFunc {
1506
+ st .RegisterQueueSortPlugin (queuesort .Name , queuesort .New ),
1507
+ st .RegisterPluginAsExtensions (noderesources .FitName , noderesources .NewFit , "Filter" , "PreFilter" ),
1508
+ st .RegisterBindPlugin (defaultbinder .Name , defaultbinder .New ),
1509
+ },
1510
+ nodes : []string {"machine1" },
1511
+ pod : & v1.Pod {ObjectMeta : metav1.ObjectMeta {Name : "pod1" , UID : types .UID ("pod1" )}, Spec : v1.PodSpec {Containers : veryLargeContainers , Priority : & highPriority }},
1512
+ pods : []* v1.Pod {
1513
+ {ObjectMeta : metav1.ObjectMeta {Name : "a" , UID : types .UID ("a" ), Labels : map [string ]string {"app" : "foo" }}, Spec : v1.PodSpec {Containers : mediumContainers , Priority : & midPriority , NodeName : "machine1" }},
1514
+ {ObjectMeta : metav1.ObjectMeta {Name : "b" , UID : types .UID ("b" ), Labels : map [string ]string {"app" : "foo" }}, Spec : v1.PodSpec {Containers : mediumContainers , Priority : & midPriority , NodeName : "machine1" }},
1515
+ {ObjectMeta : metav1.ObjectMeta {Name : "c" , UID : types .UID ("c" ), Labels : map [string ]string {"app" : "foo" }}, Spec : v1.PodSpec {Containers : mediumContainers , Priority : & midPriority , NodeName : "machine1" }}},
1516
+ pdbs : []* policy.PodDisruptionBudget {
1517
+ {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 ()}}}}},
1518
+ expected : map [string ]victims {"machine1" : {pods : sets .NewString ("a" , "b" , "c" ), numPDBViolations : 1 }},
1519
+ expectedNumFilterCalled : 4 ,
1520
+ },
1503
1521
}
1504
1522
labelKeys := []string {"hostname" , "zone" , "region" }
1505
1523
for _ , test := range tests {
0 commit comments