Skip rootfs unmount when no mounts are provided
Co-authored-by: Julia Nedialkova <julianedialkova@hotmail.com> Signed-off-by: Georgi Sabev <georgethebeatle@gmail.com>
This commit is contained in:
parent
e7b6fea572
commit
2a5e4c4be7
@ -304,10 +304,12 @@ func (p *Init) delete(ctx context.Context) error {
|
|||||||
}
|
}
|
||||||
p.io.Close()
|
p.io.Close()
|
||||||
}
|
}
|
||||||
if err2 := mount.UnmountAll(p.Rootfs, 0); err2 != nil {
|
if p.Rootfs != "" {
|
||||||
log.G(ctx).WithError(err2).Warn("failed to cleanup rootfs mount")
|
if err2 := mount.UnmountAll(p.Rootfs, 0); err2 != nil {
|
||||||
if err == nil {
|
log.G(ctx).WithError(err2).Warn("failed to cleanup rootfs mount")
|
||||||
err = errors.Wrap(err2, "failed rootfs umount")
|
if err == nil {
|
||||||
|
err = errors.Wrap(err2, "failed rootfs umount")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
|
@ -138,13 +138,13 @@ func (s *Service) Create(ctx context.Context, r *shimapi.CreateTaskRequest) (_ *
|
|||||||
Options: r.Options,
|
Options: r.Options,
|
||||||
}
|
}
|
||||||
rootfs := filepath.Join(r.Bundle, "rootfs")
|
rootfs := filepath.Join(r.Bundle, "rootfs")
|
||||||
defer func() {
|
defer func(rootfs string) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err2 := mount.UnmountAll(rootfs, 0); err2 != nil {
|
if err2 := mount.UnmountAll(rootfs, 0); err2 != nil {
|
||||||
log.G(ctx).WithError(err2).Warn("Failed to cleanup rootfs mount")
|
log.G(ctx).WithError(err2).Warn("Failed to cleanup rootfs mount")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}(rootfs)
|
||||||
for _, rm := range mounts {
|
for _, rm := range mounts {
|
||||||
m := &mount.Mount{
|
m := &mount.Mount{
|
||||||
Type: rm.Type,
|
Type: rm.Type,
|
||||||
@ -159,6 +159,10 @@ func (s *Service) Create(ctx context.Context, r *shimapi.CreateTaskRequest) (_ *
|
|||||||
s.mu.Lock()
|
s.mu.Lock()
|
||||||
defer s.mu.Unlock()
|
defer s.mu.Unlock()
|
||||||
|
|
||||||
|
if len(mounts) == 0 {
|
||||||
|
rootfs = ""
|
||||||
|
}
|
||||||
|
|
||||||
process, err := newInit(
|
process, err := newInit(
|
||||||
ctx,
|
ctx,
|
||||||
s.config.Path,
|
s.config.Path,
|
||||||
@ -169,6 +173,7 @@ func (s *Service) Create(ctx context.Context, r *shimapi.CreateTaskRequest) (_ *
|
|||||||
s.config.SystemdCgroup,
|
s.config.SystemdCgroup,
|
||||||
s.platform,
|
s.platform,
|
||||||
config,
|
config,
|
||||||
|
rootfs,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errdefs.ToGRPC(err)
|
return nil, errdefs.ToGRPC(err)
|
||||||
@ -632,7 +637,7 @@ func getTopic(ctx context.Context, e interface{}) string {
|
|||||||
return runtime.TaskUnknownTopic
|
return runtime.TaskUnknownTopic
|
||||||
}
|
}
|
||||||
|
|
||||||
func newInit(ctx context.Context, path, workDir, runtimeRoot, namespace, criu string, systemdCgroup bool, platform rproc.Platform, r *proc.CreateConfig) (*proc.Init, error) {
|
func newInit(ctx context.Context, path, workDir, runtimeRoot, namespace, criu string, systemdCgroup bool, platform rproc.Platform, r *proc.CreateConfig, rootfs string) (*proc.Init, error) {
|
||||||
var options runctypes.CreateOptions
|
var options runctypes.CreateOptions
|
||||||
if r.Options != nil {
|
if r.Options != nil {
|
||||||
v, err := typeurl.UnmarshalAny(r.Options)
|
v, err := typeurl.UnmarshalAny(r.Options)
|
||||||
@ -642,7 +647,6 @@ func newInit(ctx context.Context, path, workDir, runtimeRoot, namespace, criu st
|
|||||||
options = *v.(*runctypes.CreateOptions)
|
options = *v.(*runctypes.CreateOptions)
|
||||||
}
|
}
|
||||||
|
|
||||||
rootfs := filepath.Join(path, "rootfs")
|
|
||||||
runtime := proc.NewRunc(runtimeRoot, path, namespace, r.Runtime, criu, systemdCgroup)
|
runtime := proc.NewRunc(runtimeRoot, path, namespace, r.Runtime, criu, systemdCgroup)
|
||||||
p := proc.New(r.ID, runtime, rproc.Stdio{
|
p := proc.New(r.ID, runtime, rproc.Stdio{
|
||||||
Stdin: r.Stdin,
|
Stdin: r.Stdin,
|
||||||
|
Loading…
Reference in New Issue
Block a user