Skip to content

jupyterhub passes invalid (old) config params to sudospawner-singleuser #100

Description

@jelmd

Bug description

When jupyterhub spawns a new single user instance it passes not the current parameters from the given config file, but outdated/wrong values from a previous run.

How to reproduce

  1. Insert into systemdspawner/systemd.py a "debug line" like this to see, what gets passed:
sys.stderr.write(" ".join(run_cmd) + "\n")
  1. start jupyterhub e.g. like this:
#!/bin/ksh93
LOGFILE=~${LOGNAME}/jupyterhub.log

[[ ${LOGLEVEL} =~ ^(DEBUG|INFO|WARN|ERROR|CRITICAL)$ ]] || LOGLEVEL=WARN

export JUPYTER_PATH=/usr/local/jupyter
export PATH=${JUPYTER_PATH}/bin:${PATH}
CMD=( ${ python3 -V ; } )
CMD=( ${CMD[1]//./ } )
export PYTHONPATH=${JUPYTER_PATH}/lib/python${CMD}.${CMD[1]}/site-packages
export NPM_CONFIG_GLOBALCONFIG=/usr/local/jupyter/npmrc
export HOST=${ uname -n; }

exec "${JUPYTER_PATH}/bin/jupyterhub" ${SSL} \
    -f "/etc/jhub_cfg.py" \
    --log-level=${LOGLEVEL} \
    >${LOGFILE} 2>&1 &

and /etc/jhub_cfg.py:

import os
import re

c = get_config()

c.JupyterHub.base_url = '/'.join([ '/jupyter', os.environ['HOST'] ]) 
c.JupyterHub.spawner_class = 'systemdspawner.SystemdSpawner'
c.JupyterHub.shutdown_on_logout = True

c.Spawner.args = ['--ServerApp.allow_origin=*']
c.Spawner.notebook_dir = '~/'

c.Authenticator.admin_users = {'foobar','barfuss'}
c.Authenticator.admin_groups = {'nobrain'}
c.Authenticator.allow_all = True
c.Authenticator.allow_existing_users = True

c.ConfigurableHTTPProxy.debug = True

c.SystemdSpawner.default_shell = '/bin/bash'
c.SystemdSpawner.unit_name_template = 'jsu-{USERNAME}'
c.SystemdSpawner.slice = 'jhub-' + (os.environ['HOST']).replace('-',':')
c.SystemdSpawner.unit_extra_properties = { 'RuntimeDirectory': 'jhub/jsu-{USERNAME}' }
  1. Try to connect to the service, login and wait (let it fail).

  2. Stop the jupyterhub service.

  3. Change the config e.g. by setting SystemdSpawner.unit_name_template to something else, e.g. 'jhub-{USERNAME}'.

  4. Start the jupyterhub service as in 1.

  5. Try to connect/login to the service again.

  6. Check the log

Expected behaviour

On the second try systemd-run --unit jhub-* should have been used to start the jupyterhub user instance.

Actual behaviour

It still uses systemd-run --unit jsu-* as in the first run (and Note, the jupyterhab got properly shutdown before starting it with the new config).

  • OS: ubuntu 24.04
  • Version(s):
Selected Jupyter core packages...
IPython          : 9.5.0
ipykernel        : 6.30.1
ipywidgets       : 8.1.7
jupyter_client   : 8.6.3
jupyter_core     : 5.8.1
jupyter_server   : 2.17.0
jupyterlab       : 4.4.7
nbclient         : 0.10.2
nbconvert        : 7.16.6
nbformat         : 5.10.4
notebook         : 7.4.5
qtconsole        : not installed
traitlets        : 5.14.3
...
jsd-helper systemd-run --unit jsu-foobar --working-directory /home/foobar --uid=1234 --gid=5678 --slice=jhub-n02:00 --property=NoNewPrivileges=yes --property=RuntimeDirectory=jhub/jsu-foobar --property=RuntimeDirectoryMode=755 --property=RuntimeDirectoryPreserve=restart --property=OOMPolicy=continue --property=EnvironmentFile=/run/jhub/jsu-foobar/jsu-foobar.env /usr/local/jupyter/bin/jupyterhub-singleuser --ServerApp.allow_origin=*
[W 2025-09-25 20:45:23.492 JupyterHub metrics:456] Event loop was unresponsive for at least 29.99s!
[W 2025-09-25 20:45:23.494 JupyterHub base:1229] User foobar is slow to start (timeout=10)
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions