jupyterhub / kubespawner

Kubernetes spawner for JupyterHub
https://jupyterhub-kubespawner.readthedocs.io
BSD 3-Clause "New" or "Revised" License
543 stars 304 forks source link

Some _template options don't work when defined in profile_list profiles #761

Open AlexHill opened 1 year ago

AlexHill commented 1 year ago

https://github.com/jupyterhub/kubespawner/issues/528 touches on this but the issue is more general than described there.

Bug description

Some of the *_template options are expanded in KubeSpawner.__init__() and never again. Overriding them in profile_list profiles therefore doesn't work - you can override the template, but since the template has already been expanded, overriding doesn't produce the desired effect.

See e.g. pvc_name, which is set in init and then used in get_pod_manifest() as-is. Instead, I think pvc_name_template should be expanded in get_pod_manifest().

Expected behaviour

Expansion of templates should be deferred wherever possible so that their overridden values can be respected.

Actual behaviour

Some templates are expanded during init and never again, so overriding them has no effect.

How to reproduce

Deploy z2jh with

  singleuser:
    profileList:
      - display_name: Override test
        default: true
        kubespawner_override:
          service_account: default
          volumes:
            - name: user-home
              persistentVolumeClaim:
                claimName: override-claim-{userid}--{servername}
          volume_mounts:
            - name: user-home
              mountPath: /home/jovyan
          pvc_name_template: override-claim-{userid}--{servername}

And try to launch your server. It will fail, because the volume definitions are expanded after overrides are applied, but the PVC name is not.

welcome[bot] commented 1 year ago

Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out Jupyter's Code of Conduct. Also, please try to follow the issue template as it helps other other community members to contribute more effectively. welcome You can meet the other Jovyans by joining our Discourse forum. There is also an intro thread there where you can stop by and say Hi! :wave:
Welcome to the Jupyter community! :tada:

yuvipanda commented 1 year ago

Thanks for opening this, @AlexHill! I agree it makes sense they shouln't be expanded in __init__. Do you think you would be able to make a PR?