Skip to content

Commit

Permalink
Merge pull request moby#4499 from crazy-max/fix-smoke-test
Browse files Browse the repository at this point in the history
dockerfile: mitigate flaky smoke test with timeout
  • Loading branch information
tonistiigi authored Jan 4, 2024
2 parents c7edff7 + 30e54fc commit 3c0fe5e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
10 changes: 1 addition & 9 deletions .github/workflows/buildkit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ env:
IMAGE_NAME: "moby/buildkit"
PLATFORMS: "linux/amd64,linux/arm/v7,linux/arm64,linux/s390x,linux/ppc64le,linux/riscv64"
DESTDIR: "./bin"
BUILD_TIMEOUT: "900" # 15 minutes

jobs:
prepare:
Expand Down Expand Up @@ -161,7 +160,6 @@ jobs:
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
with:
version: ${{ env.SETUP_BUILDX_VERSION }}
Expand All @@ -177,14 +175,8 @@ jobs:
-
name: Build ${{ needs.prepare.outputs.tag }}
run: |
timeout ${BUILD_TIMEOUT} ./hack/images "${{ needs.prepare.outputs.tag }}" "$IMAGE_NAME" "${{ needs.prepare.outputs.push }}"
if [ $? -eq 124 ]; then
echo "::error::Build timed out after ${BUILD_TIMEOUT} seconds"
docker kill --signal=SIGQUIT buildx_buildkit_${{ steps.buildx.outputs.name }}
exit 1
fi
./hack/images "${{ needs.prepare.outputs.tag }}" "$IMAGE_NAME" "${{ needs.prepare.outputs.push }}"
env:
BUILDX_CMD: docker --debug buildx
RELEASE: ${{ startsWith(github.ref, 'refs/tags/v') }}
TARGET: ${{ matrix.target-stage }}
CACHE_FROM: type=gha,scope=image${{ matrix.target-stage }}
Expand Down
25 changes: 24 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,30 @@ RUN --mount=target=. --mount=target=/root/.cache,type=cache \
set -ex
xx-go build ${GOBUILDFLAGS} -gcflags="${GOGCFLAGS}" -ldflags "$(cat /tmp/.ldflags) -extldflags '-static'" -tags "osusergo netgo static_build seccomp ${BUILDKITD_TAGS}" -o /usr/bin/buildkitd ./cmd/buildkitd
xx-verify ${VERIFYFLAGS} /usr/bin/buildkitd
if [ "$(xx-info os)" = "linux" ]; then /usr/bin/buildkitd --version; fi

# buildkitd --version can be flaky when running through emulation related to
# https://github.com/moby/buildkit/pull/4491. Retry a few times as a workaround.
set +ex
if [ "$(xx-info os)" = "linux" ]; then
max_retries=5
for attempt in $(seq "$max_retries"); do
timeout 3 /usr/bin/buildkitd --version
exitcode=$?
if ! xx-info is-cross; then
exit $exitcode
elif [ $exitcode -eq 0 ]; then
break
elif [ $exitcode -eq 124 ] || [ $exitcode -eq 143 ]; then
echo "WARN: buildkitd --version timed out ($attempt/$max_retries)"
if [ "$attempt" -eq "$max_retries" ]; then
exit $exitcode
fi
else
echo "ERROR: buildkitd --version failed with exit code $exitcode"
fi
sleep 1
done
fi
EOT

FROM scratch AS binaries-linux
Expand Down

0 comments on commit 3c0fe5e

Please sign in to comment.