Skip to content

Commit

Permalink
core/mount: Only remove dirs if unmount succeeded
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
rata authored and Matteo-Pulcini committed Oct 15, 2024
1 parent da660e0 commit b20287b
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions core/mount/mount_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ func doPrepareIDMappedOverlay(lowerDirs []string, usernsFd int) (tmpLowerDirs []
// gone (eventually) and we can safely delete the directory too.
if err := unix.Unmount(lowerDir, unix.MNT_DETACH); err != nil {
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
// rootfs.
Expand Down

0 comments on commit b20287b

Please sign in to comment.