From 149f4878a7067f4bf8004a3682929787c80d1087 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20=C5=A0afr=C3=A1nek?= Date: Tue, 23 May 2023 14:46:05 +0200 Subject: [PATCH] Simplify DeferCleanup. Co-authored-by: Patrick Ohly --- test/e2e/storage/static_pods.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/test/e2e/storage/static_pods.go b/test/e2e/storage/static_pods.go index e82a0c506da..89c6d641134 100644 --- a/test/e2e/storage/static_pods.go +++ b/test/e2e/storage/static_pods.go @@ -78,12 +78,7 @@ var _ = utils.SIGDescribe("StaticPods [Feature:Kind]", func() { } pod, err := e2epod.CreateSecPod(ctx, f.ClientSet, podConfig, f.Timeouts.PodStart) framework.ExpectNoError(err, "Creating a pod with a CSI volume") - ginkgo.DeferCleanup(func(ctx context.Context) { - if pod != nil { - err := f.ClientSet.CoreV1().Pods(f.Namespace.Name).Delete(ctx, pod.Name, metav1.DeleteOptions{}) - framework.ExpectNoError(err, "Deleting the pod with the CSI volume") - } - }) + ginkgo.DeferCleanup(f.ClientSet.CoreV1().Pods(f.Namespace.Name).Delete, pod.Name, metav1.DeleteOptions{}) ginkgo.By("Stop the control plane by removing the static pod manifests") err = stopControlPlane(ctx)