Commit Graph

9 Commits

Author SHA1 Message Date
Rodrigo Campos
30f2893351 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>
2024-09-24 17:45:34 +02:00
Rodrigo Campos
f8d84ecf92 core/mount: Prevent accidental removal of rootfs files
Using os.RemoveAll() is quite risky, as if the unmount failed and we
can delete files from the container rootfs. In fact, we were doing just
that.

Let's use os.Remove() to make sure we only deleted empty dirs.

Big kudos to @mbaynton for reporting this issue with lot of details,
nailing it down to containerd lines of code and showing all the log
lines to understand the big picture.

Fixes: #10704

Signed-off-by: Rodrigo Campos <rodrigoca@microsoft.com>
2024-09-24 17:45:34 +02:00
Rodrigo Campos
004f3951d5 core/mount: Use MNT_DETACH for umount of tmp layers
Overlayfs needs to do an idmap mount of each layer and the cleanup
function just unmounts and deletes the directories. However, when the
resource is busy, the umount fails.

Let's make the unmount detached so the unmount will eventually be done
when it's not busy anymore. Also, making it detached solves the issues with
the unmount failing because it is busy.

Big kudos to @mbaynton for reporting this issue with lot of details,
nailing it down to containerd lines of code and showing all the log
lines to understand the big picture.

Fixes: #10704

Signed-off-by: Rodrigo Campos <rodrigoca@microsoft.com>
2024-09-24 17:34:52 +02:00
Marat Radchenko
bfc1465a2c Reorganize mount/unmount code so it is easier to add Darwin-specific implementation
After these changes, in order to add Darwin bind-mount implementation, one only needs:
* Adjust HasBindMounts definition in mount.go
* Provide implementation in mount_darwin.go

There was no consensus on adding dependency on bindfs, that seems to be the only working solution for bind-mounts on Darwin as of today, in https://github.com/containerd/containerd/pull/8789, that's why the actual implementation is not added in current PR.

As a bonus, Linux FUSE-related code was moved to a separate file and possibly could be reused on FreeBSD, though this needs testing.

Signed-off-by: Marat Radchenko <marat@slonopotamus.org>
2024-08-30 15:25:06 +03:00
Sebastiaan van Stijn
9776047243
migrate to github.com/moby/sys/userns
Commit 8437c567d8 migrated the use of the
userns package to the github.com/moby/sys/user module.

After further discussion with maintainers, it was decided to move the
userns package to a separate module, as it has no direct relation with
"user" operations (other than having "user" in its name).

This patch migrates our code to use the new module.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-08-08 12:48:54 +02:00
Sebastiaan van Stijn
8437c567d8
pkg/userns: deprecate and migrate to github.com/moby/sys/user/userns
The userns package in libcontainer was integrated into the moby/sys/user
module at commit [3778ae603c706494fd1e2c2faf83b406e38d687d][1].

This patch deprecates the containerd fork of that package, and adds it as
an alias for the moby/sys/user/userns package.

[1]: 3778ae603c

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-26 09:47:50 +02:00
Sebastiaan van Stijn
ed64e6503a
core/mount: remove logrus import
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-17 12:40:18 +02:00
Swagat Bora
0597317759 Preserve CL_UNPRIVILEGED locked flags during remount of bind mounts
Signed-off-by: Swagat Bora <sbora@amazon.com>
2024-05-10 00:31:21 +00:00
Derek McGowan
6e5408dcec
Move mount to core/mount
Signed-off-by: Derek McGowan <derek@mcg.dev>
2024-01-17 09:52:12 -08:00