Skip to content

Commit 694ba9c

Browse files
authored
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.
2 parents 74e731f + 7def3f0 commit 694ba9c

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/ci/docker/run.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,10 @@ if [ -f "$docker_dir/$image/Dockerfile" ]; then
3636
s3url="s3://$SCCACHE_BUCKET/docker/$cksum"
3737
url="https://s3-us-west-1.amazonaws.com/$SCCACHE_BUCKET/docker/$cksum"
3838
echo "Attempting to download $s3url"
39+
rm -f /tmp/rustci_docker_cache
3940
set +e
40-
loaded_images=$(curl $url | docker load | sed 's/.* sha/sha/')
41+
retry curl -f -L -C - -o /tmp/rustci_docker_cache "$url"
42+
loaded_images=$(docker load -i /tmp/rustci_docker_cache | sed 's/.* sha/sha/')
4143
set -e
4244
echo "Downloaded containers:\n$loaded_images"
4345
fi

src/ci/shared.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@ function retry {
2121
while true; do
2222
"$@" && break || {
2323
if [[ $n -lt $max ]]; then
24+
sleep $n # don't retry immediately
2425
((n++))
2526
echo "Command failed. Attempt $n/$max:"
2627
else
2728
echo "The command has failed after $n attempts."
28-
exit 1
29+
return 1
2930
fi
3031
}
3132
done

0 commit comments

Comments
 (0)