From 3522f3fc31f0930552a7ff57b504e299158b1a98 Mon Sep 17 00:00:00 2001 From: Tomas Sebestik Date: Mon, 17 Jan 2022 07:23:03 +0100 Subject: [PATCH] Handle gitlab 404 error ci: do not retry on 404 when LOCAL_GITLAB_HTTPS_HOST not set --- tools/ci/python_packages/gitlab_api.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tools/ci/python_packages/gitlab_api.py b/tools/ci/python_packages/gitlab_api.py index 8e8df4b231..0094e20165 100644 --- a/tools/ci/python_packages/gitlab_api.py +++ b/tools/ci/python_packages/gitlab_api.py @@ -28,9 +28,16 @@ def retry(func): # type: (TR) -> TR try: res = func(self, *args, **kwargs) except (IOError, EOFError, gitlab.exceptions.GitlabError) as e: - if isinstance(e, gitlab.exceptions.GitlabError) and e.response_code != 500: - # Only retry on error 500 - raise e + if isinstance(e, gitlab.exceptions.GitlabError): + if e.response_code == 500: + # retry on this error + pass + elif e.response_code == 404 and os.environ.get('LOCAL_GITLAB_HTTPS_HOST', None): + # remove the environment variable "LOCAL_GITLAB_HTTPS_HOST" and retry + os.environ.pop('LOCAL_GITLAB_HTTPS_HOST', None) + else: + # other GitlabErrors aren't retried + raise e retried += 1 if retried > self.DOWNLOAD_ERROR_MAX_RETRIES: raise e # get out of the loop