From 154fcde7d01fd53d4fd0d805b19a147dcb85a30f Mon Sep 17 00:00:00 2001 From: Yusuke Kuoka Date: Tue, 22 Nov 2022 12:08:54 +0900 Subject: [PATCH] runner: Make WAIT_FOR_DOCKER_SECONDS configurable and working (#1999) * runner: Make WAIT_FOR_DOCKER_SECONDS configurable and working Ref #1830 Ref #1804 * Update acceptance/testdata/runnerdeploy.envsubst.yaml Co-authored-by: Callum Tait <15716903+toast-gear@users.noreply.github.com> * Update docs/detailed-docs.md Co-authored-by: Callum Tait <15716903+toast-gear@users.noreply.github.com> Co-authored-by: Callum Tait <15716903+toast-gear@users.noreply.github.com> --- acceptance/testdata/runnerdeploy.envsubst.yaml | 2 ++ docs/detailed-docs.md | 6 ++++++ runner/startup.sh | 8 ++++++-- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/acceptance/testdata/runnerdeploy.envsubst.yaml b/acceptance/testdata/runnerdeploy.envsubst.yaml index 8430a4ea..17ce69e6 100644 --- a/acceptance/testdata/runnerdeploy.envsubst.yaml +++ b/acceptance/testdata/runnerdeploy.envsubst.yaml @@ -74,6 +74,8 @@ spec: value: "172.17.0.0/12" - name: DOCKER_DEFAULT_ADDRESS_POOL_SIZE value: "24" + - name: WAIT_FOR_DOCKER_SECONDS + value: "3" dockerMTU: 1400 diff --git a/docs/detailed-docs.md b/docs/detailed-docs.md index 57aa23e7..3a1bebd7 100644 --- a/docs/detailed-docs.md +++ b/docs/detailed-docs.md @@ -1576,6 +1576,12 @@ spec: # Issues a sleep command at the start of the entrypoint - name: STARTUP_DELAY_IN_SECONDS value: "2" + # Specify the duration to wait for the docker daemon to be available + # The default duration of 120 seconds is sometimes too short + # to reliably wait for the docker daemon to start + # See https://github.com/actions-runner-controller/actions-runner-controller/issues/1804 + - name: WAIT_FOR_DOCKER_SECONDS + value: 120 # Disables the wait for the docker daemon to be available check - name: DISABLE_WAIT_FOR_DOCKER value: "true" diff --git a/runner/startup.sh b/runner/startup.sh index 2e873fbf..f726a7a7 100755 --- a/runner/startup.sh +++ b/runner/startup.sh @@ -145,10 +145,14 @@ if [ -z "${UNITTEST:-}" ] && [ -e ./externalstmp ]; then mv ./externalstmp/* ./externals/ fi +WAIT_FOR_DOCKER_SECONDS=${WAIT_FOR_DOCKER_SECONDS:-120} if [[ "${DISABLE_WAIT_FOR_DOCKER}" != "true" ]] && [[ "${DOCKER_ENABLED}" == "true" ]]; then log.debug 'Docker enabled runner detected and Docker daemon wait is enabled' - log.debug 'Waiting until Docker is available or the timeout is reached' - timeout 120s bash -c 'until docker ps ;do sleep 1; done' + log.debug "Waiting until Docker is available or the timeout of ${WAIT_FOR_DOCKER_SECONDS} seconds is reached" + if ! timeout "${WAIT_FOR_DOCKER_SECONDS}s" bash -c 'until docker ps ;do sleep 1; done'; then + log.notice "Docker has not become available within ${WAIT_FOR_DOCKER_SECONDS} seconds. Exiting with status 1." + exit 1 + fi else log.notice 'Docker wait check skipped. Either Docker is disabled or the wait is disabled, continuing with entrypoint' fi