Skip to content

Commit

Permalink
Revert "PYTHON-4734 Make node download more robust" (#489)
Browse files Browse the repository at this point in the history
  • Loading branch information
blink1073 authored Sep 6, 2024
1 parent 6cc90aa commit 76ee1ac
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 75 deletions.
18 changes: 9 additions & 9 deletions .evergreen/download-mongodb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
#For future use the feed to get full list of distros : http://downloads.mongodb.org/full.json

set -o errexit # Exit the script with error if any of the commands fail
SCRIPT_DIR=$(dirname ${BASH_SOURCE[0]})
. $SCRIPT_DIR/handle-paths.sh

get_distro ()
{
Expand Down Expand Up @@ -687,6 +685,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 1 2 3; do curl --fail -sS --max-time 300 "$@" && break || sleep 5;
done
}

# download_and_extract_package downloads a MongoDB server package.
download_and_extract_package ()
Expand All @@ -703,8 +707,7 @@ download_and_extract_package ()
fi

echo "Installing server binaries..."
. "$SCRIPT_DIR/retry-with-backoff.sh"
retry_with_backoff 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."
Expand Down Expand Up @@ -735,8 +738,7 @@ download_and_extract_mongosh ()
fi

echo "Installing MongoDB shell..."
. "$SCRIPT_DIR/retry-with-backoff.sh"
retry_with_backoff curl $MONGOSH_DOWNLOAD_URL --output mongosh.tgz
curl_retry $MONGOSH_DOWNLOAD_URL --output mongosh.tgz
$EXTRACT_MONGOSH mongosh.tgz

rm -f mongosh.tgz
Expand Down Expand Up @@ -821,9 +823,7 @@ download_and_extract_crypt_shared ()
rm -rf crypt_shared_download
mkdir crypt_shared_download
cd crypt_shared_download

. "$SCRIPT_DIR/retry-with-backoff.sh"
retry_with_backoff 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"
Expand Down
17 changes: 6 additions & 11 deletions .evergreen/ensure-binary.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
# Should be called as:
# . $DRIVERS_TOOLS/.evergreen/ensure-binary.sh <binary-name>

SCRIPT_DIR=$(dirname ${BASH_SOURCE[0]})
. $SCRIPT_DIR/handle-paths.sh

NAME=$1
if [ -z "$NAME" ]; then
echo "Must supply a binary name!"
Expand All @@ -18,17 +15,15 @@ if [ -z "$DRIVERS_TOOLS" ]; then
return 1
fi

# if command -v $NAME &> /dev/null; then
# echo "$NAME found in PATH!"
# return 0
# fi
if command -v $NAME &> /dev/null; then
echo "$NAME found in PATH!"
return 0
fi

OS_NAME=$(uname -s | tr '[:upper:]' '[:lower:]')
MARCH=$(uname -m | tr '[:upper:]' '[:lower:]')
URL=""

. "$SCRIPT_DIR/retry-with-backoff.sh"

case $NAME in
kubectl)
VERSION=$(curl -L -s https://dl.k8s.io/release/stable.txt)
Expand Down Expand Up @@ -76,15 +71,15 @@ echo "Installing $NAME..."
if [ "$NAME" != "gcloud" ]; then
mkdir -p ${DRIVERS_TOOLS}/.bin
TARGET=${DRIVERS_TOOLS}/.bin/$NAME
retry_with_backoff curl -L -s $URL -o $TARGET
curl -L -s $URL -o $TARGET || curl -L $URL -o $TARGET
chmod +x $TARGET

else
# Google Cloud needs special handling: we need a symlink to the source location.
pushd /tmp
rm -rf google-cloud-sdk
FNAME=/tmp/google-cloud-sdk.tgz
retry_with_backoff curl -L -s $URL -o $FNAME
curl -L -s $URL -o $FNAME || curl -L $URL -o $FNAME
tar xfz $FNAME
popd
ln -s /tmp/google-cloud-sdk/bin/gcloud $DRIVERS_TOOLS/.bin/gcloud
Expand Down
11 changes: 5 additions & 6 deletions .evergreen/install-node.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ NODE_LTS_VERSION=${NODE_LTS_VERSION:-18}
NPM_VERSION=${NPM_VERSION:-latest}

source "./init-node-and-npm-env.sh"
source "./retry-with-backoff.sh"

if [[ -z "${npm_global_prefix}" ]]; then echo "npm_global_prefix is unset" && exit 1; fi
if [[ -z "${NODE_ARTIFACTS_PATH}" ]]; then echo "NODE_ARTIFACTS_PATH is unset" && exit 1; fi
Expand All @@ -34,7 +33,7 @@ shopt -s nocasematch
# index.tab is a sorted tab separated values file with the following headers
# 0 1 2 3 4 5 6 7 8 9 10
# version date files npm v8 uv zlib openssl modules lts security
retry_with_backoff curl "${CURL_FLAGS[@]}" "https://nodejs.org/dist/index.tab" --output node_index.tab
curl "${CURL_FLAGS[@]}" "https://nodejs.org/dist/index.tab" --output node_index.tab

while IFS=$'\t' read -r -a row; do
node_index_version="${row[0]}"
Expand All @@ -47,7 +46,7 @@ while IFS=$'\t' read -r -a row; do
[[ "$NODE_LTS_VERSION" = "$node_index_major_version" ]] && break # case insensitive compare
done < node_index.tab

if [[ "${OS:-}" = "Windows_NT" ]]; then
if [[ "$OS" = "Windows_NT" ]]; then
operating_system="win"
elif [[ $(uname) = "darwin" ]]; then
operating_system="darwin"
Expand Down Expand Up @@ -75,7 +74,7 @@ else
fi

file_extension="tar.gz"
if [[ "${OS:-}" = "Windows_NT" ]]; then file_extension="zip"; fi
if [[ "$OS" = "Windows_NT" ]]; then file_extension="zip"; fi

node_directory="node-${node_index_version}-${operating_system}-${architecture}"
node_archive="${node_directory}.${file_extension}"
Expand All @@ -90,7 +89,7 @@ if [[ "$file_extension" = "zip" ]]; then
if [[ -d "${NODE_ARTIFACTS_PATH}/nodejs/bin/${node_directory}" ]]; then
echo "Node.js already installed!"
else
retry_with_backoff curl "${CURL_FLAGS[@]}" "${node_download_url}" --output "$node_archive_path"
curl "${CURL_FLAGS[@]}" "${node_download_url}" --output "$node_archive_path"
unzip -q "$node_archive_path" -d "${NODE_ARTIFACTS_PATH}"
mkdir -p "${NODE_ARTIFACTS_PATH}/nodejs"
# Windows "bins" are at the top level
Expand All @@ -103,7 +102,7 @@ else
if [[ -d "${NODE_ARTIFACTS_PATH}/nodejs/${node_directory}" ]]; then
echo "Node.js already installed!"
else
retry_with_backoff curl "${CURL_FLAGS[@]}" "${node_download_url}" --output "$node_archive_path"
curl "${CURL_FLAGS[@]}" "${node_download_url}" --output "$node_archive_path"
tar -xf "$node_archive_path" -C "${NODE_ARTIFACTS_PATH}"
mv "${NODE_ARTIFACTS_PATH}/${node_directory}" "${NODE_ARTIFACTS_PATH}/nodejs"
fi
Expand Down
5 changes: 3 additions & 2 deletions .evergreen/k8s/configure-pod.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ echo "Waiting for pod to be ready... done."
echo "Configuring pod $POD_NAME..."
set -x
# Account for initial error in connecting to pod.
. "../retry-with-backoff.sh"
retry_with_backoff kubectl cp ./remote-scripts/setup-pod.sh ${POD_NAME}:/tmp/setup-pod.sh
CP_CMD="kubectl cp ./remote-scripts/setup-pod.sh ${POD_NAME}:/tmp/setup-pod.sh"
for i in 1 2 3; do $CP_CMD && break || sleep 5;
done
kubectl exec ${POD_NAME} -- /tmp/setup-pod.sh
kubectl exec ${POD_NAME} -- git --version
set +x
Expand Down
47 changes: 0 additions & 47 deletions .evergreen/retry-with-backoff.sh

This file was deleted.

0 comments on commit 76ee1ac

Please sign in to comment.