Skip to content

Commit 816c214

Browse files
committed
fix: backoff delay if rate is exceeded
1 parent d380c4b commit 816c214

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

tests/integration/codebuild-local/test_one.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,22 @@ function usage {
1717
>&2 echo " env Additional environment variables file."
1818
}
1919

20+
function pull_with_retry() {
21+
local image="$1"
22+
local max_retries=3
23+
local wait=10
24+
for attempt in $(seq 1 $max_retries); do
25+
if docker pull "$image"; then
26+
return 0
27+
fi
28+
>&2 echo "Docker pull attempt $attempt/$max_retries failed. Retrying in ${wait}s..."
29+
sleep $wait
30+
wait=$((wait * 2))
31+
done
32+
>&2 echo "Failed to pull $image after $max_retries attempts."
33+
return 1
34+
}
35+
2036
main() {
2137
if (( $# != 3 && $# != 4)); then
2238
>&2 echo "Invalid number of parameters."
@@ -49,6 +65,9 @@ main() {
4965
ARTIFACTS_DIR="$CODEBUILD_TEMP_DIR/artifacts"
5066
mkdir -p "$ARTIFACTS_DIR"
5167

68+
# Pre-pull the CodeBuild local agent image with retries to handle ECR rate limits.
69+
pull_with_retry "public.ecr.aws/codebuild/local-builds:latest"
70+
5271
# Run CodeBuild local agent.
5372
"$(dirname "$0")"/codebuild_build.sh \
5473
-i "$CODEBUILD_IMAGE_TAG" \

0 commit comments

Comments
 (0)