From 58036eab84a7f55994c8a332da70542c94d3ae7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= Date: Tue, 28 Feb 2023 10:14:02 +0100 Subject: [PATCH] Retry 401 error from CTS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This could be a transient error caused by kerberos server instability. JIRA: RHELCMP-11251 Signed-off-by: Lubomír Sedlář --- pungi/compose.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/pungi/compose.py b/pungi/compose.py index a978c709..fa59d27a 100644 --- a/pungi/compose.py +++ b/pungi/compose.py @@ -58,11 +58,22 @@ except ImportError: SUPPORTED_MILESTONES = ["RC", "Update", "SecurityFix"] +def is_status_fatal(status_code): + """Check if status code returned from CTS reports an error that is unlikely + to be fixed by retrying. Generally client errors (4XX) are fatal, with the + exception of 401 Unauthorized which could be caused by transient network + issue between compose host and KDC. + """ + if status_code == 401: + return False + return status_code >= 400 and status_code < 500 + + @retry(wait_on=RequestException) def retry_request(method, url, data=None, auth=None): request_method = getattr(requests, method) rv = request_method(url, json=data, auth=auth) - if rv.status_code >= 400 and rv.status_code < 500: + if is_status_fatal(rv.status_code): try: error = rv.json()["message"] except ValueError: