aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosh Spicer <joshspicer@github.com>2023-06-29 23:42:47 +0300
committerJosh Spicer <joshspicer@github.com>2023-06-29 23:42:47 +0300
commit3a844bf70f2ef468bd5fc969b53646171fedaf73 (patch)
tree39ced2bce6ace29a0fde934900980f91aa920210
parent4a4d289551557ad944f4db1cb9b9fe6e666368dd (diff)
add a single retry for cgroup nesting
-rwxr-xr-xsrc/docker-in-docker/install.sh33
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