KubeSpawner pre_spawn_hook not called?

I am trying to use the pre_spawn_hook of the KubeSpawner.
My ultimate goal is to add volumes and auth info.

Following different examples I’ve seen in this forum, I actually can’t see the hook being executed at all anywhere.
So I went very basic and have this code, for which I would expect some logs in the hub pod logs.

    - display_name: "test"
          00-volumes: |
            def preSpawnHook(spawner):          
                print("preSpawnHook for mounting volume\n")
            print("hook - 00-volume")
            c.KubeSpawner.pre_spawn_hook = preSpawnHook

Those 2 print statements never show up in the hub pod logs.

The override appears to be read properly by the hub, as stated in the hub logs when the single user pod is starting.

[D 2023-02-14 23:47:05.232 JupyterHub spawner:2989] .. overriding KubeSpawner value extraConfig={'00-volumes': 'def preSpawnHook(spawner):          \n    print("preSpawnHook for mounting volume\\n")\nprint("hook - 00-volume")\nc.KubeSpawner.pre_spawn_hook = preSpawnHook\n'}

I have 2 questions:

  • anything else I need to do to “activate” the hook?
  • is there a better way to debug this than the print statement and pod logs?

I am using the version 2.0.0 of the helm chart of jupyterhub

extraConfig is a Helm Chart feature implemented in the Hub section, it lets you add arbitrary Python code, and KubeSpawner is part of the hub.
Try something like:

    00-volumes: |
      def preSpawnHook(spawner):

Oh my,
I must have been dreaming it was part of the user profile overrides :slight_smile:

Thanks for opening my eyes !