Commit 701ac72
committed
Harden cgroupv2 mounts detection by selecting the first mount
1e4a114 was filtering on the cgroupv2 device to prevent a `cgroup_mount` variable with multiline content failing downsteam without clear errors.
cilium-originating mount
```
cat /proc/self/mounts | grep cgroup2
# device mount_point fs_type dummy
cgroup2 /sys/fs/cgroup/unified cgroup2 rw,nosuid,nodev,noexec,relatime 0 0
none /run/cilium/cgroupv2 cgroup2 rw,relatime 0 0
```
however, in warden/docker stemcells, the device is cgroup, which introduced regression #637
```
cat /proc/self/mounts | grep cgroup2
# device mount_point fs_type dummy
cgroup /sys/fs/cgroup cgroup2 rw,...
```
Applying suggestion by @colins in #637 to instead rely on the chronological ordering of mount points, and select the canonical cgroup2 mount point first added by the kernel during boot process.
https://man7.org/linux/man-pages/man5/proc_pid_mounts.5.html
> /proc/self/mounts, lists the mounts of the process's own mount namespace. The format of this file is documented in [fstab(5)](https://man7.org/linux/man-pages/man5/fstab.5.html).
https://man7.org/linux/man-pages/man5/fstab.5.html
> The order of records in fstab is important because [fsck(8)](https://man7.org/linux/man-pages/man8/fsck.8.html), [mount(8)](https://man7.org/linux/man-pages/man8/mount.8.html), and [umount(8)](https://man7.org/linux/man-pages/man8/umount.8.html)
> sequentially iterate through fstab doing their thing
https://man7.org/linux/man-pages/man7/cgroups.7.html
> Note that on many modern systems, systemd(1) automatically mounts
> the cgroup2 filesystem at /sys/fs/cgroup/unified during the boot
> process.1 parent 720d3a3 commit 701ac72
1 file changed
Lines changed: 1 addition & 1 deletion
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
| 32 | + | |
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| |||
0 commit comments