From 2ed2c4f18a806754225cfbce17506ff7025834e3 Mon Sep 17 00:00:00 2001 From: Felipe Reyes Date: Wed, 6 Sep 2023 13:01:31 -0300 Subject: [PATCH] Retry on ContentTooShortError This patch makes the download_image() to retry automatically on ContentTooShortError exception, this is an issue that has been seen on the gate, see [0]. [0] https://openstack-ci-reports.ubuntu.com/artifacts/3ae/891712/3/check/focal-wallaby-pacemaker-remote-ssl_masakari/3ae840c/job-output.txt (cherry picked from commit 91c1cc3c339752377d57a2acc0e3c4355448bd1f) --- zaza/openstack/utilities/openstack.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/zaza/openstack/utilities/openstack.py b/zaza/openstack/utilities/openstack.py index 96bfd9c4e..18e88d76b 100644 --- a/zaza/openstack/utilities/openstack.py +++ b/zaza/openstack/utilities/openstack.py @@ -2254,6 +2254,12 @@ def find_ubuntu_image(release, arch): return UBUNTU_IMAGE_URLS[release].format(release=release, arch=arch) +@tenacity.retry( + wait=tenacity.wait_fixed(2), + stop=tenacity.stop_after_attempt(10), + reraise=True, + retry=tenacity.retry_if_exception_type(urllib.error.ContentTooShortError), +) def download_image(image_url, target_file): """Download the image from the given url to the specified file.