From 797e505f8401ba78313a77aea7fd4b0b0584463c Mon Sep 17 00:00:00 2001 From: Aurelien Lourot Date: Tue, 20 Jul 2021 10:37:51 +0200 Subject: [PATCH] Add connection timeout to CirrOS image download (#604) Without this timeout it has been observed that Zaza may hang forever on open(). It is better to fail faster and save time and resources. --- zaza/openstack/utilities/openstack.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/zaza/openstack/utilities/openstack.py b/zaza/openstack/utilities/openstack.py index 3082068..a5ba6f6 100644 --- a/zaza/openstack/utilities/openstack.py +++ b/zaza/openstack/utilities/openstack.py @@ -2194,8 +2194,9 @@ def find_cirros_image(arch): :returns: URL for latest cirros image :rtype: str """ + http_connection_timeout = 10 # seconds opener = get_urllib_opener() - f = opener.open(CIRROS_RELEASE_URL) + f = opener.open(CIRROS_RELEASE_URL, timeout=http_connection_timeout) version = f.read().strip().decode() cirros_img = 'cirros-{}-{}-disk.img'.format(version, arch) return '{}/{}/{}'.format(CIRROS_IMAGE_URL, version, cirros_img)