diff --git a/hack/dind b/hack/dind index 456ba861a6..dbe6949792 100755 --- a/hack/dind +++ b/hack/dind @@ -62,10 +62,18 @@ if [ -f /sys/fs/cgroup/cgroup.controllers ]; then # otherwise writing subtree_control fails with EBUSY. # An error during moving non-existent process (i.e., "cat") is ignored. mkdir -p /sys/fs/cgroup/init - xargs -rn1 < /sys/fs/cgroup/cgroup.procs > /sys/fs/cgroup/init/cgroup.procs || : - # enable controllers - sed -e 's/ / +/g' -e 's/^/+/' < /sys/fs/cgroup/cgroup.controllers \ - > /sys/fs/cgroup/cgroup.subtree_control + # this happens in a loop because things like "docker exec" on our dind + # container will create new processes, which creates a race between our + # moving everything to "init" and enabling subtree_control + while ! { + # move the processes from the root group to the /init group, + # otherwise writing subtree_control fails with EBUSY. + # An error during moving non-existent process (i.e., "cat") is ignored. + xargs -rn1 < /sys/fs/cgroup/cgroup.procs > /sys/fs/cgroup/init/cgroup.procs || : + # enable controllers + sed -e 's/ / +/g' -e 's/^/+/' < /sys/fs/cgroup/cgroup.controllers \ + > /sys/fs/cgroup/cgroup.subtree_control + }; do true; done fi # Change mount propagation to shared to make the environment more similar to a