From 9520c83da90adb4d0fd0e338e96a30c76a28cca2 Mon Sep 17 00:00:00 2001 From: Seth Foster Date: Fri, 30 May 2025 13:37:14 -0400 Subject: [PATCH] Restore basic auth for subscriptions API Fallback to basic auth if OAUTH to console.redhat.com fails Notes: Envoy has a timeout of 30 seconds, so the total timeout should be less than that. (5, 20) means 5 seconds to connect to server, 20 seconds to start reading data. Signed-off-by: Seth Foster --------- Signed-off-by: Seth Foster --- awx/main/utils/licensing.py | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/awx/main/utils/licensing.py b/awx/main/utils/licensing.py index 2110bab5da..2df0a07e5e 100644 --- a/awx/main/utils/licensing.py +++ b/awx/main/utils/licensing.py @@ -243,14 +243,23 @@ class Licenser(object): return [] def get_rhsm_subs(self, host, client_id, client_secret): - client = OIDCClient(client_id, client_secret) - subs = client.make_request( - 'GET', - host, - verify=True, - timeout=(31, 31), - ) - + try: + client = OIDCClient(client_id, client_secret) + subs = client.make_request( + 'GET', + host, + verify=True, + timeout=(5, 20), + ) + except requests.RequestException: + logger.warning("Failed to connect to console.redhat.com using Service Account credentials. Falling back to basic auth.") + subs = requests.request( + 'GET', + host, + auth=(client_id, client_secret), + verify=True, + timeout=(5, 20), + ) subs.raise_for_status() subs_formatted = [] for sku in subs.json()['body']: