From c2aa40ca1362ad0be77f44b65765f99bc860b16e Mon Sep 17 00:00:00 2001 From: Kermit Alexander Date: Tue, 16 Mar 2021 14:44:19 +0000 Subject: [PATCH 1/3] Do not early exit if pod is not found in WaitForPodCondition. --- test/e2e/framework/pod/wait.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/framework/pod/wait.go b/test/e2e/framework/pod/wait.go index cb107a920b8..4f7e0691f24 100644 --- a/test/e2e/framework/pod/wait.go +++ b/test/e2e/framework/pod/wait.go @@ -215,7 +215,7 @@ func WaitForPodCondition(c clientset.Interface, ns, podName, desc string, timeou if err != nil { if apierrors.IsNotFound(err) { e2elog.Logf("Pod %q in namespace %q not found. Error: %v", podName, ns, err) - return err + continue } e2elog.Logf("Get pod %q in namespace %q failed, ignoring for %v. Error: %v", podName, ns, poll, err) continue From 3213e36430ce0a5a91ee6f652e8d19588538684e Mon Sep 17 00:00:00 2001 From: Kermit Alexander Date: Wed, 17 Mar 2021 23:14:29 +0000 Subject: [PATCH 2/3] Always check passed podCondition in WaitForPodCondition. --- test/e2e/framework/pod/wait.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/e2e/framework/pod/wait.go b/test/e2e/framework/pod/wait.go index 4f7e0691f24..fd2075c7bb4 100644 --- a/test/e2e/framework/pod/wait.go +++ b/test/e2e/framework/pod/wait.go @@ -215,10 +215,9 @@ func WaitForPodCondition(c clientset.Interface, ns, podName, desc string, timeou if err != nil { if apierrors.IsNotFound(err) { e2elog.Logf("Pod %q in namespace %q not found. Error: %v", podName, ns, err) - continue + } else { + e2elog.Logf("Get pod %q in namespace %q failed, ignoring for %v. Error: %v", podName, ns, poll, err) } - 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", From 81040d386f2a34a64d0ff56bc967ad1de28908be Mon Sep 17 00:00:00 2001 From: Kermit Alexander Date: Thu, 18 Mar 2021 00:53:26 +0000 Subject: [PATCH 3/3] Return last pod error when apierrors.IsNotFound returns true in WaitForPodCondition. --- test/e2e/framework/pod/wait.go | 7 +++++++ 1 file changed, 7 insertions(+) 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) }