jupyterhub / sudospawner

Spawn JupyterHub single-user servers with sudo
BSD 3-Clause "New" or "Revised" License
50 stars 41 forks source link

I can't create notebook as a user with "dot" in username #77

Open lpcez opened 8 months ago

lpcez commented 8 months ago

Bug description

Hi. I get 500 error when creating notebook as a user with "." in username. We are using ldap to authenticate users and almost everyone has name in form of "firstletterofthename.surname".

How to reproduce

  1. Login to jupyterhub as a user ex. "q.bert" from a domain.
  2. Try to launch any notebook using ipykernel.
  3. See the error below.

Expected behaviour

I would have a notebook.

Actual behaviour

It goes like this: (look for the "ValueError: substring not found", it might be it)

mar 13 10:44:27 some-host-name jupyterhub[636247]: [E 2024-03-13 10:44:27.605 JupyterHub pages:313] Error starting server some.username: substring not found
mar 13 10:44:27 some-host-name jupyterhub[636247]:     Traceback (most recent call last):
mar 13 10:44:27 some-host-name jupyterhub[636247]:     None: None
mar 13 10:44:27 some-host-name jupyterhub[636247]:     
mar 13 10:44:27 some-host-name jupyterhub[636247]: [W 2024-03-13 10:44:27.606 JupyterHub web:1873] 500 GET /hub/spawn (127.0.0.1): Unhandled error starting server some.username
mar 13 10:44:27 some-host-name jupyterhub[636247]: [E 2024-03-13 10:44:27.612 JupyterHub log:183] {
mar 13 10:44:27 some-host-name jupyterhub[636247]:       "X-Forwarded-Proto": "http",
mar 13 10:44:27 some-host-name jupyterhub[636247]:       "X-Forwarded-Port": "80",
mar 13 10:44:27 some-host-name jupyterhub[636247]:       "Connection": "Keep-Alive",
mar 13 10:44:27 some-host-name jupyterhub[636247]:       "X-Forwarded-Server": "some-address.local",
mar 13 10:44:27 some-host-name jupyterhub[636247]:       "X-Forwarded-Host": "some-host-name.com",
mar 13 10:44:27 some-host-name jupyterhub[636247]:       "X-Forwarded-For": "ip.ip.ip.ip,127.0.0.1",
mar 13 10:44:27 some-host-name jupyterhub[636247]:       "Sec-Fetch-User": "?1",
mar 13 10:44:27 some-host-name jupyterhub[636247]:       "Sec-Fetch-Site": "same-origin",
mar 13 10:44:27 some-host-name jupyterhub[636247]:       "Sec-Fetch-Mode": "navigate",
mar 13 10:44:27 some-host-name jupyterhub[636247]:       "Sec-Fetch-Dest": "document",
mar 13 10:44:27 some-host-name jupyterhub[636247]:       "Upgrade-Insecure-Requests": "1",
mar 13 10:44:27 some-host-name jupyterhub[636247]:       "Cookie": "_xsrf=[secret]; jupyterhub-hub-login=[secret]; _ga_PWDD85JKVC=[secret]; _ga=[secret]; jupyterhub-session-id=[secret]",
mar 13 10:44:27 some-host-name jupyterhub[636247]:       "Referer": "https://some-host-name.com/hub/login",
mar 13 10:44:27 some-host-name jupyterhub[636247]:       "Accept-Encoding": "gzip, deflate, br",
mar 13 10:44:27 some-host-name jupyterhub[636247]:       "Accept-Language": "pl,en-US;q=0.7,en;q=0.3",
mar 13 10:44:27 some-host-name jupyterhub[636247]:       "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8",
mar 13 10:44:27 some-host-name jupyterhub[636247]:       "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:123.0) Gecko/20100101 Firefox/123.0",
mar 13 10:44:27 some-host-name jupyterhub[636247]:       "Host": "some-host-name.com"
mar 13 10:44:27 some-host-name jupyterhub[636247]:     }
mar 13 10:44:27 some-host-name jupyterhub[636247]: [E 2024-03-13 10:44:27.612 JupyterHub log:191] 500 GET /hub/spawn (some.username@127.0.0.1) 264.13ms
mar 13 10:44:30 some-host-name jupyterhub[636247]: [I 2024-03-13 10:44:30.079 JupyterHub log:191] 200 GET /hub/home (some.username@127.0.0.1) 9.39ms
mar 13 10:44:31 some-host-name jupyterhub[636247]: [I 2024-03-13 10:44:31.472 JupyterHub provider:659] Creating oauth client jupyterhub-user-some.username
mar 13 10:44:31 some-host-name sudo[640181]: jupyterhub : PWD=/opt/jupyterhub/app/hub ; USER=some.username ; COMMAND=/opt/jupyterhub/app/hub/bin/sudospawner
mar 13 10:44:31 some-host-name jupyterhub[636247]: /opt/jupyterhub/app/hub/bin/python3.9: error while loading shared libraries: libcrypt.so.1: failed to map segment from shared object
mar 13 10:44:31 some-host-name jupyterhub[636247]: [E 2024-03-13 10:44:31.653 JupyterHub spawner:83] Failed to get JSON result from mediator: ''
mar 13 10:44:31 some-host-name jupyterhub[636247]: [E 2024-03-13 10:44:31.654 JupyterHub user:884] Unhandled error starting some.username's server: substring not found
mar 13 10:44:31 some-host-name jupyterhub[636247]:     Traceback (most recent call last):
mar 13 10:44:31 some-host-name jupyterhub[636247]:       File "/opt/jupyterhub/app/hub/lib64/python3.9/site-packages/jupyterhub/user.py", line 798, in spawn
mar 13 10:44:31 some-host-name jupyterhub[636247]:         url = await gen.with_timeout(timedelta(seconds=spawner.start_timeout), f)
mar 13 10:44:31 some-host-name jupyterhub[636247]:       File "/opt/jupyterhub/app/hub/lib64/python3.9/site-packages/sudospawner/spawner.py", line 92, in start
mar 13 10:44:31 some-host-name jupyterhub[636247]:         reply = yield self.do(action='spawn', args=self.get_args(), env=self.get_env())
mar 13 10:44:31 some-host-name jupyterhub[636247]:       File "/opt/jupyterhub/app/hub/lib64/python3.9/site-packages/sudospawner/spawner.py", line 80, in do
mar 13 10:44:31 some-host-name jupyterhub[636247]:         data_str = data_str[data_str.index('{'):data_str.rindex('}')+1]
mar 13 10:44:31 some-host-name jupyterhub[636247]:     ValueError: substring not found
mar 13 10:44:31 some-host-name jupyterhub[636247]:     
mar 13 10:44:31 some-host-name jupyterhub[636247]: [E 2024-03-13 10:44:31.702 JupyterHub pages:313] Error starting server some.username: substring not found
mar 13 10:44:31 some-host-name jupyterhub[636247]:     Traceback (most recent call last):
mar 13 10:44:31 some-host-name jupyterhub[636247]:     None: None
mar 13 10:44:31 some-host-name jupyterhub[636247]:     
mar 13 10:44:31 some-host-name jupyterhub[636247]: [W 2024-03-13 10:44:31.703 JupyterHub web:1873] 500 GET /hub/spawn/some.username (127.0.0.1): Unhandled error starting server some.username
mar 13 10:44:31 some-host-name jupyterhub[636247]: [E 2024-03-13 10:44:31.708 JupyterHub log:183] {
mar 13 10:44:31 some-host-name jupyterhub[636247]:       "X-Forwarded-Proto": "http",
mar 13 10:44:31 some-host-name jupyterhub[636247]:       "X-Forwarded-Port": "80",
mar 13 10:44:31 some-host-name jupyterhub[636247]:       "Connection": "Keep-Alive",
mar 13 10:44:31 some-host-name jupyterhub[636247]:       "X-Forwarded-Server": "some-address.local",
mar 13 10:44:31 some-host-name jupyterhub[636247]:       "X-Forwarded-Host": "some-host-name.com",
mar 13 10:44:31 some-host-name jupyterhub[636247]:       "X-Forwarded-For": "ip.ip.ip.ip,127.0.0.1",
mar 13 10:44:31 some-host-name jupyterhub[636247]:       "Sec-Fetch-User": "?1",
mar 13 10:44:31 some-host-name jupyterhub[636247]:       "Sec-Fetch-Site": "same-origin",
mar 13 10:44:31 some-host-name jupyterhub[636247]:       "Sec-Fetch-Mode": "navigate",
mar 13 10:44:31 some-host-name jupyterhub[636247]:       "Sec-Fetch-Dest": "document",
mar 13 10:44:31 some-host-name jupyterhub[636247]:       "Upgrade-Insecure-Requests": "1",
mar 13 10:44:31 some-host-name jupyterhub[636247]:       "Cookie": "_xsrf=[secret]; jupyterhub-hub-login=[secret]; _ga_PWDD85JKVC=[secret]; _ga=[secret]; jupyterhub-session-id=[secret]",
mar 13 10:44:31 some-host-name jupyterhub[636247]:       "Referer": "https://some-host-name.com/hub/home",
mar 13 10:44:31 some-host-name jupyterhub[636247]:       "Accept-Encoding": "gzip, deflate, br",
mar 13 10:44:31 some-host-name jupyterhub[636247]:       "Accept-Language": "pl,en-US;q=0.7,en;q=0.3",
mar 13 10:44:31 some-host-name jupyterhub[636247]:       "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8",
mar 13 10:44:31 some-host-name jupyterhub[636247]:       "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:123.0) Gecko/20100101 Firefox/123.0",
mar 13 10:44:31 some-host-name jupyterhub[636247]:       "Host": "some-host-name.com"
mar 13 10:44:31 some-host-name jupyterhub[636247]:     }
mar 13 10:44:31 some-host-name jupyterhub[636247]: [E 2024-03-13 10:44:31.708 JupyterHub log:191] 500 GET /hub/spawn/some.username (some.username@127.0.0.1) 269.19ms
mar 13 10:44:33 some-host-name jupyterhub[636247]: [I 2024-03-13 10:44:33.468 JupyterHub log:191] 200 GET /hub/home (some.username@127.0.0.1) 9.18ms
mar 13 10:44:35 some-host-name jupyterhub[636247]: [I 2024-03-13 10:44:35.175 JupyterHub login:44] User logged out: some.username
mar 13 10:44:35 some-host-name jupyterhub[636247]: [I 2024-03-13 10:44:35.181 JupyterHub log:191] 302 GET /hub/logout -> /hub/login (@127.0.0.1) 10.03ms
mar 13 10:44:35 some-host-name jupyterhub[636247]: [I 2024-03-13 10:44:35.203 JupyterHub log:191] 200 GET /hub/login (@127.0.0.1) 5.73ms
mar 13 10:45:12 some-host-name jupyterhub[636250]: 10:45:12.946 [ConfigProxy] info: 200 GET /api/routes
mar 13 10:45:39 some-host-name python3.9[636247]: pam_sss(login:auth): authentication success; logname= uid=2001 euid=2001 tty= ruser= rhost= user=some.username
mar 13 10:45:39 some-host-name jupyterhub[636247]: [I 2024-03-13 10:45:39.330 JupyterHub base:837] User logged in: some.username
mar 13 10:45:39 some-host-name jupyterhub[636247]: [I 2024-03-13 10:45:39.332 JupyterHub log:191] 302 POST /hub/login?next= -> /hub/spawn (some.username@127.0.0.1) 497.85ms
mar 13 10:45:39 some-host-name jupyterhub[636247]: [I 2024-03-13 10:45:39.382 JupyterHub provider:659] Creating oauth client jupyterhub-user-some.username
mar 13 10:45:39 some-host-name sudo[640565]: jupyterhub : PWD=/opt/jupyterhub/app/hub ; USER=some.username ; COMMAND=/opt/jupyterhub/app/hub/bin/sudospawner
mar 13 10:45:39 some-host-name jupyterhub[636247]: /opt/jupyterhub/app/hub/bin/python3.9: error while loading shared libraries: libcrypt.so.1: failed to map segment from shared object
mar 13 10:45:39 some-host-name jupyterhub[636247]: [E 2024-03-13 10:45:39.561 JupyterHub spawner:83] Failed to get JSON result from mediator: ''
mar 13 10:45:39 some-host-name jupyterhub[636247]: [E 2024-03-13 10:45:39.563 JupyterHub user:884] Unhandled error starting some.username's server: substring not found
mar 13 10:45:39 some-host-name jupyterhub[636247]:     Traceback (most recent call last):
mar 13 10:45:39 some-host-name jupyterhub[636247]:       File "/opt/jupyterhub/app/hub/lib64/python3.9/site-packages/jupyterhub/user.py", line 798, in spawn
mar 13 10:45:39 some-host-name jupyterhub[636247]:         url = await gen.with_timeout(timedelta(seconds=spawner.start_timeout), f)
mar 13 10:45:39 some-host-name jupyterhub[636247]:       File "/opt/jupyterhub/app/hub/lib64/python3.9/site-packages/sudospawner/spawner.py", line 92, in start
mar 13 10:45:39 some-host-name jupyterhub[636247]:         reply = yield self.do(action='spawn', args=self.get_args(), env=self.get_env())
mar 13 10:45:39 some-host-name jupyterhub[636247]:       File "/opt/jupyterhub/app/hub/lib64/python3.9/site-packages/sudospawner/spawner.py", line 80, in do
mar 13 10:45:39 some-host-name jupyterhub[636247]:         data_str = data_str[data_str.index('{'):data_str.rindex('}')+1]
mar 13 10:45:39 some-host-name jupyterhub[636247]:     ValueError: substring not found
mar 13 10:45:39 some-host-name jupyterhub[636247]:     
mar 13 10:45:39 some-host-name jupyterhub[636247]: [E 2024-03-13 10:45:39.609 JupyterHub pages:313] Error starting server some.username: substring not found
mar 13 10:45:39 some-host-name jupyterhub[636247]:     Traceback (most recent call last):
mar 13 10:45:39 some-host-name jupyterhub[636247]:     None: None
mar 13 10:45:39 some-host-name jupyterhub[636247]:     
mar 13 10:45:39 some-host-name jupyterhub[636247]: [W 2024-03-13 10:45:39.610 JupyterHub web:1873] 500 GET /hub/spawn (127.0.0.1): Unhandled error starting server some.username
mar 13 10:45:39 some-host-name jupyterhub[636247]: [E 2024-03-13 10:45:39.614 JupyterHub log:183] {
mar 13 10:45:39 some-host-name jupyterhub[636247]:       "X-Forwarded-Proto": "http",
mar 13 10:45:39 some-host-name jupyterhub[636247]:       "X-Forwarded-Port": "80",
mar 13 10:45:39 some-host-name jupyterhub[636247]:       "Connection": "Keep-Alive",
mar 13 10:45:39 some-host-name jupyterhub[636247]:       "X-Forwarded-Server": "some-address.local",
mar 13 10:45:39 some-host-name jupyterhub[636247]:       "X-Forwarded-Host": "some-host-name.com",
mar 13 10:45:39 some-host-name jupyterhub[636247]:       "X-Forwarded-For": "ip.ip.ip.ip,127.0.0.1",
mar 13 10:45:39 some-host-name jupyterhub[636247]:       "Sec-Fetch-User": "?1",
mar 13 10:45:39 some-host-name jupyterhub[636247]:       "Sec-Fetch-Site": "same-origin",
mar 13 10:45:39 some-host-name jupyterhub[636247]:       "Sec-Fetch-Mode": "navigate",
mar 13 10:45:39 some-host-name jupyterhub[636247]:       "Sec-Fetch-Dest": "document",
mar 13 10:45:39 some-host-name jupyterhub[636247]:       "Upgrade-Insecure-Requests": "1",
mar 13 10:45:39 some-host-name jupyterhub[636247]:       "Cookie": "_xsrf=[secret]; jupyterhub-hub-login=[secret]; _ga_PWDD85JKVC=[secret]; _ga=[secret]; jupyterhub-session-id=[secret]",
mar 13 10:45:39 some-host-name jupyterhub[636247]:       "Referer": "https://some-host-name.com/hub/login",
mar 13 10:45:39 some-host-name jupyterhub[636247]:       "Accept-Encoding": "gzip, deflate, br",
mar 13 10:45:39 some-host-name jupyterhub[636247]:       "Accept-Language": "pl,en-US;q=0.7,en;q=0.3",
mar 13 10:45:39 some-host-name jupyterhub[636247]:       "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8",
mar 13 10:45:39 some-host-name jupyterhub[636247]:       "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:123.0) Gecko/20100101 Firefox/123.0",
mar 13 10:45:39 some-host-name jupyterhub[636247]:       "Host": "some-host-name.com"
mar 13 10:45:39 some-host-name jupyterhub[636247]:     }
mar 13 10:45:39 some-host-name jupyterhub[636247]: [E 2024-03-13 10:45:39.614 JupyterHub log:191] 500 GET /hub/spawn (some.username@127.0.0.1) 267.85ms
mar 13 10:45:41 some-host-name jupyterhub[636247]: [I 2024-03-13 10:45:41.706 JupyterHub log:191] 200 GET /hub/home (some.username@127.0.0.1) 8.40ms

