Skip to content

Commit 7def3f0

Browse files
committed
Retry when downloading the Docker cache.
Prevent spuriously needing to rebuild the docker image when the network was down. Also, adjusted the retry function to insert a sleep between retries, because retrying immediately will often just hit the same issue.
1 parent 95d0b9e commit 7def3f0

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)