From d4a912208d5ba0d3627a5196ee0b6d96e13fe592 Mon Sep 17 00:00:00 2001 From: Davanum Srinivas Date: Sun, 13 Nov 2016 19:33:28 -0500 Subject: [PATCH] Cleanup pod in MatchContainerOutput MatchContainerOutput always creates a pod and does not cleanup. We need to fix this to be better at re-trying the scenarios. When there is an error say in the first attempt of ExpectNoErrorWithRetries (for example in "Pods should contain environment variables for services" test) the retries logic calls MatchContainerOutput another time and the podClient.create fails correctly since the pod was not cleaned up the first time MatchContainerOutput was called. Fixes #35089 --- test/e2e/framework/util.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/e2e/framework/util.go b/test/e2e/framework/util.go index d0023faa1af..b1e0363e703 100644 --- a/test/e2e/framework/util.go +++ b/test/e2e/framework/util.go @@ -2163,6 +2163,10 @@ func (f *Framework) MatchContainerOutput( ns := f.Namespace.Name createdPod := podClient.Create(pod) + defer func() { + By("delete the pod") + podClient.DeleteSync(createdPod.Name, &api.DeleteOptions{}, podNoLongerRunningTimeout) + }() // Wait for client pod to complete. if err := WaitForPodSuccessInNamespace(f.ClientSet, createdPod.Name, ns); err != nil {