Failsafe container?

Sometimes users mess up their setup so jupyterhub throws an internal error on startup. Is it possible to set up a failsafe container image so users can log on an clean up their mess themselves?

Containers are ephemeral, so stopping and restarting a user’s server should result in a clean environment. Can you share some examples of the errors you’re seeing?

Sorry, I was unclear. This happens on our current setup for jupyterhub which is vm-based. When users build their own failed environments on their home directory or mess up their path setups jupyterhub can throw an internal error on startup. Then an admin must log in as root and remove .config/.local/.ipython and so on. I know containers are ephermal, but the user environments survive because their home dirs are on PVCs. I’m trying to be preemtive here before we move our production to kubernetes. It would be nice to be able to provide a failsafe container that would work regardless of what damage a user has done to its environment.

will let you disable the user’s Jupyter configuration file which helps.

Unfortunately disabling the user’s Python directory seems more complicated…

Thanks. This is obviously trickier than I thought. Most things are…

You can disable user packages by launching Python in isolated mode:

python3 -I -m jupyterhub.singleuser

or set

PYTHONNOUSERSITE=1
.

I think the linked issue is complicated by the fact that disabling user site requires controlling the command-line or environment variables and they want to be able to make it a property of the env itself. But we can set the env/cli in JupyterHub, so the existing mechanisms work for us.

2 Likes

So all that would be needed is to add this to profileList?


- display_name: "Failsafe environment"
      description: "Use this if you get internal error on startup"
      kubespawner_override:
        image: jupyter/minimal-notebook:2343e33dec46
        enviroment: 
            PYTHONNOUSERSITE: "1"
1 Like

Did a quick test with this and it seems to be the right approach. The PYTHONNOUSERSITE gets propagated to the user environment.