diff --git a/test/e2e/framework/pod/wait.go b/test/e2e/framework/pod/wait.go index fd2075c7bb4..1154e6d60bb 100644 --- a/test/e2e/framework/pod/wait.go +++ b/test/e2e/framework/pod/wait.go @@ -210,14 +210,17 @@ func WaitForPodsRunningReady(c clientset.Interface, ns string, minPods, allowedN // WaitForPodCondition waits a pods to be matched to the given condition. func WaitForPodCondition(c clientset.Interface, ns, podName, desc string, timeout time.Duration, condition podCondition) error { e2elog.Logf("Waiting up to %v for pod %q in namespace %q to be %q", timeout, podName, ns, desc) + var lastPodError error for start := time.Now(); time.Since(start) < timeout; time.Sleep(poll) { pod, err := c.CoreV1().Pods(ns).Get(context.TODO(), podName, metav1.GetOptions{}) + lastPodError = err if err != nil { if apierrors.IsNotFound(err) { e2elog.Logf("Pod %q in namespace %q not found. Error: %v", podName, ns, err) } else { e2elog.Logf("Get pod %q in namespace %q failed, ignoring for %v. Error: %v", podName, ns, poll, err) } + continue } // log now so that current pod info is reported before calling `condition()` e2elog.Logf("Pod %q: Phase=%q, Reason=%q, readiness=%t. Elapsed: %v", @@ -229,6 +232,10 @@ func WaitForPodCondition(c clientset.Interface, ns, podName, desc string, timeou return err } } + if apierrors.IsNotFound(lastPodError) { + // return for compatbility with other functions testing for IsNotFound + return lastPodError + } return fmt.Errorf("Gave up after waiting %v for pod %q to be %q", timeout, podName, desc) }