jupyterhub / wrapspawner

Mechanism for runtime configuration of spawners for JupyterHub
BSD 3-Clause "New" or "Revised" License
60 stars 58 forks source link

pre_spawn_hook not working #29

Open belfhi opened 5 years ago

belfhi commented 5 years ago

Hello, I want to use CondorSpawner to spawn notebooks on HTCondor. For this I need to add a pre_spawn_hook to do some work so that the Kerberos credentials are put into the spawner.environment properly. When I use CondorSpawner directly the pre_spawn_hook executes and spawning works. With wrapspawner.ProfilesSpawner the pre_spawn_hook seems to execute (I added a log message) but spawning doesn't work because the environment in the spawner isn't set properly. Is adding the pre_spawn_hook via c.Spawner.pre_spawn_hook = get_krb5_var the right way of doing it or do I need to do it differently so that the hook is added to the child spawners?

rkdarst commented 5 years ago

It looks like pre_spawn_hook isn't relayed from WrapSpawner to the child spawner - this has been a problem with other attributes, too. I'd say, check out the way the start method works: https://github.com/jupyterhub/wrapspawner/blob/master/wrapspawner/wrapspawner.py#L121 I think something like that should work with the pre_spawn_hook. I don't have time to make something right now, but you could try if you wanted.

Putting it on c.Spawner puts it on both (I think), but the one on ProfileSpawner doesn't update child spawner (I guess?) and the one on CondorSpawner doesn't get called at all. #27 would relay the attributes from ProfileSpawner to CondorSpawner, but I think that only gets set up when start is called, which happens after pre_spawn_hook gets called. But it gets harder... if you set c.Spawner = your_hook, it would also override ProfileSpawner.pre_spawn_hook, which would mean it overrides the the child spawner construction and relaying the call. So I think the simplest thing to support is to only set c.CondorSpawner.pre_spawn_hook (and this should be documented).

Anything above could be wrong... but good luck for now! This will be important to have in general.

belfhi commented 5 years ago

okay, I will see if I can come up with something that can be turned into a pull request in the near future... Thanks for the help for now.