Open dstndstn opened 5 years ago
I'd like to echo this gratitude and also this request.
I am having exactly the same issue, with NFS-mounted home directories being inaccessible (200/CHDIR) using the bash "cd {wd} ..."
command in systemd.py. The only way I can get the singleuser service to start with access to user's home directories is by setting c.SystemdSpawner.user_workingdir = '/'
in jupyterhub_config.py and then getting them to navigate manually to their own home directories through Jupyter.
Incidentally, I also tried setting properties['WorkingDirectory'] = working_dir
in systemdspawner.py to no avail.
We're also on systemd version 229 (Ubuntu 16.04), systemdspawner version 0.11. The old systemdspawner version 0.9.10 still appears to work.
Thanks for any help!
I ended up doing something like:
c.Spawner.notebook_dir = '/'
class MySystemdSpawner(systemdspawner.SystemdSpawner):
pass
MySystemdSpawner.cmd = ['/home2/jupyterhub/jupyterhub-run/singleuser.sh']
MySystemdSpawner.notebook_dir = ''
where that singleuser.sh script includes:
#! /bin/bash
cd
jupyterhub-singleuser --notebook-dir=$HOME "$@"
First of all: many thanks for creating this tool! It's super awesome.
We use jupyterhub on an academic computer cluster where the home directories are exported from another machine via NFS. With root squashing, this means that root can't see or cd into users' home directories. As such, when systemd-run is run and by default sets the WorkingDir to the spawning user's home directory, this fails and the service fails with the 200/CHDIR error.
I guess this relates to the order in which systemd does the chdir to the WorkingDir and becoming the User? Once it has become the specified user it can chdir into the home directory, but as root it can't!
(In our case, jupyterhub runs as a special "jupyterhub" user who has sudo power to run systemd-run, but I don't think this matters.)
I can override this with the "user_workingdir" setting -- nice! -- but actually I would like it if jupyterhub session started in the user's home directory.
From what I can see, you are not explicitly setting the WorkingDir in the systemd-run call, so I guess I am proposing adding a config option that would allow setting this -- its default of the user's home dir doesn't work in this case. It looks like later systemd-run commands support a --working-dir option, but my old systemd 229 does not -- maybe a --property=WorkingDir=XXX works?
I can probably figure out how to do this and send a PR if you think this is reasonable.
Thanks again!