From aadf954958c988158087af3ae3b13900388c162a Mon Sep 17 00:00:00 2001 From: Samruddhi Khandale Date: Wed, 23 Aug 2023 16:27:57 -0700 Subject: [PATCH 1/4] Create docker-in-docker-stress-test.yaml --- .../docker-in-docker-stress-test.yaml | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/workflows/docker-in-docker-stress-test.yaml diff --git a/.github/workflows/docker-in-docker-stress-test.yaml b/.github/workflows/docker-in-docker-stress-test.yaml new file mode 100644 index 000000000..11848d302 --- /dev/null +++ b/.github/workflows/docker-in-docker-stress-test.yaml @@ -0,0 +1,23 @@ +name: "Stress test - Docker in Docker" +on: + pull_request: + paths: + - 'src/docker-in-docker/**' + workflow_dispatch: + +jobs: + test: + strategy: + matrix: + test-pass: [ 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20 ] + fail-fast: false + runs-on: ubuntu-latest + continue-on-error: true + steps: + - uses: actions/checkout@v3 + + - name: "Install latest devcontainer CLI" + run: npm install -g @devcontainers/cli + + - name: "Generating tests for '${{ matrix.features }}' against '${{ matrix.baseImage }}'" + run: devcontainer features test --skip-scenarios -f docker-in-docker -i mcr.microsoft.com/devcontainers/base:debian . From 4f3263a30dea662a1d2aa824d1858d0f4efed7c0 Mon Sep 17 00:00:00 2001 From: Samruddhi Khandale Date: Wed, 23 Aug 2023 16:52:36 -0700 Subject: [PATCH 2/4] Update docker-in-docker-stress-test.yaml --- .github/workflows/docker-in-docker-stress-test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-in-docker-stress-test.yaml b/.github/workflows/docker-in-docker-stress-test.yaml index 11848d302..d561a19e9 100644 --- a/.github/workflows/docker-in-docker-stress-test.yaml +++ b/.github/workflows/docker-in-docker-stress-test.yaml @@ -19,5 +19,5 @@ jobs: - name: "Install latest devcontainer CLI" run: npm install -g @devcontainers/cli - - name: "Generating tests for '${{ matrix.features }}' against '${{ matrix.baseImage }}'" + - name: "Generating tests for 'docker-in-docker' which validates if docker daemon is available within 'onCreateCommand'" run: devcontainer features test --skip-scenarios -f docker-in-docker -i mcr.microsoft.com/devcontainers/base:debian . From 68b959efc9d188a78817abfa66adf7f4615a6e2a Mon Sep 17 00:00:00 2001 From: Samruddhi Khandale Date: Wed, 23 Aug 2023 16:54:21 -0700 Subject: [PATCH 3/4] Update install.sh --- src/docker-in-docker/install.sh | 35 +++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/src/docker-in-docker/install.sh b/src/docker-in-docker/install.sh index bdef12697..d55c45153 100755 --- a/src/docker-in-docker/install.sh +++ b/src/docker-in-docker/install.sh @@ -423,12 +423,35 @@ dockerd_start="AZURE_DNS_AUTO_DETECTION=${AZURE_DNS_AUTO_DETECTION} DOCKER_DEFAU INNEREOF )" -# Start using sudo if not invoked as root -if [ "$(id -u)" -ne 0 ]; then - sudo /bin/sh -c "${dockerd_start}" -else - eval "${dockerd_start}" -fi +retry_docker_start_count=0 +docker_ok="false" + +until [ "${docker_ok}" = "true" ] || [ "${retry_docker_start_count}" -eq "5" ]; +do + # Start using sudo if not invoked as root + if [ "$(id -u)" -ne 0 ]; then + sudo /bin/sh -c "${dockerd_start}" + else + eval "${dockerd_start}" + fi + + retry_count=0 + until [ "${docker_ok}" = "true" ] || [ "${retry_count}" -eq "5" ]; + do + set +e + docker info > /dev/null 2>&1 && docker_ok="true" + set -e + + retry_count=`expr $retry_count + 1` + sleep 1s + done + + if [ "${docker_ok}" != "true" ]; then + echo "(*) Failed to start docker, retrying..." + fi + + retry_docker_start_count=`expr $retry_docker_start_count + 1` +done # Execute whatever commands were passed in (if any). This allows us # to set this script to ENTRYPOINT while still executing the default CMD. From b37b98eadd578d0f7d9ced06a18dd476a8244a3d Mon Sep 17 00:00:00 2001 From: Samruddhi Khandale Date: Wed, 23 Aug 2023 16:54:39 -0700 Subject: [PATCH 4/4] Update test.sh --- test/docker-in-docker/test.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/docker-in-docker/test.sh b/test/docker-in-docker/test.sh index 1eebfd243..b25124cc3 100755 --- a/test/docker-in-docker/test.sh +++ b/test/docker-in-docker/test.sh @@ -8,10 +8,11 @@ source dev-container-features-test-lib # Feature specific tests check "version" docker --version check "docker-init-exists" bash -c "ls /usr/local/share/docker-init.sh" +check "docker-ps" bash -c "docker ps" check "log-exists" bash -c "ls /tmp/dockerd.log" check "log-for-completion" bash -c "cat /tmp/dockerd.log | grep 'Daemon has completed initialization'" check "log-contents" bash -c "cat /tmp/dockerd.log | grep 'API listen on /var/run/docker.sock'" -check "docker-ps" bash -c "docker ps" + # Report result -reportResults \ No newline at end of file +reportResults