Skip to content

Commit

Permalink
Add debug logs for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
jawadqur committed Jan 3, 2025
1 parent 4a4bc15 commit 8dcd619
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions wts/auth_plugins/k8s.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@


def get_username_from_ip(ip):
flask.current_app.logger.info("Getting username from IP {}".format(ip))
# Fail if we can't load kubernetes config...
try:
kubernetes.config.load_incluster_config()
Expand All @@ -24,14 +25,25 @@ def get_username_from_ip(ip):
pod.metadata.annotations
and POD_USERNAME_ANNOTATION in pod.metadata.annotations
):
flask.current_app.logger.info(
"Found username {} for IP {}".format(
pod.metadata.annotations[POD_USERNAME_ANNOTATION], ip
)
)
return pod.metadata.annotations[POD_USERNAME_ANNOTATION]
elif (
pod.metadata.annotations
and JUPYTER_POD_ANNOTATION in pod.metadata.annotations
):
flask.current_app.logger.info(
"Found username {} for IP {}".format(
pod.metadata.annotations[JUPYTER_POD_ANNOTATION], ip
)
)
return pod.metadata.annotations[JUPYTER_POD_ANNOTATION]

# No matching pod found
flask.current_app.logger.info("No username found for IP {}".format(ip))
return None


Expand Down

0 comments on commit 8dcd619

Please sign in to comment.