From a527c10edc00968ec5462753f633599d0a192aa6 Mon Sep 17 00:00:00 2001 From: hasheddan Date: Sat, 11 Jul 2020 10:18:56 -0500 Subject: [PATCH] Make sure pod tested for eviction with PDB is not scheduled for deletion In #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 --- test/e2e/apps/disruption.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/e2e/apps/disruption.go b/test/e2e/apps/disruption.go index 23d905d5a36..235b485ecb4 100644 --- a/test/e2e/apps/disruption.go +++ b/test/e2e/apps/disruption.go @@ -276,10 +276,10 @@ var _ = SIGDescribe("DisruptionController", func() { createReplicaSetOrDie(cs, ns, 3, false) ginkgo.By("First trying to evict a pod which shouldn't be evictable") + waitForPodsOrDie(cs, ns, 3) // make sure that they are running and so would be evictable with a different pdb + pod, err := locateRunningPod(cs, ns) framework.ExpectNoError(err) - - waitForPodsOrDie(cs, ns, 3) // make sure that they are running and so would be evictable with a different pdb e := &policyv1beta1.Eviction{ ObjectMeta: metav1.ObjectMeta{ Name: pod.Name, @@ -314,9 +314,9 @@ var _ = SIGDescribe("DisruptionController", func() { return jsonpatch.CreateMergePatch(oldData, newData) }) + waitForPodsOrDie(cs, ns, 3) pod, err = locateRunningPod(cs, ns) // locate a new running pod framework.ExpectNoError(err) - waitForPodsOrDie(cs, ns, 3) e = &policyv1beta1.Eviction{ ObjectMeta: metav1.ObjectMeta{ Name: pod.Name, @@ -491,7 +491,7 @@ func waitForPodsOrDie(cs kubernetes.Interface, ns string, n int) { ready := 0 for i := range pods.Items { pod := pods.Items[i] - if podutil.IsPodReady(&pod) { + if podutil.IsPodReady(&pod) && pod.ObjectMeta.DeletionTimestamp.IsZero() { ready++ } } @@ -550,7 +550,7 @@ func locateRunningPod(cs kubernetes.Interface, ns string) (pod *v1.Pod, err erro for i := range podList.Items { p := podList.Items[i] - if podutil.IsPodReady(&p) { + if podutil.IsPodReady(&p) && p.ObjectMeta.DeletionTimestamp.IsZero() { pod = &p return true, nil }