Don't log a warning when slow_spawn_timeout is disabled

When using the `KubeSpawner` it is typical to disable the
`slow_spawn_timeout` by setting it to 0. `zero-to-jupyterhub-k8s`
does this by default [1]. However, this causes an immediate `TimeoutError`
which gets logged as a warning like this:

>User hub-stress-test-123 is slow to start (timeout=0)

This avoids the warning by checking the value and if disabled simply
returns without logging the warning.

[1] https://github.com/jupyterhub/zero-to-jupyterhub-k8s/commit/b4738edc5

Closes #3126
This commit is contained in:
Matt Riedemann
2020-07-23 16:09:19 -05:00
parent f3c3225124
commit 7e205a9751

View File

@@ -977,13 +977,16 @@ class BaseHandler(RequestHandler):
# waiting_for_response indicates server process has started, # waiting_for_response indicates server process has started,
# but is yet to become responsive. # but is yet to become responsive.
if spawner._spawn_pending and not spawner._waiting_for_response: if spawner._spawn_pending and not spawner._waiting_for_response:
# still in Spawner.start, which is taking a long time # If slow_spawn_timeout is intentionally disabled then we
# we shouldn't poll while spawn is incomplete. # don't need to log a warning, just return.
self.log.warning( if self.slow_spawn_timeout > 0:
"User %s is slow to start (timeout=%s)", # still in Spawner.start, which is taking a long time
user_server_name, # we shouldn't poll while spawn is incomplete.
self.slow_spawn_timeout, self.log.warning(
) "User %s is slow to start (timeout=%s)",
user_server_name,
self.slow_spawn_timeout,
)
return return
# start has finished, but the server hasn't come up # start has finished, but the server hasn't come up