@@ -138,13 +138,13 @@ func (s *Service) Create(ctx context.Context, r *shimapi.CreateTaskRequest) (_ *
138138 Options : r .Options ,
139139 }
140140 rootfs := filepath .Join (r .Bundle , "rootfs" )
141- defer func () {
141+ defer func (rootfs string ) {
142142 if err != nil {
143143 if err2 := mount .UnmountAll (rootfs , 0 ); err2 != nil {
144144 log .G (ctx ).WithError (err2 ).Warn ("Failed to cleanup rootfs mount" )
145145 }
146146 }
147- }()
147+ }(rootfs )
148148 for _ , rm := range mounts {
149149 m := & mount.Mount {
150150 Type : rm .Type ,
@@ -159,6 +159,10 @@ func (s *Service) Create(ctx context.Context, r *shimapi.CreateTaskRequest) (_ *
159159 s .mu .Lock ()
160160 defer s .mu .Unlock ()
161161
162+ if len (mounts ) == 0 {
163+ rootfs = ""
164+ }
165+
162166 process , err := newInit (
163167 ctx ,
164168 s .config .Path ,
@@ -169,6 +173,7 @@ func (s *Service) Create(ctx context.Context, r *shimapi.CreateTaskRequest) (_ *
169173 s .config .SystemdCgroup ,
170174 s .platform ,
171175 config ,
176+ rootfs ,
172177 )
173178 if err != nil {
174179 return nil , errdefs .ToGRPC (err )
@@ -632,7 +637,7 @@ func getTopic(ctx context.Context, e interface{}) string {
632637 return runtime .TaskUnknownTopic
633638}
634639
635- func newInit (ctx context.Context , path , workDir , runtimeRoot , namespace , criu string , systemdCgroup bool , platform rproc.Platform , r * proc.CreateConfig ) (* proc.Init , error ) {
640+ func newInit (ctx context.Context , path , workDir , runtimeRoot , namespace , criu string , systemdCgroup bool , platform rproc.Platform , r * proc.CreateConfig , rootfs string ) (* proc.Init , error ) {
636641 var options runctypes.CreateOptions
637642 if r .Options != nil {
638643 v , err := typeurl .UnmarshalAny (r .Options )
@@ -642,7 +647,6 @@ func newInit(ctx context.Context, path, workDir, runtimeRoot, namespace, criu st
642647 options = * v .(* runctypes.CreateOptions )
643648 }
644649
645- rootfs := filepath .Join (path , "rootfs" )
646650 runtime := proc .NewRunc (runtimeRoot , path , namespace , r .Runtime , criu , systemdCgroup )
647651 p := proc .New (r .ID , runtime , rproc.Stdio {
648652 Stdin : r .Stdin ,
0 commit comments