Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Startup script causes timeout on JupyterHub due to slow chown -R #269

Open
wieluk opened this issue Feb 25, 2025 · 2 comments
Open

Startup script causes timeout on JupyterHub due to slow chown -R #269

wieluk opened this issue Feb 25, 2025 · 2 comments
Assignees

Comments

@wieluk
Copy link

wieluk commented Feb 25, 2025

When starting a container from JupyterHub, the chown -R operation takes too long if there are many files, leading to a timeout even though the timeout is already set to 600 seconds. The script enforces ownership changes when NB_UID and NB_GID differ from the defaults, causing significant delays.

your config/jupyter/start_notebook.sh:

# This script runs in local Jupyterlab only (e.g. Docker, Neurodeskapp)
# This script does NOT run on stock JupterHub/BinderHub instances (e.g. kubernetes)
# For global startup script, see ./config/jupyter/jupterlab_startup.sh

if [ -z "$GRANT_SUDO" ]; then
export GRANT_SUDO='yes'
fi
if [ -z "$RESTARTABLE" ]; then
export RESTARTABLE='yes'
fi

if [[ "$NB_UID" != "1000" || "$NB_GID" != "100" ]]; then
    if [ -z "$CHOWN_HOME" ]; then
    export CHOWN_HOME='yes'
    fi
    if [ -z "$CHOWN_HOME_OPTS" ]; then
    export CHOWN_HOME_OPTS='-R'
    fi
fi

Logs show that chown -R runs on /home/jovyan:

docker logs jupyterhub-5fnv
Entered start.sh with args: start-notebook.py
Running hooks in: /usr/local/bin/start-notebook.d as uid: 0 gid: 0
Sourcing shell script: /usr/local/bin/start-notebook.d/start_notebook.sh
Done running hooks in: /usr/local/bin/start-notebook.d
Update jovyan's UID:GID to 1013:1014
userdel: group jovyan not removed because it is not the primary group of user jovyan.
Ensuring /home/jovyan is owned by 1013:1014 (chown options: -R)

Do you know how to prevent this while still being able to change guid and uid for users with a lot of files in /home/joyvan?

@aswinnarayanan
Copy link
Contributor

Thanks @wieluk.

The following potential changes may resolve this:

  • Apply the chown only when there is an actual mismatch between home dir and nb uid/gid. Currently it's hardcoded to expect 1000:100
  • The notebook will need the home directory and certain files and sub-directories to have the proper ownership to start up.
    We could the startup script only modify those locations, instead of the entire home subtree. It might be the case that the user will need to manage the remaining files. Or have that moved to an extra flag

I'll try this and let you know when it's updated

@aswinnarayanan aswinnarayanan self-assigned this Feb 26, 2025
@wieluk
Copy link
Author

wieluk commented Feb 26, 2025

Thanks! The user has 1.1 million files, most of which likely come from installed Python and R packages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: New
Development

No branches or pull requests

2 participants