diff --git a/pkg/v1/shim/service.go b/pkg/v1/shim/service.go index 083dfa534..b9e1c0ced 100644 --- a/pkg/v1/shim/service.go +++ b/pkg/v1/shim/service.go @@ -125,6 +125,11 @@ func (s *Service) Create(ctx context.Context, r *shimapi.CreateTaskRequest) (_ * }) } + rootfs := filepath.Join(r.Bundle, "rootfs") + if err := os.Mkdir(rootfs, 0711); err != nil && !os.IsExist(err) { + return nil, err + } + config := &proc.CreateConfig{ ID: r.ID, Bundle: r.Bundle, @@ -136,7 +141,6 @@ func (s *Service) Create(ctx context.Context, r *shimapi.CreateTaskRequest) (_ * Stderr: r.Stderr, Options: r.Options, } - rootfs := filepath.Join(r.Bundle, "rootfs") defer func() { if err != nil { if err2 := mount.UnmountAll(rootfs, 0); err2 != nil { diff --git a/pkg/v2/service.go b/pkg/v2/service.go index c2d2b1511..63a2f0da6 100644 --- a/pkg/v2/service.go +++ b/pkg/v2/service.go @@ -287,6 +287,12 @@ func (s *service) Create(ctx context.Context, r *taskAPI.CreateTaskRequest) (_ * Options: m.Options, }) } + + rootfs := filepath.Join(r.Bundle, "rootfs") + if err := os.Mkdir(rootfs, 0711); err != nil && !os.IsExist(err) { + return nil, err + } + config := &proc.CreateConfig{ ID: r.ID, Bundle: r.Bundle, @@ -301,7 +307,6 @@ func (s *service) Create(ctx context.Context, r *taskAPI.CreateTaskRequest) (_ * if err := s.writeRuntime(r.Bundle, opts.BinaryName); err != nil { return nil, err } - rootfs := filepath.Join(r.Bundle, "rootfs") defer func() { if err != nil { if err2 := mount.UnmountAll(rootfs, 0); err2 != nil { @@ -327,6 +332,7 @@ func (s *service) Create(ctx context.Context, r *taskAPI.CreateTaskRequest) (_ * s.platform, config, &opts, + rootfs, ) if err != nil { return nil, errdefs.ToGRPC(err) @@ -698,13 +704,12 @@ func getTopic(e interface{}) string { return runtime.TaskUnknownTopic } -func newInit(ctx context.Context, path, workDir, namespace string, platform rproc.Platform, r *proc.CreateConfig, options *options.Options) (*proc.Init, error) { +func newInit(ctx context.Context, path, workDir, namespace string, platform rproc.Platform, r *proc.CreateConfig, options *options.Options, rootfs string) (*proc.Init, error) { spec, err := utils.ReadSpec(r.Bundle) if err != nil { return nil, errors.Wrap(err, "read oci spec") } runsc.FormatLogPath(r.ID, options.RunscConfig) - rootfs := filepath.Join(path, "rootfs") runtime := proc.NewRunsc(options.Root, path, namespace, options.BinaryName, options.RunscConfig) p := proc.New(r.ID, runtime, rproc.Stdio{ Stdin: r.Stdin,