From a4ab403fb8cdd233e1b0b74bbb57ca48249e2ab9 Mon Sep 17 00:00:00 2001 From: "cnv-tests-github-webhook-dollierp[bot]" Date: Sun, 12 Jul 2026 15:06:07 +0300 Subject: [PATCH] CherryPicked: [cnv-4.22] Add retry for virtctl download to handle transient SSL errors (#5570) Cherry-pick from `main` branch, original PR: https://github.com/RedHatQE/openshift-virtualization-tests/pull/5355, PR owner: Ahmad-Hafe Co-authored-by: Ahmad Hafe Signed-off-by: cnv-tests-github-webhook-dollierp[bot] --- utilities/infra.py | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/utilities/infra.py b/utilities/infra.py index 63ca533edf..aa4a498327 100644 --- a/utilities/infra.py +++ b/utilities/infra.py @@ -712,6 +712,24 @@ def get_all_console_links(console_cli_downloads_spec_links): return all_urls +@retry( + wait_timeout=TIMEOUT_2MIN, + sleep=TIMEOUT_10SEC, + exceptions_dict={ + requests.exceptions.SSLError: [], + requests.exceptions.ConnectionError: [], + requests.exceptions.Timeout: [], + }, +) +def _download_file(url: str, local_file_name: str) -> str: + urllib3.disable_warnings() # TODO: remove this when we fix the SSL warning + response = requests.get(url=url, verify=False, timeout=TIMEOUT_30SEC) + response.raise_for_status() + with open(local_file_name, "wb") as file_downloaded: + file_downloaded.write(response.content) + return local_file_name + + def download_and_extract_file_from_cluster(tmpdir, url): """ Download and extract archive file from the cluster @@ -725,13 +743,8 @@ def download_and_extract_file_from_cluster(tmpdir, url): """ zip_file_extension = ".zip" 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: - for chunk in created_request.iter_content(chunk_size=8192): - file_downloaded.write(chunk) + _download_file(url=url, local_file_name=local_file_name) LOGGER.info("Extract the downloaded archive.") if url.endswith(zip_file_extension): archive_file_object = zipfile.ZipFile(file=local_file_name)