mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 03:41:45 +00:00
Merge pull request #87205 from mortent/DeflakePdbE2eTest
Make sure PDB has observed pods before doing eviction in e2e test
This commit is contained in:
commit
7ab9a1de34
@ -223,6 +223,7 @@ var _ = SIGDescribe("DisruptionController", func() {
|
||||
|
||||
ginkgo.By("Trying to evict the same pod we tried earlier which should now be evictable")
|
||||
waitForPodsOrDie(cs, ns, 3)
|
||||
waitForPdbToObserveHealthyPods(cs, ns, 3)
|
||||
err = cs.CoreV1().Pods(ns).Evict(e)
|
||||
framework.ExpectNoError(err) // the eviction is now allowed
|
||||
})
|
||||
@ -402,3 +403,18 @@ func waitForPdbToBeProcessed(cs kubernetes.Interface, ns string) {
|
||||
})
|
||||
framework.ExpectNoError(err, "Waiting for the pdb to be processed in namespace %s", ns)
|
||||
}
|
||||
|
||||
func waitForPdbToObserveHealthyPods(cs kubernetes.Interface, ns string, healthyCount int32) {
|
||||
ginkgo.By("Waiting for the pdb to observed all healthy pods")
|
||||
err := wait.PollImmediate(framework.Poll, wait.ForeverTestTimeout, func() (bool, error) {
|
||||
pdb, err := cs.PolicyV1beta1().PodDisruptionBudgets(ns).Get("foo", metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
if pdb.Status.CurrentHealthy != healthyCount {
|
||||
return false, nil
|
||||
}
|
||||
return true, nil
|
||||
})
|
||||
framework.ExpectNoError(err, "Waiting for the pdb in namespace %s to observed %d healthy pods", ns, healthyCount)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user