File tree Expand file tree Collapse file tree
aws-lambda-java-runtime-interface-client Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2626
2727.PHONY : setup-codebuild-agent
2828setup-codebuild-agent :
29- docker build -t codebuild-agent \
29+ test/integration/codebuild-local/ docker-retry.sh docker build --load -t codebuild-agent \
3030 --build-arg ARCHITECTURE=$(ARCHITECTURE_ALIAS ) \
31- - < test/integration/codebuild-local/Dockerfile.agent
31+ -f test/integration/codebuild-local/Dockerfile.agent \
32+ test/integration/codebuild-local
3233
3334.PHONY : test-smoke
3435test-smoke : setup-codebuild-agent
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ # Copyright 2026 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
4+ set -uo pipefail
5+
6+ MAX_ATTEMPTS=" ${RETRY_MAX_ATTEMPTS:- 5} "
7+ BASE_DELAY=" ${RETRY_BASE_DELAY:- 5} "
8+ MAX_DELAY=" ${RETRY_MAX_DELAY:- 60} "
9+
10+ if (( $# == 0 )) ; then
11+ >&2 echo " usage: docker-retry.sh <command> [args...]"
12+ exit 2
13+ fi
14+
15+ attempt=1
16+ while true ; do
17+ " $@ " && exit 0
18+ status=$?
19+
20+ if (( attempt >= MAX_ATTEMPTS )) ; then
21+ >&2 echo " docker-retry: '$* ' failed after ${attempt} attempt(s) (exit ${status} ); giving up."
22+ exit " $status "
23+ fi
24+
25+ # Exponential backoff: BASE_DELAY * 2^(attempt-1), capped at MAX_DELAY.
26+ backoff=$(( BASE_DELAY * (2 ** (attempt - 1 )) ))
27+ (( backoff > MAX_DELAY )) && backoff=$MAX_DELAY
28+ # Full jitter: wait a random duration in [0, backoff] so concurrent jobs
29+ # spread out instead of retrying at the same moment.
30+ delay=$(( RANDOM % (backoff + 1 ) ))
31+
32+ >&2 echo " docker-retry: '$* ' failed (exit ${status} ); attempt ${attempt} /${MAX_ATTEMPTS} , retrying in ${delay} s."
33+ sleep " $delay "
34+ attempt=$(( attempt + 1 ))
35+ done
Original file line number Diff line number Diff line change @@ -60,14 +60,18 @@ main() {
6060
6161 ARTIFACTS_DIR=" $CODEBUILD_TEMP_DIR /artifacts"
6262 mkdir -p " $ARTIFACTS_DIR "
63+
64+ LOCAL_AGENT_IMAGE=" $( get_local_agent_image) "
65+ " $( dirname " $0 " ) " /docker-retry.sh docker pull " $LOCAL_AGENT_IMAGE " || true
66+
6367 # Run CodeBuild local agent.
6468 " $( dirname " $0 " ) " /codebuild_build.sh \
6569 -i " $CODEBUILD_IMAGE_TAG " \
6670 -a " $ARTIFACTS_DIR " \
6771 -e " $ENVFILE " \
6872 -b " $BUILDSPEC_YML " \
6973 -s " $( dirname $PWD ) " \
70- -l " $( get_local_agent_image ) "
74+ -l " $LOCAL_AGENT_IMAGE "
7175}
7276
7377main " $@ "
Original file line number Diff line number Diff line change @@ -72,7 +72,7 @@ phases:
7272 "${SCRATCH_DIR}/Dockerfile.function.${OS_DISTRIBUTION}.tmp"
7373 - echo "Building image ${IMAGE_TAG}"
7474 - >
75- docker build . \
75+ aws-lambda-java-runtime-interface-client/test/integration/codebuild-local/docker-retry.sh docker build . \
7676 -f "${SCRATCH_DIR}/Dockerfile.function.${OS_DISTRIBUTION}.tmp" \
7777 -t "${IMAGE_TAG}" \
7878 --platform="${PLATFORM}" \
Original file line number Diff line number Diff line change @@ -68,7 +68,7 @@ phases:
6868 "${SCRATCH_DIR}/Dockerfile.function.${OS_DISTRIBUTION}.tmp"
6969 - echo "Building image ${IMAGE_TAG}"
7070 - >
71- docker build . \
71+ aws-lambda-java-runtime-interface-client/test/integration/codebuild-local/docker-retry.sh docker build . \
7272 -f "${SCRATCH_DIR}/Dockerfile.function.${OS_DISTRIBUTION}.tmp" \
7373 -t "${IMAGE_TAG}" \
7474 --platform="${PLATFORM}" \
Original file line number Diff line number Diff line change @@ -55,7 +55,7 @@ phases:
5555 "${SCRATCH_DIR}/Dockerfile.function.${OS_DISTRIBUTION}.tmp"
5656 - echo "Building image ${IMAGE_TAG}"
5757 - >
58- docker build . \
58+ aws-lambda-java-runtime-interface-client/test/integration/codebuild-local/docker-retry.sh docker build . \
5959 -f "${SCRATCH_DIR}/Dockerfile.function.${OS_DISTRIBUTION}.tmp" \
6060 -t "${IMAGE_TAG}" \
6161 --build-arg RUNTIME_VERSION="${RUNTIME_VERSION}" \
Original file line number Diff line number Diff line change @@ -67,7 +67,7 @@ phases:
6767 "${SCRATCH_DIR}/Dockerfile.function.${OS_DISTRIBUTION}.tmp"
6868 - echo "Building image ${IMAGE_TAG}"
6969 - >
70- docker build . \
70+ aws-lambda-java-runtime-interface-client/test/integration/codebuild-local/docker-retry.sh docker build . \
7171 -f "${SCRATCH_DIR}/Dockerfile.function.${OS_DISTRIBUTION}.tmp" \
7272 -t "${IMAGE_TAG}" \
7373 --platform="${PLATFORM}" \
Original file line number Diff line number Diff line change @@ -71,7 +71,7 @@ phases:
7171 "${SCRATCH_DIR}/Dockerfile.function.${OS_DISTRIBUTION}.tmp"
7272 - echo "Building image ${IMAGE_TAG}"
7373 - >
74- docker build . \
74+ aws-lambda-java-runtime-interface-client/test/integration/codebuild-local/docker-retry.sh docker build . \
7575 -f "${SCRATCH_DIR}/Dockerfile.function.${OS_DISTRIBUTION}.tmp" \
7676 -t "${IMAGE_TAG}" \
7777 --platform="${PLATFORM}" \
Original file line number Diff line number Diff line change @@ -71,7 +71,7 @@ phases:
7171 "${SCRATCH_DIR}/Dockerfile.function.${OS_DISTRIBUTION}.tmp"
7272 - echo "Building image ${IMAGE_TAG}"
7373 - >
74- docker build . \
74+ aws-lambda-java-runtime-interface-client/test/integration/codebuild-local/docker-retry.sh docker build . \
7575 -f "${SCRATCH_DIR}/Dockerfile.function.${OS_DISTRIBUTION}.tmp" \
7676 -t "${IMAGE_TAG}" \
7777 --platform="${PLATFORM}" \
Original file line number Diff line number Diff line change 1515fi
1616
1717echo " Installing ${TARGET_EMULATOR} emulator"
18- docker pull public.ecr.aws/eks-distro-build-tooling/binfmt-misc:qemu-v6.1.0
18+ " $( dirname " $0 " ) " /../../codebuild-local/docker-retry.sh docker pull public.ecr.aws/eks-distro-build-tooling/binfmt-misc:qemu-v6.1.0
1919docker run --rm --privileged public.ecr.aws/eks-distro-build-tooling/binfmt-misc:qemu-v6.1.0 --install ${TARGET_EMULATOR}
2020echo " Setting docker build command to default to buildx"
2121echo " Docker buildx version: $( docker buildx version) "
You can’t perform that action at this time.
0 commit comments