From bb3425110fbd872bfde301713ba0313470d08351 Mon Sep 17 00:00:00 2001 From: Himani Anil Deshpande Date: Wed, 31 Dec 2025 14:57:44 -0500 Subject: [PATCH] [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 --- cli/src/pcluster/resources/compute_node/user_data.sh | 7 ++++++- cli/src/pcluster/resources/head_node/user_data.sh | 7 ++++++- .../pcluster/resources/imagebuilder/parallelcluster.yaml | 7 ++++++- cli/src/pcluster/resources/login_node/user_data.sh | 7 ++++++- 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/cli/src/pcluster/resources/compute_node/user_data.sh b/cli/src/pcluster/resources/compute_node/user_data.sh index 76a5c7dfb3..a3ec97c5c5 100644 --- a/cli/src/pcluster/resources/compute_node/user_data.sh +++ b/cli/src/pcluster/resources/compute_node/user_data.sh @@ -137,7 +137,12 @@ write_files: 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." fi if [ "${!custom_cookbook}" != "NONE" ]; then - curl --retry 9 --retry-all-errors -v -L -o /etc/chef/aws-parallelcluster-cookbook.tgz ${!cookbook_url} + delays=(1 2 4 8 16 32 64 128 256) + for i in {0..8}; do + curl -v -L -o /etc/chef/aws-parallelcluster-cookbook.tgz ${!cookbook_url} && break + echo "Curl attempt $((i+1)) failed, retrying in ${!delays[$i]}s..." + sleep ${!delays[$i]} + done vendor_cookbook fi cd /tmp diff --git a/cli/src/pcluster/resources/head_node/user_data.sh b/cli/src/pcluster/resources/head_node/user_data.sh index f93a060111..9deaa8be25 100644 --- a/cli/src/pcluster/resources/head_node/user_data.sh +++ b/cli/src/pcluster/resources/head_node/user_data.sh @@ -123,7 +123,12 @@ else 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." fi if [ "${!custom_cookbook}" != "NONE" ]; then - curl --retry 9 --retry-all-errors -v -L -o /etc/chef/aws-parallelcluster-cookbook.tgz ${!cookbook_url} + delays=(1 2 4 8 16 32 64 128 256) + for i in {0..8}; do + curl -v -L -o /etc/chef/aws-parallelcluster-cookbook.tgz ${!cookbook_url} && break + echo "Curl attempt $((i+1)) failed, retrying in ${!delays[$i]}s..." + sleep ${!delays[$i]} + done vendor_cookbook fi diff --git a/cli/src/pcluster/resources/imagebuilder/parallelcluster.yaml b/cli/src/pcluster/resources/imagebuilder/parallelcluster.yaml index a89cc3d5eb..c476a5e304 100644 --- a/cli/src/pcluster/resources/imagebuilder/parallelcluster.yaml +++ b/cli/src/pcluster/resources/imagebuilder/parallelcluster.yaml @@ -219,7 +219,12 @@ phases: # Download cookbook mkdir -p /etc/chef && sudo chown -R root:root /etc/chef - curl --retry 9 --retry-all-errors -L -o /etc/chef/aws-parallelcluster-cookbook.tgz "$COOKBOOK_URL" + delays=(1 2 4 8 16 32 64 128 256) + for i in {0..8}; do + curl -L -o /etc/chef/aws-parallelcluster-cookbook.tgz "$COOKBOOK_URL" && break + echo "Curl attempt $((i+1)) failed, retrying in ${!delays[$i]}s..." + sleep ${!delays[$i]} + done cd /etc/chef && tar -xzf /etc/chef/aws-parallelcluster-cookbook.tgz --strip-components 1 && rm -f aws-parallelcluster-cookbook.tgz diff --git a/cli/src/pcluster/resources/login_node/user_data.sh b/cli/src/pcluster/resources/login_node/user_data.sh index 372012d10a..01ca2a3807 100644 --- a/cli/src/pcluster/resources/login_node/user_data.sh +++ b/cli/src/pcluster/resources/login_node/user_data.sh @@ -120,7 +120,12 @@ write_files: 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." fi if [ "${!custom_cookbook}" != "NONE" ]; then - curl --retry 9 --retry-all-errors -v -L -o /etc/chef/aws-parallelcluster-cookbook.tgz ${!cookbook_url} + delays=(1 2 4 8 16 32 64 128 256) + for i in {0..8}; do + curl -v -L -o /etc/chef/aws-parallelcluster-cookbook.tgz ${!cookbook_url} && break + echo "Curl attempt $((i+1)) failed, retrying in ${!delays[$i]}s..." + sleep ${!delays[$i]} + done vendor_cookbook fi cd /tmp