From 04b1062cbc5eac1a8b70a1094f767f3214fd9ab8 Mon Sep 17 00:00:00 2001 From: Antonio Ojea Date: Wed, 17 Feb 2021 11:24:45 +0100 Subject: [PATCH] e2e createSync() method wait for pod running and ready The user expectections calling this method is that the pod should be ready for the test, however, it only checks that is running, causing timing issues on busy environments. Per example, if the pod is not ready, kube-proxy or other services implementations will not forward traffic to it. --- test/e2e/framework/pod/wait.go | 2 +- test/e2e/framework/pods.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/e2e/framework/pod/wait.go b/test/e2e/framework/pod/wait.go index 8124540ba0e..cb107a920b8 100644 --- a/test/e2e/framework/pod/wait.go +++ b/test/e2e/framework/pod/wait.go @@ -357,7 +357,7 @@ func WaitForPodNoLongerRunningInNamespace(c clientset.Interface, podName, namesp return WaitTimeoutForPodNoLongerRunningInNamespace(c, podName, namespace, defaultPodDeletionTimeout) } -// WaitTimeoutForPodReadyInNamespace waits the given timeout diration for the +// WaitTimeoutForPodReadyInNamespace waits the given timeout duration for the // specified pod to be ready and running. func WaitTimeoutForPodReadyInNamespace(c clientset.Interface, podName, namespace string, timeout time.Duration) error { return wait.PollImmediate(poll, timeout, podRunningAndReady(c, podName, namespace)) diff --git a/test/e2e/framework/pods.go b/test/e2e/framework/pods.go index ad20a63fce2..679ac54abf2 100644 --- a/test/e2e/framework/pods.go +++ b/test/e2e/framework/pods.go @@ -96,12 +96,12 @@ func (c *PodClient) Create(pod *v1.Pod) *v1.Pod { return p } -// CreateSync creates a new pod according to the framework specifications, and wait for it to start. +// CreateSync creates a new pod according to the framework specifications, and wait for it to start and be running and ready. func (c *PodClient) CreateSync(pod *v1.Pod) *v1.Pod { namespace := c.f.Namespace.Name p := c.Create(pod) - ExpectNoError(e2epod.WaitForPodNameRunningInNamespace(c.f.ClientSet, p.Name, namespace)) - // Get the newest pod after it becomes running, some status may change after pod created, such as pod ip. + ExpectNoError(e2epod.WaitTimeoutForPodReadyInNamespace(c.f.ClientSet, p.Name, namespace, PodStartTimeout)) + // Get the newest pod after it becomes running and ready, some status may change after pod created, such as pod ip. p, err := c.Get(context.TODO(), p.Name, metav1.GetOptions{}) ExpectNoError(err) return p