From 30f28933513e62a3243b88420e00af0e1b912b13 Mon Sep 17 00:00:00 2001 From: Rodrigo Campos Date: Tue, 24 Sep 2024 17:44:52 +0200 Subject: [PATCH] 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 --- core/mount/mount_linux.go | 1 + 1 file changed, 1 insertion(+) diff --git a/core/mount/mount_linux.go b/core/mount/mount_linux.go index cd3b354cf..a14d545fd 100644 --- a/core/mount/mount_linux.go +++ b/core/mount/mount_linux.go @@ -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.