Skip to content

Commit 92357d9

Browse files
Himani Anil Deshpandehimani2411
authored andcommitted
[develop][cli] Use retry loop with curl as --retry-all-errors is available in curl v7.71+
* curl 7.71 is available in all OS except rhel8 and rocky8 * applying the same exponential backoff as with previous change where we wait at max (1 + 2 + 4 + 8 + 16 + 32 + 64 + 128 + 256 = 511 seconds) of 8.51 minutes
1 parent cab50e5 commit 92357d9

4 files changed

Lines changed: 24 additions & 4 deletions

File tree

cli/src/pcluster/resources/compute_node/user_data.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,12 @@ write_files:
137137
error_exit "This AMI was not baked by ParallelCluster. Please use pcluster build-image command to create an AMI by providing your AMI as parent image."
138138
fi
139139
if [ "${!custom_cookbook}" != "NONE" ]; then
140-
curl --retry 9 --retry-all-errors -v -L -o /etc/chef/aws-parallelcluster-cookbook.tgz ${!cookbook_url}
140+
delays=(1 2 4 8 16 32 64 128 256)
141+
for i in {0..8}; do
142+
curl -v -L -o /etc/chef/aws-parallelcluster-cookbook.tgz ${!cookbook_url} && break
143+
echo "Curl attempt $((i+1)) failed, retrying in ${!delays[$i]}s..."
144+
sleep ${!delays[$i]}
145+
done
141146
vendor_cookbook
142147
fi
143148
cd /tmp

cli/src/pcluster/resources/head_node/user_data.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,12 @@ else
123123
error_exit "This AMI was not baked by ParallelCluster. Please use pcluster build-image command to create an AMI by providing your AMI as parent image."
124124
fi
125125
if [ "${!custom_cookbook}" != "NONE" ]; then
126-
curl --retry 9 --retry-all-errors -v -L -o /etc/chef/aws-parallelcluster-cookbook.tgz ${!cookbook_url}
126+
delays=(1 2 4 8 16 32 64 128 256)
127+
for i in {0..8}; do
128+
curl -v -L -o /etc/chef/aws-parallelcluster-cookbook.tgz ${!cookbook_url} && break
129+
echo "Curl attempt $((i+1)) failed, retrying in ${!delays[$i]}s..."
130+
sleep ${!delays[$i]}
131+
done
127132
vendor_cookbook
128133
fi
129134

cli/src/pcluster/resources/imagebuilder/parallelcluster.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,12 @@ phases:
219219
220220
# Download cookbook
221221
mkdir -p /etc/chef && sudo chown -R root:root /etc/chef
222-
curl --retry 9 --retry-all-errors -L -o /etc/chef/aws-parallelcluster-cookbook.tgz "$COOKBOOK_URL"
222+
delays=(1 2 4 8 16 32 64 128 256)
223+
for i in {0..8}; do
224+
curl -L -o /etc/chef/aws-parallelcluster-cookbook.tgz "$COOKBOOK_URL" && break
225+
echo "Curl attempt $((i+1)) failed, retrying in ${!delays[$i]}s..."
226+
sleep ${!delays[$i]}
227+
done
223228
224229
cd /etc/chef && tar -xzf /etc/chef/aws-parallelcluster-cookbook.tgz --strip-components 1 && rm -f aws-parallelcluster-cookbook.tgz
225230

cli/src/pcluster/resources/login_node/user_data.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,12 @@ write_files:
120120
error_exit "This AMI was not baked by ParallelCluster. Please use pcluster build-image command to create an AMI by providing your AMI as parent image."
121121
fi
122122
if [ "${!custom_cookbook}" != "NONE" ]; then
123-
curl --retry 9 --retry-all-errors -v -L -o /etc/chef/aws-parallelcluster-cookbook.tgz ${!cookbook_url}
123+
delays=(1 2 4 8 16 32 64 128 256)
124+
for i in {0..8}; do
125+
curl -v -L -o /etc/chef/aws-parallelcluster-cookbook.tgz ${!cookbook_url} && break
126+
echo "Curl attempt $((i+1)) failed, retrying in ${!delays[$i]}s..."
127+
sleep ${!delays[$i]}
128+
done
124129
vendor_cookbook
125130
fi
126131
cd /tmp

0 commit comments

Comments
 (0)