`extraFiles` makes folder unwritable?

I’m trying to map in a jupyter_server_config.py file to restrict the available kernels in our custom image. My config looks like:

singleuser:
  extraFiles:
    custom_config:
      mountPath: /home/user/.jupyter/jupyter_server_config.py
      mode: 0777
      stringData: |
        c.KernelSpecManager.ensure_native_kernel = False
        c.KernelSpecManager.whitelist = {'xpython'}

…but unfortunately this doesn’t work.

I’m using a recent version of the chart:

> helm install jupyterhub `
>>     jupyterhub/jupyterhub `
>>     --namespace jhub `
>>     --version 0.11.1-n361.h166e2157 `
>>     --values jupyterhub-helm.yaml

The container logs show a permission denied error trying to access the ~/.jupyter/lab folder:

[W 2021-04-03 20:46:47.962 SingleUserNotebookApp web:1787] 500 PUT /user/dhirschfeld/lab/api/workspaces/default?1617446807946 (10.200.72.34): [Errno 13] Permission denied: '/home/user/.jupyter/lab'

In the JupyterLab container itself I can see the config is mapped in:

user@jupyter-dhirschfeld:~/.jupyter$ cat jupyter_server_config.py 
c.KernelSpecManager.ensure_native_kernel = False
c.KernelSpecManager.whitelist = {'xpython'}

…but the lab folder is missing and the folder seems to be read-only:

user@jupyter-dhirschfeld:~/.jupyter$ ls
jupyter_server_config.py
user@jupyter-dhirschfeld:~/.jupyter$ touch jupyter_server_config.py
touch: cannot touch 'jupyter_server_config.py': Read-only file system
user@jupyter-dhirschfeld:~/.jupyter$ touch a.txt
touch: cannot touch 'a.txt': Permission denied
user@jupyter-dhirschfeld:~/.jupyter$ mkdir lab
mkdir: cannot create directory ‘lab’: Permission denied

Is this expected? It would seem to make it difficult to use to map in configuration.

Saving the config to /usr/local/etc/jupyter/jupyter_server_config.py did the job, but only in combination with changing the cmd:

singleuser:
  cmd: jupyter-labhub

Does the ~/.jupyter directory already exist in the container image with the correct permissions before you mount the extra file?

Good point. I don’t think it existed previously.

I wonder if I can use an init container to create it or if it’s already too late by that point :thinking: