From 28b25e4e20f19aef0e832b776274449d9c6ff85d Mon Sep 17 00:00:00 2001 From: Dejan Benedik Date: Fri, 2 Aug 2024 11:20:21 +0200 Subject: [PATCH] fix: busybox xargs unlinked on new k3s releases Since rancher/k3s:v1.30.3-k3s1, busybox xargs has been unlinked in favour of findutils xargs, see https://github.com/k3s-io/k3s-root/pull/65. Fixes #1478 --- pkg/types/fixes/assets/k3d-entrypoint-cgroupv2.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pkg/types/fixes/assets/k3d-entrypoint-cgroupv2.sh b/pkg/types/fixes/assets/k3d-entrypoint-cgroupv2.sh index e6a0790d0..969d165cc 100755 --- a/pkg/types/fixes/assets/k3d-entrypoint-cgroupv2.sh +++ b/pkg/types/fixes/assets/k3d-entrypoint-cgroupv2.sh @@ -11,10 +11,15 @@ set -o nounset ######################################################################################################################################### if [ -f /sys/fs/cgroup/cgroup.controllers ]; then echo "[$(date -Iseconds)] [CgroupV2 Fix] Evacuating Root Cgroup ..." - # move the processes from the root group to the /init group, + # move the processes from the root group to the /init group, # otherwise writing subtree_control fails with EBUSY. mkdir -p /sys/fs/cgroup/init - busybox xargs -rn1 < /sys/fs/cgroup/cgroup.procs > /sys/fs/cgroup/init/cgroup.procs || : + # new k3s releases only have xargs from findutils + if command -v xargs >/dev/null; then + xargs -rn1 /sys/fs/cgroup/init/cgroup.procs || : + else + busybox xargs -rn1 /sys/fs/cgroup/init/cgroup.procs || : + fi # enable controllers sed -e 's/ / +/g' -e 's/^/+/' <"/sys/fs/cgroup/cgroup.controllers" >"/sys/fs/cgroup/cgroup.subtree_control" echo "[$(date -Iseconds)] [CgroupV2 Fix] Done"