diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2018-05-10 11:35:38 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-05-10 11:35:38 -0500 |
| commit | 694ba9c04b8ab1d8a76e2549b213428f093bb359 (patch) | |
| tree | 262911f5e848b72735c4086a0d95bc00e3da0bf2 | |
| parent | 74e731fcb07de3527c84e9a30821034784aa40cd (diff) | |
| parent | 7def3f0c82a95ee9147c969e94665418bf77468c (diff) | |
| download | rust-694ba9c04b8ab1d8a76e2549b213428f093bb359.tar.gz rust-694ba9c04b8ab1d8a76e2549b213428f093bb359.zip | |
Rollup merge of #50606 - kennytm:retry-docker-cache, r=alexcrichton
Retry when downloading the Docker cache. As a safety measure, prevent spuriously needing to rebuild the docker image in case the network was reset while downloading. Also, adjusted the retry function to insert a sleep between retries, because retrying immediately will often just hit the same issue.
| -rwxr-xr-x | src/ci/docker/run.sh | 4 | ||||
| -rw-r--r-- | src/ci/shared.sh | 3 |
2 files changed, 5 insertions, 2 deletions
diff --git a/src/ci/docker/run.sh b/src/ci/docker/run.sh index c470ae7eb30..3465e386cd9 100755 --- a/src/ci/docker/run.sh +++ b/src/ci/docker/run.sh @@ -36,8 +36,10 @@ if [ -f "$docker_dir/$image/Dockerfile" ]; then s3url="s3://$SCCACHE_BUCKET/docker/$cksum" url="https://s3-us-west-1.amazonaws.com/$SCCACHE_BUCKET/docker/$cksum" echo "Attempting to download $s3url" + rm -f /tmp/rustci_docker_cache set +e - loaded_images=$(curl $url | docker load | sed 's/.* sha/sha/') + retry curl -f -L -C - -o /tmp/rustci_docker_cache "$url" + loaded_images=$(docker load -i /tmp/rustci_docker_cache | sed 's/.* sha/sha/') set -e echo "Downloaded containers:\n$loaded_images" fi diff --git a/src/ci/shared.sh b/src/ci/shared.sh index 4a08683e3ee..bb6945f0fd6 100644 --- a/src/ci/shared.sh +++ b/src/ci/shared.sh @@ -21,11 +21,12 @@ function retry { while true; do "$@" && break || { if [[ $n -lt $max ]]; then + sleep $n # don't retry immediately ((n++)) echo "Command failed. Attempt $n/$max:" else echo "The command has failed after $n attempts." - exit 1 + return 1 fi } done |
