Error at creating single user server when using Swarmspawner

Hello guys,

I am using jupyterhub with swarm spawner.

my jupyterhub_config.py file:

c.SwarmSpawner.cmd = [“jupyterhub-singleuser”, “–allow-root”]
c.SwarmSpawmer.use_internal_ip = True
c.SwarmSpawner.image = “guyq1997/jupyterlab”
c.SwarmSpawner.network_name = os.environ[“DOCKER_NETWORK_NAME”]
c.SwarmSpawner.extra_host_config = { ‘network_mode’:os.environ[“DOCKER_NETWORK_NAME”] }
c.SwarmSpawner.start_timeout = 120
c.SwarmSpawner.remove = False
c.Spawner.extra_placement_spec = { “constraints”: [“node.role == manager”] }
class MyDockerSpawner(SwarmSpawner):
def start(self):
if self.user.name in Dozenten:
self.extra_create_kwargs = {‘user’: ‘root’}
return super().start()
c.JupyterHub.spawner_class = MyDockerSpawner
c.JupyterHub.hub_ip = “0.0.0.0”
c.JupyterHub.bind_url = ‘http://0.0.0.0:8000/jupyterhub
c.JupyterHub.authenticator_class = ShibbolethAuthenticator

my docker-compose.yml file:

jupyterhub:
image: guyq1997/jupyterhub
container_name: jupyterhub

volumes:
  - "/var/run/docker.sock:/var/run/docker.sock"
  - "./jupyterhub_config.py:/srv/jupyterhub/jupyterhub_config.py"
environment:
  DOCKER_NETWORK_NAME: jupyterhub_network2

networks:
  - jupyterhub_network2

command: >
  jupyterhub -f /srv/jupyterhub/jupyterhub_config.py

deploy:
  placement:
    constraints:
      - node.role == manager

networks:
jupyterhub_network2:
name: jupyterhub_network2
external: true

When I try to spawn my single user server I got 500 Error from Jupyterhub:

And this is the Error Log from Jupyterhub Container:

swarm_jupyterhub.1.5s9adq9fsmin@jds-shib | [E 2024-04-29 12:05:52.151 JupyterHub user:887] Unhandled error starting yuqiang’s server: ServiceApiMixin.create_service() got an unexpected keyword argument ‘user’

DockerSpawner and SwarmSpawner use different Docker API calls.
The former calls create_container

whereas the latter calls create_service which doesn’t accept a user argument.

2 Likes

Thanks a lot! That helps!

1 Like