jupyterhub / batchspawner

Custom Spawner for Jupyterhub to start servers in batch scheduled systems
BSD 3-Clause "New" or "Revised" License
190 stars 134 forks source link

Upgrade singleuser.py to JupyterHub 4 #267

Closed mahendrapaipuri closed 8 months ago

mahendrapaipuri commented 1 year ago

jupyterhub-singleuser is a subclass of ExtensionApp and after a brief discussion with @minrk at JupyterCon, he told me that the new implementation of jupyterhub-singleuser does not expect any CLI args. If we use batchspawner with JupyterHub 4, we end up getting an error as follows:

[W 2023-05-13 15:27:12.537 ServerApp] Permission to listen on port 443 denied.
[C 2023-05-13 15:27:12.537 ServerApp] ERROR: the Jupyter server could not be started because port 443 is not available.
[D 2023-05-13 15:27:12.537 ServerApp] Exiting application: jupyter-server

The JUPYTERHUB_SERVICE_URL env var is set to http(s)://0.0.0.0:0/user/<user>/servers/<server> at the spawn time in batchspawner and due to this code here, depending on the HTTP scheme, the server will be either launched on 80/443 ports.

This PR replaces the port in JUPYTERHUB_SERVICE_URL with free port that we find and updates the env var. Consequently, CLI arg --port is removed as it is not used anymore.

consideRatio commented 8 months ago

@minrk are you able to help review this?

Note that batchspawner is in main branch currently requires jupyterhub 1.5.1+, up from the latest release that required jupyterhub 0.9+.

minrk commented 8 months ago

Updated the handling a tiny bit. JUPYTERHUB_SERVICE_URL is added in JupyterHub 2.0, so it's only 1.5.1 that needs the --port

welcome[bot] commented 8 months ago

Congrats on your first merged pull request in this project! :tada: congrats Thank you for contributing, we are very proud of you! :heart: