@@ -323,7 +323,7 @@ func TestSelectNodesForPreemption(t *testing.T) {
323
323
expectedNumFilterCalled : 4 ,
324
324
},
325
325
{
326
- name : "a pod that would fit on the machines, but other pods running are higher priority" ,
326
+ name : "a pod that would fit on the machines, but other pods running are higher priority, no preemption would happen " ,
327
327
registerPlugins : []st.RegisterPluginFunc {
328
328
st .RegisterPluginAsExtensions (noderesources .FitName , noderesources .NewFit , "Filter" , "PreFilter" ),
329
329
},
@@ -334,7 +334,7 @@ func TestSelectNodesForPreemption(t *testing.T) {
334
334
st .MakePod ().Name ("p2" ).UID ("p2" ).Node ("node2" ).Priority (midPriority ).Req (largeRes ).Obj (),
335
335
},
336
336
expected : map [string ]* extenderv1.Victims {},
337
- expectedNumFilterCalled : 2 ,
337
+ expectedNumFilterCalled : 0 ,
338
338
},
339
339
{
340
340
name : "medium priority pod is preempted, but lower priority one stays as it is small" ,
@@ -380,7 +380,7 @@ func TestSelectNodesForPreemption(t *testing.T) {
380
380
},
381
381
},
382
382
},
383
- expectedNumFilterCalled : 5 ,
383
+ expectedNumFilterCalled : 4 ,
384
384
},
385
385
{
386
386
name : "mixed priority pods are preempted, pick later StartTime one when priorities are equal" ,
@@ -404,7 +404,7 @@ func TestSelectNodesForPreemption(t *testing.T) {
404
404
},
405
405
},
406
406
},
407
- expectedNumFilterCalled : 5 ,
407
+ expectedNumFilterCalled : 4 , // no preemption would happen on node2 and no filter call is counted.
408
408
},
409
409
{
410
410
name : "pod with anti-affinity is preempted" ,
@@ -428,9 +428,8 @@ func TestSelectNodesForPreemption(t *testing.T) {
428
428
PodAntiAffinityExists ("foo" , "hostname" , st .PodAntiAffinityWithRequiredReq ).Obj (),
429
429
},
430
430
},
431
- "node2" : {},
432
431
},
433
- expectedNumFilterCalled : 4 ,
432
+ expectedNumFilterCalled : 3 , // no preemption would happen on node2 and no filter call is counted.
434
433
},
435
434
{
436
435
name : "preemption to resolve pod topology spread filter failure" ,
@@ -457,7 +456,7 @@ func TestSelectNodesForPreemption(t *testing.T) {
457
456
Pods : []* v1.Pod {st .MakePod ().Name ("pod-b1" ).UID ("pod-b1" ).Node ("node-b" ).Label ("foo" , "" ).Priority (lowPriority ).Obj ()},
458
457
},
459
458
},
460
- expectedNumFilterCalled : 6 ,
459
+ expectedNumFilterCalled : 5 , // node-a (3), node-b (2), node-x (0)
461
460
},
462
461
{
463
462
name : "get Unschedulable in the preemption phase when the filter plugins filtering the nodes" ,
@@ -696,17 +695,6 @@ func TestPickOneNodeForPreemption(t *testing.T) {
696
695
},
697
696
expected : []string {"node1" , "node2" },
698
697
},
699
- {
700
- name : "a pod that fits on a machine with no preemption" ,
701
- registerPlugin : st .RegisterPluginAsExtensions (noderesources .FitName , noderesources .NewFit , "Filter" , "PreFilter" ),
702
- nodeNames : []string {"node1" , "node2" , "node3" },
703
- pod : st .MakePod ().Name ("p" ).UID ("p" ).Priority (highPriority ).Req (largeRes ).Obj (),
704
- pods : []* v1.Pod {
705
- st .MakePod ().Name ("p1" ).UID ("p1" ).Node ("node1" ).Priority (midPriority ).Req (largeRes ).StartTime (epochTime ).Obj (),
706
- st .MakePod ().Name ("p2" ).UID ("p2" ).Node ("node2" ).Priority (midPriority ).Req (largeRes ).StartTime (epochTime ).Obj (),
707
- },
708
- expected : []string {"node3" },
709
- },
710
698
{
711
699
name : "machine with min highest priority pod is picked" ,
712
700
registerPlugin : st .RegisterPluginAsExtensions (noderesources .FitName , noderesources .NewFit , "Filter" , "PreFilter" ),
@@ -1088,19 +1076,6 @@ func TestPreempt(t *testing.T) {
1088
1076
expectedNode : "node1" ,
1089
1077
expectedPods : []string {"p1.1" , "p1.2" },
1090
1078
},
1091
- {
1092
- name : "One node doesn't need any preemption" ,
1093
- pod : st .MakePod ().Name ("p" ).UID ("p" ).Priority (highPriority ).Req (veryLargeRes ).PreemptionPolicy (v1 .PreemptLowerPriority ).Obj (),
1094
- pods : []* v1.Pod {
1095
- st .MakePod ().Name ("p1.1" ).UID ("p1.1" ).Node ("node1" ).Priority (lowPriority ).Req (smallRes ).Obj (),
1096
- st .MakePod ().Name ("p1.2" ).UID ("p1.2" ).Node ("node1" ).Priority (lowPriority ).Req (smallRes ).Obj (),
1097
- st .MakePod ().Name ("p2.1" ).UID ("p2.1" ).Node ("node2" ).Priority (highPriority ).Req (largeRes ).Obj (),
1098
- },
1099
- nodeNames : []string {"node1" , "node2" , "node3" },
1100
- registerPlugin : st .RegisterPluginAsExtensions (noderesources .FitName , noderesources .NewFit , "Filter" , "PreFilter" ),
1101
- expectedNode : "node3" ,
1102
- expectedPods : []string {},
1103
- },
1104
1079
{
1105
1080
name : "preemption for topology spread constraints" ,
1106
1081
pod : st .MakePod ().Name ("p" ).UID ("p" ).Label ("foo" , "" ).Priority (highPriority ).
@@ -1170,21 +1145,22 @@ func TestPreempt(t *testing.T) {
1170
1145
expectedPods : []string {"p1.1" , "p1.2" },
1171
1146
},
1172
1147
{
1173
- name : "One scheduler extender allows only machine1, but it is not interested in given pod, otherwise node1 would have been chosen" ,
1148
+ name : "One scheduler extender allows only machine1, but it is not interested in given pod, otherwise machine1 would have been chosen" ,
1174
1149
pod : st .MakePod ().Name ("p" ).UID ("p" ).Priority (highPriority ).Req (veryLargeRes ).PreemptionPolicy (v1 .PreemptLowerPriority ).Obj (),
1175
1150
pods : []* v1.Pod {
1176
- st .MakePod ().Name ("p1.1" ).UID ("p1.1" ).Node ("node1 " ).Priority (midPriority ).Req (smallRes ).Obj (),
1177
- st .MakePod ().Name ("p1.2" ).UID ("p1.2" ).Node ("node1 " ).Priority (lowPriority ).Req (smallRes ).Obj (),
1178
- st .MakePod ().Name ("p2.1" ).UID ("p2.1" ).Node ("node2 " ).Priority (midPriority ).Req (largeRes ).Obj (),
1151
+ st .MakePod ().Name ("p1.1" ).UID ("p1.1" ).Node ("machine1 " ).Priority (midPriority ).Req (smallRes ).Obj (),
1152
+ st .MakePod ().Name ("p1.2" ).UID ("p1.2" ).Node ("machine1 " ).Priority (lowPriority ).Req (smallRes ).Obj (),
1153
+ st .MakePod ().Name ("p2.1" ).UID ("p2.1" ).Node ("machine2 " ).Priority (midPriority ).Req (largeRes ).Obj (),
1179
1154
},
1180
- nodeNames : []string {"node1 " , "node2" , "node3 " },
1155
+ nodeNames : []string {"machine1 " , "machine2 " },
1181
1156
extenders : []* st.FakeExtender {
1182
1157
{Predicates : []st.FitPredicate {st .Machine1PredicateExtender }, UnInterested : true },
1183
1158
{Predicates : []st.FitPredicate {st .TruePredicateExtender }},
1184
1159
},
1185
1160
registerPlugin : st .RegisterPluginAsExtensions (noderesources .FitName , noderesources .NewFit , "Filter" , "PreFilter" ),
1186
- expectedNode : "node3" ,
1187
- expectedPods : []string {},
1161
+ // sum of priorities of all victims on machine1 is larger than machine2, machine2 is chosen.
1162
+ expectedNode : "machine2" ,
1163
+ expectedPods : []string {"p2.1" },
1188
1164
},
1189
1165
{
1190
1166
name : "no preempting in pod" ,
0 commit comments