From 5a3fb2c2c90db612b6ae2de27915d9cd531c5125 Mon Sep 17 00:00:00 2001 From: Gustavo Trott Date: Tue, 27 Aug 2024 21:25:06 -0300 Subject: [PATCH] bypass build error: toomanyrequests: You have reached your pull rate limit. --- build/setup.sh | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/build/setup.sh b/build/setup.sh index 4cf30cdffe..181ab0b7fc 100755 --- a/build/setup.sh +++ b/build/setup.sh @@ -51,13 +51,36 @@ kill_docker() { trap 'kill_docker' SIGINT SIGTERM +# Try to pull Docker Image 5 times (to bypass "toomanyrequests: You have reached your pull rate limit." error) +retry_count=0 +max_retries=5 +retry_wait=300 # wait time in seconds (5 minutes) + +while [[ $retry_count -lt $max_retries ]]; do + if sudo docker pull "$DOCKER_IMAGE"; then + echo "Docker image pulled successfully." + break + else + echo "Failed to pull Docker image, attempt $((retry_count+1))/$max_retries." + ((retry_count++)) + if [[ $retry_count -lt $max_retries ]]; then + echo "Waiting for $retry_wait seconds before retrying..." + sleep $retry_wait + else + echo "Exceeded maximum retry attempts. Exiting." + exit 1 + fi + fi +done + + # -v "$CACHE_DIR/dev":/root/dev sudo docker run --rm --detach --cidfile $DOCKER_CONTAINER_ID_FILE \ --env GIT_REV=$GIT_REV --env COMMIT_DATE=$COMMIT_DATE --env LOCAL_BUILD=$LOCAL_BUILD \ --mount type=bind,src="$PWD",dst=/mnt \ --mount type=bind,src="${PWD}/artifacts,dst=/artifacts" \ -t "$DOCKER_IMAGE" /mnt/build/setup-inside-docker.sh "$PACKAGE_TO_BUILD" - + # -v "$CACHE_DIR/$DISTRO/.gradle:/root/.gradle" \ # -v "$CACHE_DIR/$DISTRO/.grails:/root/.grails" \ # -v "$CACHE_DIR/$DISTRO/.ivy2:/root/.ivy2" \