From dc31ee37ffbed323a0b6857e5741750aa749bdff Mon Sep 17 00:00:00 2001 From: mhorky Date: Mon, 23 Sep 2024 09:59:38 +0200 Subject: [PATCH] feat: Better automatic registration logging --- src/subscription_manager/scripts/rhsmcertd_worker.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/subscription_manager/scripts/rhsmcertd_worker.py b/src/subscription_manager/scripts/rhsmcertd_worker.py index 3a56e0380c..d1d4edefe4 100644 --- a/src/subscription_manager/scripts/rhsmcertd_worker.py +++ b/src/subscription_manager/scripts/rhsmcertd_worker.py @@ -292,15 +292,20 @@ def _auto_register_anonymous(uep: "UEPConnection", token: Dict[str, str]) -> Non log.debug(report) return except connection.RateLimitExceededException as exc: - if exc.headers.get("Retry-After", None) is None: + if exc.retry_after is None: + log.warning( + "Server did not include Retry-After header in rate-limited response. " + f"headers={exc.headers}" + ) raise - delay = int(exc.headers["Retry-After"]) + delay = exc.retry_after log.debug( f"Got response with status code {exc.code} and Retry-After header, " f"will try again in {delay} seconds." ) time.sleep(delay) - except Exception: + except Exception as exc: + log.warning(f"Anonymous registration failed, server returned {exc}.") raise # In theory, this should not happen, it means that something has gone wrong server-side.