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.
This commit is contained in:
Patrick Ohly 2023-06-12 15:41:43 +02:00
parent 18d05b646d
commit f7a5817bc6

View File

@ -18,6 +18,7 @@ package storage
import ( import (
"context" "context"
"errors"
"fmt" "fmt"
"math/rand" "math/rand"
"path/filepath" "path/filepath"
@ -517,7 +518,7 @@ var _ = utils.SIGDescribe("PersistentVolumes-local ", func() {
continue continue
} }
pv, err = config.client.CoreV1().PersistentVolumes().Get(backgroundCtx, pv.Name, metav1.GetOptions{}) 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 continue
} }
// Delete and create a new PV for same local volume storage // Delete and create a new PV for same local volume storage
@ -528,9 +529,15 @@ var _ = utils.SIGDescribe("PersistentVolumes-local ", func() {
continue continue
} }
err = config.client.CoreV1().PersistentVolumes().Delete(backgroundCtx, pv.Name, metav1.DeleteOptions{}) err = config.client.CoreV1().PersistentVolumes().Delete(backgroundCtx, pv.Name, metav1.DeleteOptions{})
if errors.Is(err, context.Canceled) {
continue
}
framework.ExpectNoError(err) framework.ExpectNoError(err)
pvConfig := makeLocalPVConfig(config, localVolume) pvConfig := makeLocalPVConfig(config, localVolume)
localVolume.pv, err = e2epv.CreatePV(backgroundCtx, config.client, f.Timeouts, e2epv.MakePersistentVolume(pvConfig)) localVolume.pv, err = e2epv.CreatePV(backgroundCtx, config.client, f.Timeouts, e2epv.MakePersistentVolume(pvConfig))
if errors.Is(err, context.Canceled) {
continue
}
framework.ExpectNoError(err) framework.ExpectNoError(err)
} }
} }