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
This commit is contained in:
Felipe Reyes
2023-09-06 13:01:31 -03:00
parent a07fb4017a
commit 91c1cc3c33
+6
View File
@@ -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.