diff --git a/utilities/infra.py b/utilities/infra.py index 828d95c36c..056de71516 100644 --- a/utilities/infra.py +++ b/utilities/infra.py @@ -696,10 +696,24 @@ def download_and_extract_file_from_cluster(tmpdir, url): LOGGER.info(f"Downloading archive using: url={url}") urllib3.disable_warnings() # TODO: remove this when we fix the SSL warning local_file_name = os.path.join(tmpdir, url.split("/")[-1]) - with requests.get(url, verify=False, stream=True) as created_request: - created_request.raise_for_status() - with open(local_file_name, "wb") as file_downloaded: - file_downloaded.writelines(created_request.iter_content(chunk_size=8192)) + for sample in TimeoutSampler( + wait_timeout=TIMEOUT_2MIN, + sleep=TIMEOUT_10SEC, + func=requests.get, + exceptions_dict={ + requests.exceptions.SSLError: [], + requests.exceptions.ConnectionError: [], + requests.exceptions.Timeout: [], + }, + url=url, + verify=False, + timeout=TIMEOUT_30SEC, + ): + with sample: + sample.raise_for_status() + with open(local_file_name, "wb") as file_downloaded: + file_downloaded.write(sample.content) + break LOGGER.info("Extract the downloaded archive.") if url.endswith(zip_file_extension): archive_file_object = zipfile.ZipFile(file=local_file_name)