Your personal set up

We are using RHEL 8.9 with Python3.9.

Configuration ``` $ grep -Ev '^$|^#' jupyterhub_config.py c = get_config() #noqa c.JupyterHub.spawner_class='sudospawner.SudoSpawner' c.Spawner.cmd = '/opt/jupyterhub/app/hub/bin/sudospawner' c.Spawner.notebook_dir = '/opt/jupyterhub/app/hub/notatniki' c.Spawner.http_timeout = 180 ``` ``` $ grep -Ev '^$|^#' /etc/systemd/system/jupyterhub.service [Unit] Description=JupyterHub [Service] Name=jupyterhub User=jupyterhub Environment=PYTHONUNBUFFERED=1 Environment=VIRTUALENV=/opt/jupyterhub/app/hub/notatniki Environment=PYTHONPATH=$VIRTUALENV/lib:$PYTHONPATH Environment=PATH=/opt/jupyterhub/app/hub/bin:/opt/jupyterhub/node_modules/.bin/:/opt/jupyterjub/.local/bin:/usr/local/sbin:/usr/sbin:/usr/bin:/sbin:/bin WorkingDirectory=/opt/jupyterhub/app/hub ExecStart=/opt/jupyterhub/app/hub/bin/jupyterhub --JupyterHub.confirm_no_ssl=True --port=8888 --ip=127.0.0.1 --SudoSpawner.sudospawner_path='/opt/jupyterhub/app/hub/bin/sudospawner' -f /opt/jupyterhub/app/hub/etc/jupyter/jupyterhub_config.py Restart=always RestartSec=40 Type=simple PIDFile=/var/run/jupyterhub.pid [Install] WantedBy=default.target ``` ``` $PATH: /opt/jupyterhub/app/hub/bin /opt/jupyterhub/.local/bin /opt/jupyterhub/bin /usr/local/bin /usr/bin /usr/local/sbin /usr/sbin /opt/jupyterhub/node_modules/.bin sys.path: /opt/jupyterhub/app/hub/bin /usr/lib64/python39.zip /usr/lib64/python3.9 /usr/lib64/python3.9/lib-dynload /opt/jupyterhub/app/hub/lib64/python3.9/site-packages /opt/jupyterhub/app/hub/lib/python3.9/site-packages sys.executable: /opt/jupyterhub/app/hub/bin/python3.9 sys.version: 3.9.18 (main, Sep 22 2023, 17:58:34) [GCC 8.5.0 20210514 (Red Hat 8.5.0-20)] platform.platform(): Linux-4.18.0-513.18.1.el8_9.x86_64-x86_64-with-glibc2.28 which -a jupyter: /opt/jupyterhub/app/hub/bin/jupyter pip list: Package Version ------------------------- --------------- alembic 1.13.1 anyio 4.3.0 argon2-cffi 23.1.0 argon2-cffi-bindings 21.2.0 arrow 1.3.0 asttokens 2.4.1 async-generator 1.10 async-lru 2.0.4 attrs 23.2.0 Babel 2.14.0 beautifulsoup4 4.12.3 bleach 6.1.0 certifi 2024.2.2 certipy 0.1.3 cffi 1.16.0 charset-normalizer 3.3.2 comm 0.2.1 cryptography 42.0.5 debugpy 1.8.1 decorator 5.1.1 defusedxml 0.7.1 exceptiongroup 1.2.0 executing 2.0.1 fastjsonschema 2.19.1 fqdn 1.5.1 greenlet 3.0.3 h11 0.14.0 httpcore 1.0.4 httpx 0.27.0 idna 3.6 importlib_metadata 7.0.2 ipykernel 6.29.3 ipython 8.18.1 isoduration 20.11.0 jedi 0.19.1 Jinja2 3.1.3 json5 0.9.22 jsonpointer 2.4 jsonschema 4.21.1 jsonschema-specifications 2023.12.1 jupyter_client 8.6.0 jupyter_core 5.7.1 jupyter-events 0.9.0 jupyter-lsp 2.2.4 jupyter_server 2.13.0 jupyter_server_terminals 0.5.2 jupyter-telemetry 0.1.0 jupyterhub 4.0.2 jupyterlab 4.1.4 jupyterlab_pygments 0.3.0 jupyterlab_server 2.25.3 Mako 1.3.2 MarkupSafe 2.1.5 matplotlib-inline 0.1.6 mistune 3.0.2 nbclient 0.7.4 nbconvert 7.16.2 nbformat 5.9.2 nest-asyncio 1.6.0 notebook 7.1.1 notebook_shim 0.2.4 oauthlib 3.2.2 overrides 7.7.0 packaging 23.2 pamela 1.1.0 pandocfilters 1.5.1 parso 0.8.3 pexpect 4.9.0 pip 24.0 platformdirs 4.2.0 prometheus_client 0.20.0 prompt-toolkit 3.0.43 psutil 5.9.8 ptyprocess 0.7.0 pure-eval 0.2.2 pycparser 2.21 Pygments 2.17.2 pyOpenSSL 24.0.0 python-dateutil 2.9.0.post0 python-json-logger 2.0.7 PyYAML 6.0.1 pyzmq 25.1.2 referencing 0.33.0 requests 2.31.0 rfc3339-validator 0.1.4 rfc3986-validator 0.1.1 rpds-py 0.18.0 ruamel.yaml 0.18.6 ruamel.yaml.clib 0.2.8 Send2Trash 1.8.2 setuptools 50.3.2 six 1.16.0 sniffio 1.3.1 soupsieve 2.5 SQLAlchemy 2.0.28 stack-data 0.6.3 sudospawner 0.5.2 terminado 0.18.0 tinycss2 1.2.1 tomli 2.0.1 tornado 6.4 traitlets 5.14.1 types-python-dateutil 2.8.19.20240106 typing_extensions 4.10.0 uri-template 1.3.0 urllib3 2.2.1 wcwidth 0.2.13 webcolors 1.13 webencodings 0.5.1 websocket-client 1.7.0 websockets 12.0 zipp 3.17.0 ```
welcome[bot] commented 8 months ago

Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out Jupyter's Code of Conduct. Also, please try to follow the issue template as it helps other other community members to contribute more effectively. welcome You can meet the other Jovyans by joining our Discourse forum. There is also an intro thread there where you can stop by and say Hi! :wave:
Welcome to the Jupyter community! :tada:

welcome[bot] commented 8 months ago

Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out Jupyter's Code of Conduct. Also, please try to follow the issue template as it helps other other community members to contribute more effectively. welcome You can meet the other Jovyans by joining our Discourse forum. There is also an intro thread there where you can stop by and say Hi! :wave:
Welcome to the Jupyter community! :tada: