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:
Georgi Sabev
2019-03-29 16:57:47 +02:00
parent e7b6fea572
commit 2a5e4c4be7
2 changed files with 14 additions and 8 deletions

View File

@@ -304,10 +304,12 @@ func (p *Init) delete(ctx context.Context) error {
}
p.io.Close()
}
if err2 := mount.UnmountAll(p.Rootfs, 0); err2 != nil {
log.G(ctx).WithError(err2).Warn("failed to cleanup rootfs mount")
if err == nil {
err = errors.Wrap(err2, "failed rootfs umount")
if p.Rootfs != "" {
if err2 := mount.UnmountAll(p.Rootfs, 0); err2 != nil {
log.G(ctx).WithError(err2).Warn("failed to cleanup rootfs mount")
if err == nil {
err = errors.Wrap(err2, "failed rootfs umount")
}
}
}
return err