From 4b45e1386905c7e62dbaf9172d4aaffa5540e4ee Mon Sep 17 00:00:00 2001 From: Alexandru Matei Date: Mon, 21 Nov 2022 17:36:00 +0200 Subject: [PATCH] runtime: don't fail mkdir if the folder is already created Use MkdirAll instead of Mkdir so it doesn't generate an error when the folder is created by another process Fixes #5713 Signed-off-by: Alexandru Matei --- src/runtime/virtcontainers/utils/utils.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/runtime/virtcontainers/utils/utils.go b/src/runtime/virtcontainers/utils/utils.go index 86f1ad874d..8b05bfc2fc 100644 --- a/src/runtime/virtcontainers/utils/utils.go +++ b/src/runtime/virtcontainers/utils/utils.go @@ -399,7 +399,7 @@ func MkdirAllWithInheritedOwner(path string, perm os.FileMode) error { info, err := os.Stat(curPath) if err != nil { - if err = os.Mkdir(curPath, perm); err != nil { + if err = os.MkdirAll(curPath, perm); err != nil { return fmt.Errorf("mkdir call failed: %v", err.Error()) } if err = syscall.Chown(curPath, uid, gid); err != nil {