Skip to content
This repository has been archived by the owner on Jan 4, 2024. It is now read-only.

Commit

Permalink
Improve logging in spawner get_url method
Browse files Browse the repository at this point in the history
It's normal for retrieving the lab URL to raise MissingFieldError
if the lab is still in the process of spawning. Handle that explicitly
and log it only at info level. Use a better log message for get_url
exceptions.
  • Loading branch information
rra committed May 25, 2023
1 parent 32ba4ca commit ca4fda0
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/rsp_restspawner/spawner.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,21 @@ async def get_url(self) -> str:
"""
try:
return await self._get_internal_url()
except MissingFieldError:
# This is normal if the lab is currently being spawned or deleted
# when JupyterHub asks for its URL. Tell JupyterHub to use the
# stored URL.
msg = (
f"Lab for {self.user.name} has no URL (possibly still"
" spawning), falling back on stored URL"
)
self.log.info(msg)
return await super().get_url()
except Exception:
msg = f"Unable to get URL of running lab for {self.user.name}"
msg = (
f"Unable to get URL of running lab for {self.user.name},"
" falling back on stored URL"
)
self.log.exception(msg)
return await super().get_url()

Expand Down

0 comments on commit ca4fda0

Please sign in to comment.