From 7d5d34b7c4cab656a57d2f00c0b522165ca8ae20 Mon Sep 17 00:00:00 2001 From: Felipe Reyes Date: Thu, 20 Jan 2022 11:15:50 -0300 Subject: [PATCH] Retry find_cirros_image() on URLError (#695) There are situations where the DNS infrastructure hasn't been stable and many CI jobs have failed with the error: urllib.error.URLError: This change decorates the function find_cirros_image() to retry and give the job more chances of recovering from the DNS failures. --- zaza/openstack/utilities/openstack.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/zaza/openstack/utilities/openstack.py b/zaza/openstack/utilities/openstack.py index ca65f13..a12a1ac 100644 --- a/zaza/openstack/utilities/openstack.py +++ b/zaza/openstack/utilities/openstack.py @@ -2242,6 +2242,9 @@ def get_volumes_by_name(cinder, volume_name): return [i for i in cinder.volumes.list() if volume_name == i.name] +@tenacity.retry(wait=tenacity.wait_exponential(multiplier=1, max=60), + reraise=True, + retry=tenacity.retry_if_exception_type(urllib.error.URLError)) def find_cirros_image(arch): """Return the url for the latest cirros image for the given architecture. @@ -2268,7 +2271,7 @@ def download_image(image_url, target_file): :param image_url: URL to download image from :type image_url: str - :param target_file: Local file to savee image to + :param target_file: Local file to save image to :type target_file: str """ opener = get_urllib_opener()