Skip to content

Commit

Permalink
Merge pull request #63 from flatcar-linux/jepio/fix-cgroupv1-em
Browse files Browse the repository at this point in the history
sbin/init.wrapper: remove processes from subcgroups before deleting
  • Loading branch information
jepio authored Mar 2, 2022
2 parents e72d7a4 + 67bdb80 commit 5f97a6a
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions sbin/init.wrapper
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,25 @@ echo "(flatcar) runtime switch to legacy cgroups"

CTRL_FILE=/sys/fs/cgroup/cgroup.subtree_control
if [[ -f "${CTRL_FILE}" ]]; then
find /sys/fs/cgroup -type d -delete 2>/dev/null
find /sys/fs/cgroup/*/ -name cgroup.procs -exec grep . {} \; | \
while read pid; do
echo "$pid" >/sys/fs/cgroup/cgroup.procs 2>/dev/null
done
find /sys/fs/cgroup/*/ -type d -delete 2>/dev/null
dump=0
while read ctrl; do
echo "-${ctrl}" >"${CTRL_FILE}"
if ! echo "-${ctrl}" >"${CTRL_FILE}" ; then
dump=1
fi
done <"${CTRL_FILE}"
if [[ "${dump}" -eq 1 ]]; then
echo "failed to unbind controllers; debug dump"
echo "---"
ps faux
find /sys/fs/cgroup/ -name pids.current -exec grep -Hn . {} \;
find /sys/fs/cgroup/ -name cgroup.procs -exec grep -Hn . {} \;
echo "---"
fi
fi
umount /sys/fs/cgroup

Expand Down

0 comments on commit 5f97a6a

Please sign in to comment.