Skip to content

Commit

Permalink
chore(test): backoff cleaning up temporary workspace directory
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalbreuninger committed Jan 20, 2025
1 parent 0c6b3c3 commit 603b67e
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion e2e/framework/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit 603b67e

Please sign in to comment.