Simplify DeferCleanup.

Co-authored-by: Patrick Ohly <patrick.ohly@intel.com>
This commit is contained in:
Jan Šafránek 2023-05-23 14:46:05 +02:00 committed by GitHub
parent b30720fc9f
commit 149f4878a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)