From 0fcc8ff8f50a62e56cfb3c36c9680895ea221db5 Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Thu, 14 Jan 2021 20:38:21 -0500 Subject: [PATCH] If destination does not exists, do not throw error When using volume mounts, the destination directory will get created if it does not exists. The current code blows up when the destination directory did not exists. Signed-off-by: Daniel J Walsh --- pkg/overlay/overlay.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/overlay/overlay.go b/pkg/overlay/overlay.go index 83a24758395..a3e5866eef4 100644 --- a/pkg/overlay/overlay.go +++ b/pkg/overlay/overlay.go @@ -78,10 +78,12 @@ func mountHelper(contentDir, source, dest string, _, _ int, graphOptions []strin workDir := filepath.Join(contentDir, "work") upperDir := filepath.Join(contentDir, "upper") st, err := os.Stat(dest) - if err != nil { - return mount, err + if err == nil { + if err := os.Chmod(upperDir, st.Mode()); err != nil { + return mount, err + } } - if err := os.Chmod(upperDir, st.Mode()); err != nil { + if !os.IsNotExist(err) { return mount, err } overlayOptions = fmt.Sprintf("lowerdir=%s,upperdir=%s,workdir=%s,private", source, upperDir, workDir)