name must be valid as a DNS name component
MAliNaqvi opened this issue · 7 comments
Issue:
Starting the notebook service via swarmspawner results in:
jupyterhub.1.ox704kq02e01@moby | [I 2017-03-16 19:11:34.117 JupyterHub log:100] 200 GET /hub/login?next=%2Fhub%2Fuser%2Fanaqvi%2Fapi%2Fsessions%3F_%3D1489688263779 (@::ffff:10.255.0.3) 3.45ms
jupyterhub.1.ox704kq02e01@moby | [I 2017-03-16 19:11:42.975 JupyterHub log:100] 302 GET / (@::ffff:10.255.0.3) 0.83ms
jupyterhub.1.ox704kq02e01@moby | [I 2017-03-16 19:11:42.982 JupyterHub log:100] 302 GET /hub (@::ffff:10.255.0.3) 0.60ms
jupyterhub.1.ox704kq02e01@moby | [I 2017-03-16 19:11:42.999 JupyterHub log:100] 302 GET /hub/ (@::ffff:10.255.0.3) 1.18ms
jupyterhub.1.ox704kq02e01@moby | [I 2017-03-16 19:11:43.017 JupyterHub log:100] 200 GET /hub/login (@::ffff:10.255.0.3) 2.14ms
jupyterhub.1.ox704kq02e01@moby | [I 2017-03-16 19:11:47.273 JupyterHub swarmspawner:260] Service 'jupyter-77e417a2b692b459f1deaac61b3bf5ba-1' is gone
jupyterhub.1.ox704kq02e01@moby | [W 2017-03-16 19:11:47.273 JupyterHub swarmspawner:221] Service not found
jupyterhub.1.ox704kq02e01@moby | [W 2017-03-16 19:11:47.810 JupyterHub swarmspawner:285] self.use_user_options:
jupyterhub.1.ox704kq02e01@moby | [W 2017-03-16 19:11:47.810 JupyterHub swarmspawner:286] {}
jupyterhub.1.ox704kq02e01@moby | [I 2017-03-16 19:11:47.819 JupyterHub swarmspawner:260] Service 'jupyter-77e417a2b692b459f1deaac61b3bf5ba-' is gone
jupyterhub.1.ox704kq02e01@moby | [E 2017-03-16 19:11:48.738 JupyterHub user:282] Unhandled error starting anaqvi's server: 500 Server Error: Internal Server Error for url: http+docker://localunixsocket/v1.26/services/create ("rpc error: code = 3 desc = name must be valid as a DNS name component")
Explanation:
The hub can't find the service jupyter-77e417a2b692b459f1deaac61b3bf5ba-1
associated with a username anaqvi
. It checks user options for a server_name:
https://github.com/cassinyio/SwarmSpawner/blob/master/cassinyspawner/swarmspawner.py#L292-L293
however it doesn't assign a value to server_name if there are no user options. That is if the c.SwarmSpawner.use_user_options = False
in jupyterhub_config.py then it doesn't assign
the server_name anything. This results in the DNS name to be:
jupyter-77e417a2b692b459f1deaac61b3bf5ba-
which is against the regex for DNS names in Docker ^[a-zA-Z0-9](?:[-_]*[A-Za-z0-9]+)*$
as it contains a dash at the end.
This can be confirmed by changing this line:
https://github.com/cassinyio/SwarmSpawner/blob/master/cassinyspawner/swarmspawner.py#L156
from
return "{}-{}-{}".format(self.service_prefix,
to
return "{}-{}{}".format(self.service_prefix,
Possible solution:
I have a minor commit that fixes this issue by assigning the value of 1 to self.server_name after the if statement:
MAliNaqvi@49fb55b
Hi @MAliNaqvi, thanks for the issue.
The case where server_name
is not specified should be handled inside https://github.com/cassinyio/SwarmSpawner/blob/master/cassinyspawner/swarmspawner.py#L142
I just updated the master branch with a new commit.
Can you check if it works?
Hi @barrachri thank you for the quick response.
The change doesn't work.
https://www.dropbox.com/s/wv8lxyqlryg52yh/Screenshot%202017-03-16%2019.00.15.png?dl=0
the left terminal the server logs with the error
right terminal I show the docker container which is running the hub, as well as the latest incorporated code
@barrachri
A colleague of mine @evgeniwk tracked the problem to this line:
This section relates to allowing multiple servers per user. If we set c.JupyterHub.allow_multiple_servers = False
to JupyterHub.allow_multiple_servers = True
The server_name appears correctly:
https://www.dropbox.com/s/snn9reyg0cvj1a8/Screenshot%202017-03-16%2019.13.50.png?dl=0
but there is a 404.
So the problem was that 'self.server_name' always exists and is not none but ''
that is False.
You can remove 'c.JupyterHub.allow_multiple_servers = False' because we are still working on this feature.
With the last commit this problem should be resolved.
If you get a 404 error:
- Check from docker if the service is running
- Check if you created an overlay network between the jupyterhub and the new service, otherwise jupyterhub cannot reach the service
The new change
SwarmSpawner/cassinyspawner/swarmspawner.py
Lines 150 to 153 in 254f078
gives an attribute error:
jupyterhub.1.mpvej68c1wtx@moby | File "/srv/jupyterhub/src/swarmspawner/cassinyspawner/swarmspawner.py", line 150, in service_name
jupyterhub.1.mpvej68c1wtx@moby | if self.server_name:
jupyterhub.1.mpvej68c1wtx@moby | AttributeError: 'SwarmSpawner' object has no attribute 'server_name'
We can solve it either by:
if hasattr(self, 'server_name'):
if self.server_name:
server_name = self.server_name
else:
server_name = 1
else:
server_name = 1
or a simpler version would be:
server_name = 1
if hasattr(self, 'server_name'):
if self.server_name:
server_name = self.server_name
I have tested both and they work.
Hi @MAliNaqvi thanks for the patient.
So service_name
is also called outside def start()
this why we get AttributeError
.
With the last version of the spawner it works.
I am waiting for a feedback to close this issue.
@barrachri yes the latest code works. This issue can be closed.