From 1f5408254b5d4c0aad7f38ed000f428a49cc67eb Mon Sep 17 00:00:00 2001 From: k8s-infra-cherrypick-robot <90416843+k8s-infra-cherrypick-robot@users.noreply.github.com> Date: Thu, 14 Dec 2023 08:37:19 -0800 Subject: [PATCH] retry ubuntu image download on temp error (#2506) Co-authored-by: kayrus --- tests/playbooks/roles/install-k3s/tasks/main.yaml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/playbooks/roles/install-k3s/tasks/main.yaml b/tests/playbooks/roles/install-k3s/tasks/main.yaml index b759f4cd49..cd9acb7675 100644 --- a/tests/playbooks/roles/install-k3s/tasks/main.yaml +++ b/tests/playbooks/roles/install-k3s/tasks/main.yaml @@ -16,8 +16,17 @@ set +x; source openrc admin admin > /dev/null; set -x openstack image show {{ image_name }} > /dev/null 2>&1 + if [[ "$?" != "0" ]]; then - curl -sSL {{ image_url }} -o {{ image_name }}.img + # retry ubuntu image download on failure, + # e.g. "curl: (35) OpenSSL SSL_connect: Connection reset by peer in connection to cloud-images.ubuntu.com:443" + tries=0 + until [ "$tries" -ge 5 ]; do + curl -sSL {{ image_url }} -o {{ image_name }}.img && break + echo "Error downloading an image" + ((tries++)) + sleep 10 + done openstack image create {{ image_name }} --container-format bare --disk-format qcow2 --public --file {{ image_name }}.img fi