diff --git a/.evergreen/download-mongodb.sh b/.evergreen/download-mongodb.sh index 5dcfa049..288accc0 100755 --- a/.evergreen/download-mongodb.sh +++ b/.evergreen/download-mongodb.sh @@ -688,6 +688,12 @@ set_url_win32 () MONGODB_24="https://fastdl.mongodb.org/win32/mongodb-win32-i386${DEBUG}-${VERSION_24}.zip" } +# curl_retry runs curl with up to three retries, retrying any error. +curl_retry () +{ + for i in 2 4 8; do curl --fail -sS --max-time 300 "$@" && break || sleep $i; + done +} # download_and_extract_package downloads a MongoDB server package. download_and_extract_package () @@ -702,7 +708,7 @@ download_and_extract_package () fi echo "Installing server binaries..." - curl $MONGODB_DOWNLOAD_URL --output mongodb-binaries.tgz + curl_retry $MONGODB_DOWNLOAD_URL --output mongodb-binaries.tgz $EXTRACT mongodb-binaries.tgz echo "Installing server binaries... done." @@ -734,7 +740,7 @@ download_and_extract_mongosh () fi echo "Installing MongoDB shell..." - curl $MONGOSH_DOWNLOAD_URL --output mongosh.tgz + curl_retry $MONGOSH_DOWNLOAD_URL --output mongosh.tgz $EXTRACT_MONGOSH mongosh.tgz rm -f mongosh.tgz @@ -817,7 +823,7 @@ download_and_extract_crypt_shared () mkdir crypt_shared_download cd crypt_shared_download - curl $MONGO_CRYPT_SHARED_DOWNLOAD_URL --output crypt_shared-binaries.tgz + curl_retry $MONGO_CRYPT_SHARED_DOWNLOAD_URL --output crypt_shared-binaries.tgz $EXTRACT crypt_shared-binaries.tgz LIBRARY_NAME="mongo_crypt_v1"