Jelajahi Sumber

Handle gitlab 404 error

Tomas Sebestik 4 tahun lalu
induk
melakukan
33edc13743
1 mengubah file dengan 10 tambahan dan 3 penghapusan
  1. 10 3
      tools/ci/python_packages/gitlab_api.py

+ 10 - 3
tools/ci/python_packages/gitlab_api.py

@@ -25,9 +25,16 @@ def retry(func: 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:
+                        # 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