Skip to content

Commit bdd8140

Browse files
authored
Make curl operations resilient to network issues
Retry all curl operations by default. Also don't rely on outdated system packages for pip3 but install it locally. Relates elastic#141
1 parent 497df43 commit bdd8140

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

night_rally/fixtures/ansible/Vagrantfile

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@ rally_repo = ENV.fetch("RALLY_REPO", "https://github.com/elastic/rally.git")
3535
rally_branch = ENV.fetch("RALLY_BRANCH", "master")
3636
rally_sha = ENV.fetch("RALLY_SHA", "")
3737

38+
def curl_wrapper(max_time=10, retry_max_time=100, silent=true)
39+
# Return a curl command prefix that always retries on failure
40+
basic_command = "curl -SfL --connect-timeout 5 --max-time #{max_time} --retry 5 --retry-max-time #{retry_max_time}"
41+
if silent
42+
return basic_command << " -s"
43+
else
44+
return basic_command
45+
end
46+
end
47+
3848
def rally_sudoers
3949
# Use single quotes to avoid interpolating EOF2 intended for bash
4050
# tilde before 'EOF' allows indenting heredoc without passing the extra leading spaces to actual bash command
@@ -79,22 +89,26 @@ def install_vault
7989
<<~EOF
8090
set -eo pipefail
8191
CUR_HOME=$HOME
82-
curl -fsS -o ${CUR_HOME}/vault.zip https://releases.hashicorp.com/vault/1.1.1/vault_1.1.1_linux_amd64.zip
92+
#{curl_wrapper} -o ${CUR_HOME}/vault.zip https://releases.hashicorp.com/vault/1.1.1/vault_1.1.1_linux_amd64.zip
8393
sudo unzip ${CUR_HOME}/vault.zip -d /usr/local/bin
8494
sudo chmod +x /usr/local/bin/vault
8595
rm ${CUR_HOME}/vault.zip
8696
EOF
8797
end
8898

8999
def install_rally_source(rally_repo, rally_branch, rally_sha)
100+
# Remove OS packages for python3-pip and python3-setuptools; we prefer per account installation of pip3
90101
<<~EOF
91102
set -eo pipefail
92103
apt-get update
104+
apt-get purge -y python3\*-pip python3\*-setuptools
93105
apt-get install -y python-virtualenv
94-
apt-get install -y python3-pip
106+
apt-get install -y python3-dev
95107
sudo -iu jenkins bash -c '
96-
pip3 install --user setuptools;
97108
cd /var/lib/jenkins;
109+
#{curl_wrapper} https://bootstrap.pypa.io/get-pip.py -o get-pip.py;
110+
python3 get-pip.py --user;
111+
rm get-pip.py;
98112
mkdir src bin;
99113
cd src;
100114
git clone #{rally_repo} --branch #{rally_branch};
@@ -162,11 +176,11 @@ end
162176
def install_java(major_ver)
163177
<<~EOF
164178
set -eo pipefail
165-
jdk_url=$(curl -fsSL https://jvm-catalog.elastic.co/jdk/latest_openjdk_#{major_ver}_linux | jq -r .url)
179+
jdk_url=$(#{curl_wrapper} https://jvm-catalog.elastic.co/jdk/latest_openjdk_#{major_ver}_linux | jq -r .url)
166180
cd /var/lib/jenkins
167181
mkdir -p .java/openjdk#{major_ver}
168182
cd .java/openjdk#{major_ver}
169-
curl --progress-bar -fSL -o java#{major_ver}.tgz $jdk_url
183+
#{curl_wrapper(max_time=300,retry_max_time=1800,silent=false)} --progress-bar -o java#{major_ver}.tgz $jdk_url
170184
tar zxf java#{major_ver}.tgz --strip-components=1
171185
rm -f java#{major_ver}.tgz
172186
cd ../../

0 commit comments

Comments
 (0)