From 603b67e5bd0ed5b82b0bf17aa5d44770c6adae1d Mon Sep 17 00:00:00 2001 From: Pascal Breuninger Date: Mon, 20 Jan 2025 15:19:34 +0100 Subject: [PATCH] chore(test): backoff cleaning up temporary workspace directory --- e2e/framework/util.go | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/e2e/framework/util.go b/e2e/framework/util.go index c7241ab8f..b30cf827f 100644 --- a/e2e/framework/util.go +++ b/e2e/framework/util.go @@ -9,6 +9,8 @@ import ( "time" "github.com/otiai10/copy" + "k8s.io/apimachinery/pkg/util/wait" + "k8s.io/client-go/util/retry" ) func GetTimeout() time.Duration { @@ -93,7 +95,21 @@ func CopyToTempDir(relativePath string) (string, error) { } func CleanupTempDir(initialDir, tempDir string) { - err := os.RemoveAll(tempDir) + err := retry.OnError(wait.Backoff{ + Steps: 3, + Duration: 500 * time.Millisecond, + Factor: 2.0, + Jitter: 0, + }, func(err error) bool { return true }, + func() error { + err := os.RemoveAll(tempDir) + if err != nil { + fmt.Println("WARN:", err) + return err + } + + return nil + }) if err != nil { fmt.Println("WARN:", err) }