Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

load balanced spawner #213

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

oliver-sanders
Copy link
Member

@oliver-sanders oliver-sanders commented Apr 29, 2021

closes #137

Turned out that having a spawner as a plugin to a spawner was a little tricky as there's all sorts of setup Jupyterhub does.

We could also use the existing SSH spawner plugin by subclassing and overriding the choose_remote_host method and bolting on some bits. This plugin is a little over the top for us as it does file transfers etc.

Simple solution, runs the command through an SSH connection, similar to how cylc play does it.

Note: JupyterHub spawners run as the user so this spawner, the SSH connection and the UIS is spawns are all in userland even if the hub is not.

Here's the configuration to use it:

c.JupyterHub.spawner_class = 'cylc.uiserver.distributed_spawner.DistributedSpawner'
c.DistributedSpawner.hosts = ['localhost']  

Unfortunately the UIS doesn't like being spawned onto other hosts, I think we need to patch the handlers with the location of the Hub. I've tried patching the MainHandler but that leaves me with the following error (Hub stdout):

tornado.application WARNING  oauth state '<key>' != None

So ATM this can't be used to spawn UIS on other hosts which makes it a bit of a chocolate teapot.

Been looking at the JupyterHub single-user thinggy trying to figure out how to fix it. They configure their handlers quite differently (redirect rather than render) and seem to provide hub-host and hub-prefix CLI opts?

https://github.com/jupyterhub/jupyterhub/blob/3fec19d191119e4203c243f44c43e74c8fe62f04/jupyterhub/singleuser/mixins.py#L141-L155

Requirements check-list

  • I have read CONTRIBUTING.md and added my name as a Code Contributor.
  • Contains logically grouped changes (else tidy your branch by rebase).
  • Does not contain off-topic changes (use other PRs for other changes).
  • Appropriate tests are included (unit and/or functional).
  • Already covered by existing tests.
  • Does not need tests (why?).
  • Appropriate change log entry included.
  • No change log entry required (why? e.g. invisible to users).
  • I have opened a documentation PR at cylc/cylc-doc/pull/XXXX.
  • No documentation update required.

@oliver-sanders
Copy link
Member Author

Will rebase after #230 at which point this should work,

return {
**Spawner.get_env(self),
'CYLC_VERSION': CYLC_VERSION,
'JUPYTERHUB_SERVICE_PREFIX': '/user/osanders/'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having a brief glance at this with #230, and not marked ready for review but this line will need changing.
Nice looking pr though, happy to review when it is ready.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this was hacked a bit, should be much nicer with Jupyter Server 🤞.

@oliver-sanders
Copy link
Member Author

Rebased this now we are using Jupyter Server.

The spawner works, the server is started on the remote host and the polling works correctly, but, from the hub's URL I get a 503 error and from the servers URL, a 404 so it's still not useable.

I think it's missing some of the config/initialisation required to work with the hub's remote API? More investigation required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

create a remote spawner with load-balancing capability
3 participants