From f7a5817bc65b41897e3dc4aa6d814eb51b82420b Mon Sep 17 00:00:00 2001 From: Patrick Ohly Date: Mon, 12 Jun 2023 15:41:43 +0200 Subject: [PATCH] e2e storage: terminate worker quietly on test completion Once DeferCleanup for the worker goroutine is invoked, there's no need to continue doing anything anymore in that goroutine and it can return immediately, without reporting the "context canceled" error because there is no other reason for that. --- test/e2e/storage/persistent_volumes-local.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/test/e2e/storage/persistent_volumes-local.go b/test/e2e/storage/persistent_volumes-local.go index 32853f288bf..c59e89c2225 100644 --- a/test/e2e/storage/persistent_volumes-local.go +++ b/test/e2e/storage/persistent_volumes-local.go @@ -18,6 +18,7 @@ package storage import ( "context" + "errors" "fmt" "math/rand" "path/filepath" @@ -517,7 +518,7 @@ var _ = utils.SIGDescribe("PersistentVolumes-local ", func() { continue } pv, err = config.client.CoreV1().PersistentVolumes().Get(backgroundCtx, pv.Name, metav1.GetOptions{}) - if apierrors.IsNotFound(err) { + if apierrors.IsNotFound(err) || errors.Is(err, context.Canceled) { continue } // Delete and create a new PV for same local volume storage @@ -528,9 +529,15 @@ var _ = utils.SIGDescribe("PersistentVolumes-local ", func() { continue } err = config.client.CoreV1().PersistentVolumes().Delete(backgroundCtx, pv.Name, metav1.DeleteOptions{}) + if errors.Is(err, context.Canceled) { + continue + } framework.ExpectNoError(err) pvConfig := makeLocalPVConfig(config, localVolume) localVolume.pv, err = e2epv.CreatePV(backgroundCtx, config.client, f.Timeouts, e2epv.MakePersistentVolume(pvConfig)) + if errors.Is(err, context.Canceled) { + continue + } framework.ExpectNoError(err) } }