Skip to content

Commit a527c10

Browse files
committed
Make sure pod tested for eviction with PDB is not scheduled for deletion
In kubernetes#91342 attempting to evict a Pod with a DeletionTimestamp caused checking of PDBs to be ignored due to the fact that a Pod scheduled for deletion should not be factored into a disruption budget. However, PDB eviction tests currently will sometimes select a Pod already scheduled for deletion, expecting that attempting to evict it will conflict with the PDB. This updates those tests to make sure a Pod with deletion timestamp is not selected for eviction when it is intended to violate a PDB. Signed-off-by: hasheddan <[email protected]>
1 parent c2d1541 commit a527c10

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

test/e2e/apps/disruption.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -276,10 +276,10 @@ var _ = SIGDescribe("DisruptionController", func() {
276276
createReplicaSetOrDie(cs, ns, 3, false)
277277

278278
ginkgo.By("First trying to evict a pod which shouldn't be evictable")
279+
waitForPodsOrDie(cs, ns, 3) // make sure that they are running and so would be evictable with a different pdb
280+
279281
pod, err := locateRunningPod(cs, ns)
280282
framework.ExpectNoError(err)
281-
282-
waitForPodsOrDie(cs, ns, 3) // make sure that they are running and so would be evictable with a different pdb
283283
e := &policyv1beta1.Eviction{
284284
ObjectMeta: metav1.ObjectMeta{
285285
Name: pod.Name,
@@ -314,9 +314,9 @@ var _ = SIGDescribe("DisruptionController", func() {
314314
return jsonpatch.CreateMergePatch(oldData, newData)
315315
})
316316

317+
waitForPodsOrDie(cs, ns, 3)
317318
pod, err = locateRunningPod(cs, ns) // locate a new running pod
318319
framework.ExpectNoError(err)
319-
waitForPodsOrDie(cs, ns, 3)
320320
e = &policyv1beta1.Eviction{
321321
ObjectMeta: metav1.ObjectMeta{
322322
Name: pod.Name,
@@ -491,7 +491,7 @@ func waitForPodsOrDie(cs kubernetes.Interface, ns string, n int) {
491491
ready := 0
492492
for i := range pods.Items {
493493
pod := pods.Items[i]
494-
if podutil.IsPodReady(&pod) {
494+
if podutil.IsPodReady(&pod) && pod.ObjectMeta.DeletionTimestamp.IsZero() {
495495
ready++
496496
}
497497
}
@@ -550,7 +550,7 @@ func locateRunningPod(cs kubernetes.Interface, ns string) (pod *v1.Pod, err erro
550550

551551
for i := range podList.Items {
552552
p := podList.Items[i]
553-
if podutil.IsPodReady(&p) {
553+
if podutil.IsPodReady(&p) && p.ObjectMeta.DeletionTimestamp.IsZero() {
554554
pod = &p
555555
return true, nil
556556
}

0 commit comments

Comments
 (0)