Jupyterhub: User's default server is deleted when any named server cannot be added to the proxy.

Created on 29 May 2020  路  3Comments  路  Source: jupyterhub/jupyterhub

Bug description

We noticed a problem where failure to add a named server to the proxy wrongly caused the default server to be deleted instead. In the following example, doublegpu7 failed to be added to the proxy, but instead of deleting doublegpu7, the default server jupyter-michaeldzamba was deleted instead.

[E 2020-05-28 22:02:11.206 JupyterHub base:876] Failed to add michaeldzamba:doublegpu7 to proxy!
    Traceback (most recent call last):
      File "/fn/lib/python3.7/site-packages/jupyterhub/handlers/base.py", line 869, in finish_user_spawn
        await self.proxy.add_user(user, server_name)
      File "/fn/lib/python3.7/site-packages/jupyterhub/proxy.py", line 274, in add_user
        {'user': user.name, 'server_name': server_name},
      File "/fn/lib/python3.7/site-packages/jupyterhub_traefik_proxy/kv_proxy.py", line 289, in add_route
        await self._wait_for_route(routespec, provider=self.kv_name)
      File "/fn/lib/python3.7/site-packages/jupyterhub_traefik_proxy/proxy.py", line 147, in _wait_for_route
        timeout=self.check_route_timeout,
      File "/fn/lib/python3.7/site-packages/jupyterhub/utils.py", line 177, in exponential_backoff
        raise TimeoutError(fail_message)
    TimeoutError: Traefik route for /user/michaeldzamba/doublegpu7/ configuration not available
[E 2020-05-28 22:02:11.207 JupyterHub base:878] Stopping michaeldzamba:doublegpu7 to avoid inconsistent state
[I 2020-05-28 22:02:11.208 JupyterHub spawner:1866] Deleting pod jupyter-michaeldzamba

Expected behaviour

When a named or default server cannot be added to a proxy, that named or default server should be deleted.

Actual behaviour

When a named or default server cannot be added to a proxy, the user's default server is deleted.

Your personal set up

We are currently running Jupyterhub with the traefik proxy and Kubespawner on Debian buster (versions below):

jupyterhub-kubespawner==0.11.1 \
    --hash=sha256:ba3efd98db31f157c8db6371d88d86260025a253ab826d7fa404af9764a482e1 \
    --hash=sha256:d33c771a058ec3c5931b5793813498502601a9fe6e7f315750e6e5df518af0e1 \
jupyterhub-traefik-proxy==0.1.4 \
    --hash=sha256:4e3b3190988e8e79aba96992ca52b9e1adca60f3addb8b85f2fc60e2f7934660 \
    --hash=sha256:f1d677e297c1c5912df4ffab9733c934c610398df4ac397990c476962cdfaac7 \
jupyterhub==1.1.0 \
    --hash=sha256:852a70225a03abd631b36a207f3ffdf69326a0db4cef539825fde39ec1b713d7 \
    --hash=sha256:a515a22fe1e66e1a08d2e4ecb9b5fe47ed024cddfbc657ad15f448ac3bf409ca \
bug

Most helpful comment

I believe that I have narrowed this down to this line: https://github.com/jupyterhub/jupyterhub/blob/e08552eb99c3e9493a4a34f7414ceed1bf067787/jupyterhub/handlers/base.py#L880

When called without arguments, user.stop() stops the default server according to this line: https://github.com/jupyterhub/jupyterhub/blob/3adfec0693cc463f242497ec70bd553780dde04c/jupyterhub/user.py#L732

Simply changing the first line to user.stop(spawner_name) should suffice. I am happy to work on the PR, but will need guidance w.r.t to how to set up tests for this change.

All 3 comments

I believe that I have narrowed this down to this line: https://github.com/jupyterhub/jupyterhub/blob/e08552eb99c3e9493a4a34f7414ceed1bf067787/jupyterhub/handlers/base.py#L880

When called without arguments, user.stop() stops the default server according to this line: https://github.com/jupyterhub/jupyterhub/blob/3adfec0693cc463f242497ec70bd553780dde04c/jupyterhub/user.py#L732

Simply changing the first line to user.stop(spawner_name) should suffice. I am happy to work on the PR, but will need guidance w.r.t to how to set up tests for this change.

Thanks for offering the PR! I think you are exactly right. For the test, you'll want to add it in tests/test_named_servers.py. Copy an existing test there and add a with mock.patch to patch proxy.add_user to raise any exception. Then assert the appropriate state, such as that the spawner has been stopped and/or the default server has not.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

whao picture whao  路  3Comments

minrk picture minrk  路  4Comments

consideRatio picture consideRatio  路  3Comments

sarath145p picture sarath145p  路  4Comments

gaorongchao picture gaorongchao  路  4Comments