@@ -270,6 +270,42 @@ func TestRemovePodsHavingTooManyRestarts(t *testing.T) {
270
270
}
271
271
},
272
272
},
273
+ {
274
+ description : "pods pending with initContainer with states=CrashLoopBackOff threshold(includingInitContainers=true), 3 pod evictions" ,
275
+ args : RemovePodsHavingTooManyRestartsArgs {PodRestartThreshold : 1 , States : []string {"CrashLoopBackOff" }, IncludingInitContainers : true },
276
+ nodes : []* v1.Node {node1 },
277
+ expectedEvictedPodCount : 3 ,
278
+ maxPodsToEvictPerNode : & uint3 ,
279
+ applyFunc : func (pods []* v1.Pod ) {
280
+ for _ , pod := range pods {
281
+ pod .Status .InitContainerStatuses = []v1.ContainerStatus {
282
+ {
283
+ State : v1.ContainerState {
284
+ Waiting : & v1.ContainerStateWaiting {Reason : "CrashLoopBackOff" },
285
+ },
286
+ },
287
+ }
288
+ }
289
+ },
290
+ },
291
+ {
292
+ description : "pods pending with initContainer with states=CrashLoopBackOff threshold(includingInitContainers=false), 0 pod evictions" ,
293
+ args : RemovePodsHavingTooManyRestartsArgs {PodRestartThreshold : 1 , States : []string {"CrashLoopBackOff" }, IncludingInitContainers : false },
294
+ nodes : []* v1.Node {node1 },
295
+ expectedEvictedPodCount : 0 ,
296
+ maxPodsToEvictPerNode : & uint3 ,
297
+ applyFunc : func (pods []* v1.Pod ) {
298
+ for _ , pod := range pods {
299
+ pod .Status .InitContainerStatuses = []v1.ContainerStatus {
300
+ {
301
+ State : v1.ContainerState {
302
+ Waiting : & v1.ContainerStateWaiting {Reason : "CrashLoopBackOff" },
303
+ },
304
+ },
305
+ }
306
+ }
307
+ },
308
+ },
273
309
}
274
310
275
311
for _ , tc := range tests {
0 commit comments