From 8168434f0c6f769cd4a06978e9e8bf1283eef4f2 Mon Sep 17 00:00:00 2001 From: Patrick Ohly Date: Tue, 13 Dec 2022 20:19:32 +0100 Subject: [PATCH] e2e storage: explain why cleanup is done inside the function This code must run during the test and thus cannot be moved into DeferCleanup. --- test/e2e/framework/volume/fixtures.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/e2e/framework/volume/fixtures.go b/test/e2e/framework/volume/fixtures.go index 1249c508652..0299a1a1d4f 100644 --- a/test/e2e/framework/volume/fixtures.go +++ b/test/e2e/framework/volume/fixtures.go @@ -539,6 +539,8 @@ func testVolumeClient(f *framework.Framework, config TestConfig, fsGroup *int64, framework.Failf("Failed to create client pod: %v", err) } defer func() { + // testVolumeClient might get used more than once per test, therefore + // we have to clean up before returning. e2epod.DeletePodOrFail(f.ClientSet, clientPod.Namespace, clientPod.Name) e2epod.WaitForPodToDisappear(f.ClientSet, clientPod.Namespace, clientPod.Name, labels.Everything(), framework.Poll, timeouts.PodDelete) }() @@ -572,6 +574,8 @@ func InjectContent(f *framework.Framework, config TestConfig, fsGroup *int64, fs return } defer func() { + // This pod must get deleted before the function returns becaue the test relies on + // the volume not being in use. e2epod.DeletePodOrFail(f.ClientSet, injectorPod.Namespace, injectorPod.Name) e2epod.WaitForPodToDisappear(f.ClientSet, injectorPod.Namespace, injectorPod.Name, labels.Everything(), framework.Poll, timeouts.PodDelete) }()