From b821b8a591d6a990a9e6cb549c21182c4beb30e9 Mon Sep 17 00:00:00 2001 From: tianj7 Date: Mon, 13 Nov 2023 13:19:27 -0600 Subject: [PATCH 1/7] fix header formatting --- src/argowrapper/routes/routes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/argowrapper/routes/routes.py b/src/argowrapper/routes/routes.py index bcf02bb..ea53549 100644 --- a/src/argowrapper/routes/routes.py +++ b/src/argowrapper/routes/routes.py @@ -151,7 +151,7 @@ def check_user_billing_id(request): remove gen3 username from pod metadata """ - header = {"Authorization", request.headers.get("Authorization")} + header = {"Authorization": request.headers.get("Authorization")} url = request.base_url._url.rstrip("/") + "/user/user" try: r = requests.get(url=url, headers=header) From e83de1e714c34353451b38412684f44bd0508946 Mon Sep 17 00:00:00 2001 From: tianj7 Date: Mon, 13 Nov 2023 13:43:13 -0600 Subject: [PATCH 2/7] add traceback to error handling --- src/argowrapper/routes/routes.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/argowrapper/routes/routes.py b/src/argowrapper/routes/routes.py index ea53549..1a82a28 100644 --- a/src/argowrapper/routes/routes.py +++ b/src/argowrapper/routes/routes.py @@ -160,6 +160,7 @@ def check_user_billing_id(request): except Exception as e: exception = Exception("Could not determine user billing info from fence", e) logger.error(exception) + traceback.print_exc() raise exception if "tags" in user_info and "billing_id" in user_info["tags"]: From 407fe5780e2ab2993ca3421c8a54b8b5cec4815a Mon Sep 17 00:00:00 2001 From: tianj7 Date: Mon, 13 Nov 2023 13:58:35 -0600 Subject: [PATCH 3/7] add logging statements for future debugging --- src/argowrapper/routes/routes.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/argowrapper/routes/routes.py b/src/argowrapper/routes/routes.py index 1a82a28..5bcd82b 100644 --- a/src/argowrapper/routes/routes.py +++ b/src/argowrapper/routes/routes.py @@ -163,10 +163,14 @@ def check_user_billing_id(request): traceback.print_exc() raise exception + logger.info("Got user info successfully. Checking for billing id..") + if "tags" in user_info and "billing_id" in user_info["tags"]: billing_id = user_info["tags"]["billing_id"] + logger.info("billing id found in user tags.") return billing_id else: + logger.info("billing id not found.") return None From 86260719200f64ef986997949004a35904583f3f Mon Sep 17 00:00:00 2001 From: tianj7 Date: Mon, 13 Nov 2023 16:00:05 -0600 Subject: [PATCH 4/7] use fence local service url --- src/argowrapper/routes/routes.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/argowrapper/routes/routes.py b/src/argowrapper/routes/routes.py index 5bcd82b..474abf6 100644 --- a/src/argowrapper/routes/routes.py +++ b/src/argowrapper/routes/routes.py @@ -152,7 +152,8 @@ def check_user_billing_id(request): """ header = {"Authorization": request.headers.get("Authorization")} - url = request.base_url._url.rstrip("/") + "/user/user" + # url = request.base_url._url.rstrip("/") + "/user/user" + url = "http://fence-service/user" try: r = requests.get(url=url, headers=header) r.raise_for_status() From dcad1682f5a7c89f35b3486909bec0b099f48eb9 Mon Sep 17 00:00:00 2001 From: tianj7 Date: Mon, 13 Nov 2023 16:15:30 -0600 Subject: [PATCH 5/7] add logging --- src/argowrapper/routes/routes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/argowrapper/routes/routes.py b/src/argowrapper/routes/routes.py index 474abf6..3d11762 100644 --- a/src/argowrapper/routes/routes.py +++ b/src/argowrapper/routes/routes.py @@ -163,7 +163,7 @@ def check_user_billing_id(request): logger.error(exception) traceback.print_exc() raise exception - + logger.info(user_info) logger.info("Got user info successfully. Checking for billing id..") if "tags" in user_info and "billing_id" in user_info["tags"]: From 398dfa0b4a1eeace54e5730777d68e8d8a46b683 Mon Sep 17 00:00:00 2001 From: tianj7 Date: Mon, 13 Nov 2023 16:37:54 -0600 Subject: [PATCH 6/7] use fence local service url --- src/argowrapper/routes/routes.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/argowrapper/routes/routes.py b/src/argowrapper/routes/routes.py index 3d11762..97f9787 100644 --- a/src/argowrapper/routes/routes.py +++ b/src/argowrapper/routes/routes.py @@ -152,7 +152,6 @@ def check_user_billing_id(request): """ header = {"Authorization": request.headers.get("Authorization")} - # url = request.base_url._url.rstrip("/") + "/user/user" url = "http://fence-service/user" try: r = requests.get(url=url, headers=header) From 7716519ca184dc661573f6d2588484a91d7e7ae3 Mon Sep 17 00:00:00 2001 From: tianj7 Date: Tue, 14 Nov 2023 10:52:27 -0600 Subject: [PATCH 7/7] optimize logging --- src/argowrapper/routes/routes.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/argowrapper/routes/routes.py b/src/argowrapper/routes/routes.py index 97f9787..38019d4 100644 --- a/src/argowrapper/routes/routes.py +++ b/src/argowrapper/routes/routes.py @@ -162,12 +162,11 @@ def check_user_billing_id(request): logger.error(exception) traceback.print_exc() raise exception - logger.info(user_info) logger.info("Got user info successfully. Checking for billing id..") if "tags" in user_info and "billing_id" in user_info["tags"]: billing_id = user_info["tags"]["billing_id"] - logger.info("billing id found in user tags.") + logger.info("billing id found in user tags: " + billing_id) return billing_id else: logger.info("billing id not found.")