From 91c1cc3c339752377d57a2acc0e3c4355448bd1f 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 --- 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 d98e1a7da..36279e691 100644 --- a/zaza/openstack/utilities/openstack.py +++ b/zaza/openstack/utilities/openstack.py @@ -2398,6 +2398,12 @@ def find_ubuntu_image(release, arch): return loc_str.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.