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