Skip to content

Commit ebfeee2

Browse files
committed
kamel: support cgroup2 build environments (cherry-pick sonic-net#1303)
This is needed for e.g. Ubuntu 22.04 build hosts.
1 parent 3b6d1f8 commit ebfeee2

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

files/docker/docker

+9-1
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,18 @@ cgroupfs_mount() {
6363
# see also https://github.com/tianon/cgroupfs-mount/blob/master/cgroupfs-mount
6464
if grep -v '^#' /etc/fstab | grep -q cgroup \
6565
|| [ ! -e /proc/cgroups ] \
66-
|| [ ! -d /sys/fs/cgroup ]; then
66+
|| [ ! -d /sys/fs/cgroup ] \
67+
|| [ "$(stat -fc '%T' /sys/fs/cgroup)" = "cgroup2fs" ]; then
6768
return
6869
fi
6970
if ! mountpoint -q /sys/fs/cgroup; then
71+
# cgroup2
72+
# https://github.com/systemd/systemd/blob/5c6c587ce24096d36826418b5390599d1e5ad55c/src/shared/cgroup-setup.c#L35-L74
73+
if awk '!/^#/ && $4 == 1 && $2 != 0 { count++ } END { exit count != 0 }' /proc/cgroups; then
74+
mount -t cgroup2 cgroup2 /sys/fs/cgroup
75+
return
76+
fi
77+
# cgroup1
7078
mount -t tmpfs -o uid=0,gid=0,mode=0755 cgroup /sys/fs/cgroup
7179
fi
7280
(

0 commit comments

Comments
 (0)