From 79aadf10cb8e4262947dc66871b7955ba49944b6 Mon Sep 17 00:00:00 2001 From: Tim Seagren Date: Tue, 3 Nov 2020 11:14:26 -0800 Subject: [PATCH] updating import-artifacts to fail after three retries rather than catching and exception and then immediately breaking from the while loop --- stages/import-artifacts/downloader.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/stages/import-artifacts/downloader.py b/stages/import-artifacts/downloader.py index f69761c9..438bdb4c 100644 --- a/stages/import-artifacts/downloader.py +++ b/stages/import-artifacts/downloader.py @@ -318,8 +318,9 @@ def docker_download(download_item, tag_value, tar_name, username=None, password= pull_cmd += ["--creds", f"{username}:{password}"] pull_cmd += ["--", image] + retry = True retry_count = 0 - while True: + while retry: try: subprocess.run(pull_cmd, check=True) print("Tagging image as " + tag_value) @@ -343,16 +344,16 @@ def docker_download(download_item, tag_value, tar_name, username=None, password= tar_name + ".tar", os.getenv("ARTIFACT_STORAGE") + "/import-artifacts/images/", ) + retry = False except subprocess.CalledProcessError as e: - if retry_count > 1: + if retry_count == 2: print( "Docker resource failed to pull, please check download.yaml configuration" ) sys.exit(1) else: - print(f"Docker resource failed to pull, retrying: {retry_count} /3") retry_count += 1 - break + print(f"Docker resource failed to pull, retrying: {retry_count}/2") if __name__ == "__main__": -- GitLab