Skip to content

Commit

Permalink
Merge pull request #4814 from minrk/activity-warning
Browse files Browse the repository at this point in the history
quieter logging in activity-reporting when hub is temporarily unavailable
  • Loading branch information
minrk committed May 13, 2024
2 parents 95d479a + ea73931 commit 06c8d22
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions jupyterhub/singleuser/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,9 +412,12 @@ async def notify_activity(self):
return

last_activity_timestamp = isoformat(last_activity)
failure_count = 0

async def notify():
nonlocal failure_count
self.log.debug("Notifying Hub of activity %s", last_activity_timestamp)

req = HTTPRequest(
url=self.hub_activity_url,
method='POST',
Expand All @@ -433,8 +436,12 @@ async def notify():
)
try:
await client.fetch(req)
except Exception:
self.log.exception("Error notifying Hub of activity")
except Exception as e:
failure_count += 1
# log traceback at debug-level
self.log.debug("Error notifying Hub of activity", exc_info=True)
# only one-line error visible by default
self.log.error("Error notifying Hub of activity: %s", e)
return False
else:
return True
Expand All @@ -446,6 +453,8 @@ async def notify():
max_wait=15,
timeout=60,
)
if failure_count:
self.log.info("Sent hub activity after %s retries", failure_count)
self._last_activity_sent = last_activity

async def keep_activity_updated(self):
Expand Down

0 comments on commit 06c8d22

Please sign in to comment.