From 1b33fe40220a322d95d6c6756215ad36235afcee Mon Sep 17 00:00:00 2001 From: lifupan Date: Thu, 9 May 2019 03:41:47 -0400 Subject: [PATCH] shimv2: create the rootfs dir if it doesn't exist Latest containerd commit had moved the step of creating rootfs dir from creating bundle to container creation; in order to support both of the old and latest containerd, check the "rootfs" existed before creating it. Fixes:#1652 Signed-off-by: lifupan --- containerd-shim-v2/create.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/containerd-shim-v2/create.go b/containerd-shim-v2/create.go index b5fe278b42..c30047fcca 100644 --- a/containerd-shim-v2/create.go +++ b/containerd-shim-v2/create.go @@ -210,6 +210,16 @@ func checkAndMount(s *service, r *taskAPI.CreateTaskRequest) error { } func doMount(mounts []*containerd_types.Mount, rootfs string) error { + if len(mounts) == 0 { + return nil + } + + if _, err := os.Stat(rootfs); os.IsNotExist(err) { + if err := os.Mkdir(rootfs, 0711); err != nil { + return err + } + } + for _, rm := range mounts { m := &mount.Mount{ Type: rm.Type,