From 1975fd8d875258d0b395f79ffeecfcf9f123ca76 Mon Sep 17 00:00:00 2001 From: Johannes 'fish' Ziemke Date: Sun, 31 Mar 2019 14:25:15 +0200 Subject: [PATCH] Fix cgroup hierarchy --- files/etc/init.d/k3s | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/files/etc/init.d/k3s b/files/etc/init.d/k3s index ec26df7..4edfa19 100755 --- a/files/etc/init.d/k3s +++ b/files/etc/init.d/k3s @@ -6,7 +6,21 @@ STOP=20 PIDFILE=/var/run/k3s.pid EXEC="/usr/bin/k3s" +ensure_cgroup_mount() { + # Unmount /sys/fs/cgroup if mounted as cgroup + grep ' /sys/fs/cgroup cgroup' /proc/self/mounts && umount /sys/fs/cgroup + + mount -t tmpfs -o uid=0,gid=0,mode=0755 cgroup /sys/fs/cgroup + for sys in $(awk '!/^#/ { if ($4 == 1) print $1 }' /proc/cgroups); do + mnt="/sys/fs/cgroup/$sys" + grep -q "cgroup $mnt " /proc/self/mounts && continue + mkdir -p "$mnt" + mount -n -t cgroup -o $sys cgroup "$mnt" + done +} + start() { + ensure_cgroup_mount start-stop-daemon -S -b -x "$EXEC" -m -p "$PIDFILE" \ -- server --no-deploy traefik \ --data-dir $(uci_get k3s.globals.root)