diff options
author | Josh Spicer <joshspicer@github.com> | 2023-06-29 23:42:47 +0300 |
---|---|---|
committer | Josh Spicer <joshspicer@github.com> | 2023-06-29 23:42:47 +0300 |
commit | 3a844bf70f2ef468bd5fc969b53646171fedaf73 (patch) | |
tree | 39ced2bce6ace29a0fde934900980f91aa920210 | |
parent | 4a4d289551557ad944f4db1cb9b9fe6e666368dd (diff) |
add a single retry for cgroup nesting
-rwxr-xr-x | src/docker-in-docker/install.sh | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/src/docker-in-docker/install.sh b/src/docker-in-docker/install.sh index b4c9bd2..c11c074 100755 --- a/src/docker-in-docker/install.sh +++ b/src/docker-in-docker/install.sh @@ -372,17 +372,30 @@ dockerd_start="AZURE_DNS_AUTO_DETECTION=${AZURE_DNS_AUTO_DETECTION} DOCKER_DEFAU mount -t tmpfs none /tmp fi - # cgroup v2: enable nesting - if [ -f /sys/fs/cgroup/cgroup.controllers ]; then - # 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. - 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 + set_cgroup_nesting() + { + # cgroup v2: enable nesting + if [ -f /sys/fs/cgroup/cgroup.controllers ]; then + # 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. + 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 + fi + } + + # Set cgroup nesting, retrying if necessary + set +e + set_cgroup_nesting + if [ $? -ne 0 ]; then + echo >&2 "cgroup v2: failed to enable nesting, retrying once..." + set_cgroup_nesting fi + set -e + # -- End: dind wrapper script -- # Handle DNS |