jupyterhub / binderhub

Run your code in the cloud, with technology so advanced, it feels like magic!
https://binderhub.readthedocs.io
BSD 3-Clause "New" or "Revised" License
2.57k stars 390 forks source link

namedServerLimitPerUser improperly initialized #1277

Open siboehm opened 3 years ago

siboehm commented 3 years ago

Bug description

Setting jupyterhub.hub.allowNamedServers: true without setting namedServerLimitPerUser results in an Error.

Expected behaviour

If the Limit isn't set, it's initialized to 0 as expected.

How to reproduce

From the Docs:

If you want to have users be able to launch multiple servers at the same time, you have to enable named servers on JupyterHub:

jupyterhub:
  hub:
    allowNamedServers: true
    # change this value as you wish,
    # or remove this line if you don't want to have any limit
    namedServerLimitPerUser: 5

But if you remove the namedServerLimitPerUser: 5 line it results in the pods erroring:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/local/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/usr/local/lib/python3.8/site-packages/binderhub/__main__.py", line 2, in <module>
    from binderhub.app import main
  File "/usr/local/lib/python3.8/site-packages/binderhub/app.py", line 43, in <module>
    from .launcher import Launcher
  File "/usr/local/lib/python3.8/site-packages/binderhub/launcher.py", line 32, in <module>
    class Launcher(LoggingConfigurable):
  File "/usr/local/lib/python3.8/site-packages/binderhub/launcher.py", line 49, in Launcher
    int(os.getenv('JUPYTERHUB_NAMED_SERVER_LIMIT_PER_USER', 0)),
ValueError: invalid literal for int() with base 10: ''

Debug

This should be due to https://github.com/jupyterhub/binderhub/blob/91e6bdd401b23a6cd19d097d2fa7158465fa02ce/helm-chart/binderhub/templates/deployment.yaml#L111-L116

which initializes JUPYTERHUB_NAMED_SERVER_LIMIT_PER_USER as "". This sets the variable, so os.getenv(...) will return the empty string, causing the error: https://github.com/jupyterhub/binderhub/blob/91e6bdd401b23a6cd19d097d2fa7158465fa02ce/binderhub/launcher.py#L48-L52

Your personal set up

# paste output of `pip freeze` or `conda list` here

# jupyterhub_config.py