core/mount: Only remove dirs if unmount succeeded
The detached mount is less likely to fail in our case, but if we see any failure to unmount, we should just skip the removal of directories. Signed-off-by: Rodrigo Campos <rodrigoca@microsoft.com>
This commit is contained in:
parent
f8d84ecf92
commit
30f2893351
@ -255,6 +255,7 @@ func doPrepareIDMappedOverlay(lowerDirs []string, usernsFd int) (tmpLowerDirs []
|
|||||||
// gone (eventually) and we can safely delete the directory too.
|
// gone (eventually) and we can safely delete the directory too.
|
||||||
if err := unix.Unmount(lowerDir, unix.MNT_DETACH); err != nil {
|
if err := unix.Unmount(lowerDir, unix.MNT_DETACH); err != nil {
|
||||||
log.L.WithError(err).Warnf("failed to unmount temp lowerdir %s", lowerDir)
|
log.L.WithError(err).Warnf("failed to unmount temp lowerdir %s", lowerDir)
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
// Using os.Remove() so if it's not empty, we don't delete files in the
|
// Using os.Remove() so if it's not empty, we don't delete files in the
|
||||||
// rootfs.
|
// rootfs.
|
||||||
|
Loading…
Reference in New Issue
Block a user