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.
This commit is contained in:
Aurelien Lourot
2021-07-20 10:37:51 +02:00
committed by GitHub
parent 67685b242b
commit 797e505f84
+2 -1
View File
@@ -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)