Yes, unfortunately it’s a bit complicated… If you want to use the default command from the Docker image you can unset singleuser.cmd
, but if you want to use the default command with other Spawner parameters you have to explicitly add the default, which as you figured out is start-notebook.sh
.
See this issue for more details:
opened 04:06PM - 09 Mar 21 UTC
bug
I saw that `c.KubeSpawner.default_url` [was reported to not have an impact](http… s://github.com/jupyterhub/kubespawner/issues/149#issuecomment-793998324) and decided to investigate.
I end up concluding that configuring the command that the container starts with is very complicated. The Spawner, K8s, and the Dockerfile all have various names for similar things that all combine into a k8s containers `args` field where the `command` field apparently isn't configurable to my surprise.
- `cmd`, `args`, `notebook_dir`, `default_url`, and `get_args(...)` are defined in in the Spawner base class
- `get_args(...)` combines `notebook_dir`, `default_url`, and `args` into a single appendix to `cmd`
- K8s containers have `command` and `args` which are the equivalent of Dockerfiles `entrypoint` and `cmd`
- KubeSpawner sets the containers k8s field `args` to the variable `real_cmd` decided below, which changed in 5ee6dc6f.
- Z2JH's default config of KubeSpawner's `cmd` is [`jupyterhub-singleuser`](https://github.com/jupyterhub/jupyterhub/blob/master/setup.py#L115).
```diff
async def get_pod_manifest(self):
# ...
if self.cmd:
real_cmd = self.cmd + self.get_args()
else:
# change commit comment:
# fix use of get_args() (calling get_args() alone would omit the command)
- real_cmd = self.get_args()
+ real_cmd = None
```
### Investigation conclusion
1. I'm confused we opt to set `args` of the k8s container based on the traitlets `cmd`, `args`, `notebook_dir`, `default_url` instead of setting `command` to `cmd`, and setting `args` to `default_url`, `notebook_dir` and `args`.
2. I think the logic to silently ignore the traitlets `args`, `notebook_dir`, `default_url` when `cmd` is unset is problematic and should lead to a warning at least.