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

Spawn delay while waiting for DNS update #279

Open
statiksof opened this issue Dec 4, 2018 · 21 comments
Open

Spawn delay while waiting for DNS update #279

statiksof opened this issue Dec 4, 2018 · 21 comments

Comments

@statiksof
Copy link

Hi,
sorry to insist on this, but I didn't get any answer for it.
Using lastest JH and DockerSpawner version.

Spawning is too slow (~30 seconds and sometimes more). Does anyone of you experienced this before?

@minrk
Copy link
Member

minrk commented Dec 4, 2018

Can you share the logs of jupyterhub --debug during a spawn? And perhaps try to identify some timings of when the container is created, starts, becomes responsive, and finally the user is redirected?

@statiksof
Copy link
Author

statiksof commented Dec 5, 2018

12/5/2018 12:09:48 PM[I 2018-12-05 11:09:48.353 JupyterHub dockerspawner:564] Container 'jupyter-demo' is gone
12/5/2018 12:09:49 PM[I 2018-12-05 11:09:49.346 JupyterHub dockerspawner:698] Created container jupyter-demo (id: e79ed3a) from image 
12/5/2018 12:09:49 PM[I 2018-12-05 11:09:49.346 JupyterHub dockerspawner:721] Starting container jupyter-demo (id: e79ed3a)
12/5/2018 12:09:58 PM[W 2018-12-05 11:09:58.304 JupyterHub base:699] User demo is slow to become responsive (timeout=10)
12/5/2018 12:09:58 PM[I 2018-12-05 11:09:58.325 JupyterHub log:158] 302 POST /jupyter/hub/spawn?next=%2Fjupyter%2Fhub%2Fuser%2Fdemo%2F -> /jupyter/hub/user/demo/ (demo@::ffff:172.17.0.1) 10035.10ms
12/5/2018 12:10:00 PM[I 2018-12-05 11:10:00.390 JupyterHub log:158] 200 GET /jupyter/hub/api (@172.17.0.4) 1.00ms
12/5/2018 12:10:02 PM[I 2018-12-05 11:10:02.115 JupyterHub base:628] User demo took 13.816 seconds to start
12/5/2018 12:10:02 PM[I 2018-12-05 11:10:02.116 JupyterHub proxy:242] Adding user demo to proxy /jupyter/user/demo/ => http://172.17.0.4:8888
12/5/2018 12:10:02 PM11:10:02.117 - info: [ConfigProxy] Adding route /jupyter/user/demo -> http://172.17.0.4:8888
12/5/2018 12:10:02 PM11:10:02.118 - info: [ConfigProxy] 201 POST /api/routes/jupyter/user/demo
12/5/2018 12:10:02 PM[I 2018-12-05 11:10:02.123 JupyterHub log:158] 302 GET /jupyter/hub/user/demo/ -> /jupyter/user/demo/?redirects=1 (demo@::ffff:172.17.0.1) 3782.58ms
12/5/2018 12:10:02 PM[I 2018-12-05 11:10:02.210 JupyterHub log:158] 302 GET /jupyter/hub/api/oauth2/authorize?client_id=jupyterhub-user-demo&redirect_uri=%2Fjupyter%2Fuser%2Fdemo%2Foauth_callback&response_type=code&state=[secret] -> /jupyter/user/demo/oauth_callback?code=[secret]&state=[secret] (demo@::ffff:172.17.0.1) 36.80ms
12/5/2018 12:10:02 PM[I 2018-12-05 11:10:02.347 JupyterHub log:158] 200 POST /jupyter/hub/api/oauth2/token ([email protected]) 66.78ms
12/5/2018 12:10:02 PM[I 2018-12-05 11:10:02.425 JupyterHub log:158] 200 GET /jupyter/hub/api/authorizations/token/[secret] ([email protected]) 58.34ms

@minrk
Copy link
Member

minrk commented Dec 5, 2018

Thanks! Do you also have the logs of the jupyter-demo container?

@statiksof
Copy link
Author

12/5/2018 2:49:33 PM/usr/local/bin/start-singleuser.sh: ignoring /usr/local/bin/start-notebook.d/*
12/5/2018 2:49:33 PM
12/5/2018 2:49:33 PMContainer must be run with group root to update passwd file
12/5/2018 2:49:33 PMExecuting the command: jupyterhub-singleuser --ip="0.0.0.0" --port=8888 --notebook-dir="/home/jovyan/work" --debug
12/5/2018 2:49:40 PM[D 2018-12-05 13:49:40.718 SingleUserNotebookApp application:177] Searching ['/home/jovyan', '/home/jovyan/.jupyter', '/opt/conda/etc/jupyter', '/usr/local/etc/jupyter', '/etc/jupyter'] for config files
12/5/2018 2:49:40 PM[D 2018-12-05 13:49:40.719 SingleUserNotebookApp application:555] Looking for jupyter_config in /etc/jupyter
12/5/2018 2:49:40 PM[D 2018-12-05 13:49:40.758 SingleUserNotebookApp application:555] Looking for jupyter_config in /usr/local/etc/jupyter
12/5/2018 2:49:40 PM[D 2018-12-05 13:49:40.759 SingleUserNotebookApp application:555] Looking for jupyter_config in /opt/conda/etc/jupyter
12/5/2018 2:49:40 PM[D 2018-12-05 13:49:40.769 SingleUserNotebookApp application:555] Looking for jupyter_config in /home/jovyan/.jupyter
12/5/2018 2:49:40 PM[D 2018-12-05 13:49:40.770 SingleUserNotebookApp application:555] Looking for jupyter_config in /home/jovyan
12/5/2018 2:49:40 PM[D 2018-12-05 13:49:40.771 SingleUserNotebookApp application:555] Looking for jupyter_notebook_config in /etc/jupyter
12/5/2018 2:49:40 PM[D 2018-12-05 13:49:40.780 SingleUserNotebookApp application:577] Loaded config file: /etc/jupyter/jupyter_notebook_config.py
12/5/2018 2:49:40 PM[D 2018-12-05 13:49:40.780 SingleUserNotebookApp application:555] Looking for jupyter_notebook_config in /usr/local/etc/jupyter
12/5/2018 2:49:40 PM[D 2018-12-05 13:49:40.781 SingleUserNotebookApp application:555] Looking for jupyter_notebook_config in /opt/conda/etc/jupyter
12/5/2018 2:49:40 PM[D 2018-12-05 13:49:40.788 SingleUserNotebookApp application:577] Loaded config file: /opt/conda/etc/jupyter/jupyter_notebook_config.json
12/5/2018 2:49:40 PM[D 2018-12-05 13:49:40.788 SingleUserNotebookApp application:555] Looking for jupyter_notebook_config in /home/jovyan/.jupyter
12/5/2018 2:49:40 PM[D 2018-12-05 13:49:40.789 SingleUserNotebookApp application:555] Looking for jupyter_notebook_config in /home/jovyan
12/5/2018 2:49:40 PM[W 2018-12-05 13:49:40.834 SingleUserNotebookApp configurable:168] Config option `open_browser` not recognized by `SingleUserNotebookApp`.  Did you mean `browser`?
12/5/2018 2:49:43 PM[D 2018-12-05 13:49:43.388 SingleUserNotebookApp config_manager:80] Paths used for configuration of jupyter_notebook_config:
12/5/2018 2:49:43 PM    	/etc/jupyter/jupyter_notebook_config.json
12/5/2018 2:49:43 PM[D 2018-12-05 13:49:43.389 SingleUserNotebookApp config_manager:80] Paths used for configuration of jupyter_notebook_config:
12/5/2018 2:49:43 PM    	/usr/local/etc/jupyter/jupyter_notebook_config.json
12/5/2018 2:49:43 PM[D 2018-12-05 13:49:43.393 SingleUserNotebookApp config_manager:80] Paths used for configuration of jupyter_notebook_config:
12/5/2018 2:49:43 PM    	/opt/conda/etc/jupyter/jupyter_notebook_config.d/jupyterlab.json
12/5/2018 2:49:43 PM    	/opt/conda/etc/jupyter/jupyter_notebook_config.json
12/5/2018 2:49:43 PM[D 2018-12-05 13:49:43.401 SingleUserNotebookApp config_manager:80] Paths used for configuration of jupyter_notebook_config:
12/5/2018 2:49:43 PM    	/home/jovyan/.jupyter/jupyter_notebook_config.json
12/5/2018 2:49:43 PM[I 2018-12-05 13:49:43.518 SingleUserNotebookApp extension:53] JupyterLab beta preview extension loaded from /opt/conda/lib/python3.6/site-packages/jupyterlab
12/5/2018 2:49:43 PM[I 2018-12-05 13:49:43.518 SingleUserNotebookApp extension:54] JupyterLab application directory is /opt/conda/share/jupyter/lab
12/5/2018 2:49:43 PM[I 2018-12-05 13:49:43.577 SingleUserNotebookApp singleuser:406] Starting jupyterhub-singleuser server version 0.9.4
12/5/2018 2:49:43 PM[D 2018-12-05 13:49:43.584 SingleUserNotebookApp _version:50] jupyterhub version 0.9.1 != jupyterhub-singleuser version 0.9.4.
12/5/2018 2:49:43 PM[I 2018-12-05 13:49:43.584 SingleUserNotebookApp notebookapp:1585] Serving notebooks from local directory: /home/jovyan/work
12/5/2018 2:49:43 PM[I 2018-12-05 13:49:43.585 SingleUserNotebookApp notebookapp:1585] 0 active kernels
12/5/2018 2:49:43 PM[I 2018-12-05 13:49:43.585 SingleUserNotebookApp notebookapp:1585] The Jupyter Notebook is running at:
12/5/2018 2:49:43 PM[I 2018-12-05 13:49:43.585 SingleUserNotebookApp notebookapp:1585] http://0.0.0.0:8888/jupyter/user/demo/
12/5/2018 2:49:43 PM[I 2018-12-05 13:49:43.585 SingleUserNotebookApp notebookapp:1586] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
12/5/2018 2:49:44 PM[I 2018-12-05 13:49:44.329 SingleUserNotebookApp log:158] 302 GET /jupyter/user/demo/ -> /jupyter/user/demo/tree? (@172.17.0.3) 0.84ms
12/5/2018 2:49:44 PM[I 2018-12-05 13:49:44.354 SingleUserNotebookApp log:158] 302 GET /jupyter/user/demo/?redirects=1 -> /jupyter/user/demo/tree?redirects=1 (@::ffff:172.17.0.1) 0.79ms
12/5/2018 2:49:44 PM[D 2018-12-05 13:49:44.377 SingleUserNotebookApp auth:421] No user identified
12/5/2018 2:49:44 PM[D 2018-12-05 13:49:44.379 SingleUserNotebookApp auth:741] Redirecting to login url: /jupyter/hub/api/oauth2/authorize?client_id=jupyterhub-user-demo&redirect_uri=%2Fjupyter%2Fuser%2Fdemo%2Foauth_callback&response_type=code&state=eyJ1dWlkIjogIjU0MzAxNmU4ODUxMTQ3NzU5ZmZmNDRlNmQxNGIwOWU4IiwgIm5leHRfdXJsIjogIi9qdXB5dGVyL3VzZXIvZGVtby90cmVlP3JlZGlyZWN0cz0xIn0
12/5/2018 2:49:44 PM[I 2018-12-05 13:49:44.379 SingleUserNotebookApp log:158] 302 GET /jupyter/user/demo/tree?redirects=1 -> /jupyter/hub/api/oauth2/authorize?client_id=jupyterhub-user-demo&redirect_uri=%2Fjupyter%2Fuser%2Fdemo%2Foauth_callback&response_type=code&state=[secret] (@::ffff:172.17.0.1) 2.94ms
12/5/2018 2:49:44 PM[D 2018-12-05 13:49:44.441 SingleUserNotebookApp auth:421] No user identified
12/5/2018 2:49:44 PM[D 2018-12-05 13:49:44.486 SingleUserNotebookApp auth:263] Cache miss: token:8ee2ce3e291a49ec83529589c1ac3420:6af483cf-731d-4439-b92b-b40435ed542e
12/5/2018 2:49:44 PM[D 2018-12-05 13:49:44.511 SingleUserNotebookApp auth:269] Received request from Hub user {'kind': 'user', 'name': 'demo', 'admin': False, 'groups': [], 'server': '/jupyter/user/demo/', 'pending': None, 'created': '2018-12-03T09:03:21.468173Z', 'last_activity': '2018-12-05T13:49:44.505567Z', 'servers': None}
12/5/2018 2:49:44 PM[I 2018-12-05 13:49:44.511 SingleUserNotebookApp auth:875] Logged-in user {'kind': 'user', 'name': 'demo', 'admin': False, 'groups': [], 'server': '/jupyter/user/demo/', 'pending': None, 'created': '2018-12-03T09:03:21.468173Z', 'last_activity': '2018-12-05T13:49:44.505567Z', 'servers': None}
12/5/2018 2:49:44 PM[D 2018-12-05 13:49:44.511 SingleUserNotebookApp auth:656] Setting oauth cookie for ::ffff:172.17.0.1: jupyterhub-user-demo, {'path': '/jupyter/user/demo/', 'httponly': True}
12/5/2018 2:49:44 PM[I 2018-12-05 13:49:44.512 SingleUserNotebookApp log:158] 302 GET /jupyter/user/demo/oauth_callback?code=[secret]&state=[secret] -> /jupyter/user/demo/tree?redirects=1 (@::ffff:172.17.0.1) 71.88ms
12/5/2018 2:49:44 PM[D 2018-12-05 13:49:44.538 SingleUserNotebookApp auth:778] Allowing whitelisted Hub user demo
12/5/2018 2:49:44 PM[D 2018-12-05 13:49:44.538 SingleUserNotebookApp handlers:262] Using contents: services/contents
12/5/2018 2:49:44 PM[D 2018-12-05 13:49:44.653 SingleUserNotebookApp handlers:724] Path base/images/favicon.ico served from /opt/conda/lib/python3.6/site-packages/notebook/static/base/images/favicon.ico
12/5/2018 2:49:44 PM[D 2018-12-05 13:49:44.705 SingleUserNotebookApp handlers:724] Path components/jquery-ui/themes/smoothness/jquery-ui.min.css served from /opt/conda/lib/python3.6/site-packages/notebook/static/components/jquery-ui/themes/smoothness/jquery-ui.min.css
12/5/2018 2:49:44 PM[D 2018-12-05 13:49:44.747 SingleUserNotebookApp handlers:724] Path components/jquery-typeahead/dist/jquery.typeahead.min.css served from /opt/conda/lib/python3.6/site-packages/notebook/static/components/jquery-typeahead/dist/jquery.typeahead.min.css
12/5/2018 2:49:44 PM[D 2018-12-05 13:49:44.757 SingleUserNotebookApp handlers:724] Path style/style.min.css served from /opt/conda/lib/python3.6/site-packages/notebook/static/style/style.min.css
12/5/2018 2:49:44 PM[D 2018-12-05 13:49:44.776 SingleUserNotebookApp handlers:724] Path components/es6-promise/promise.min.js served from /opt/conda/lib/python3.6/site-packages/notebook/static/components/es6-promise/promise.min.js
12/5/2018 2:49:44 PM[D 2018-12-05 13:49:44.779 SingleUserNotebookApp handlers:724] Path components/preact/index.js served from /opt/conda/lib/python3.6/site-packages/notebook/static/components/preact/index.js
12/5/2018 2:49:44 PM[D 2018-12-05 13:49:44.788 SingleUserNotebookApp handlers:724] Path components/proptypes/index.js served from /opt/conda/lib/python3.6/site-packages/notebook/static/components/proptypes/index.js
12/5/2018 2:49:44 PM[D 2018-12-05 13:49:44.789 SingleUserNotebookApp handlers:724] Path components/preact-compat/index.js served from /opt/conda/lib/python3.6/site-packages/notebook/static/components/preact-compat/index.js
12/5/2018 2:49:44 PM[D 2018-12-05 13:49:44.799 SingleUserNotebookApp handlers:724] Path components/requirejs/require.js served from /opt/conda/lib/python3.6/site-packages/notebook/static/components/requirejs/require.js
12/5/2018 2:49:44 PM[D 2018-12-05 13:49:44.812 SingleUserNotebookApp handlers:724] Path tree/js/main.min.js served from /opt/conda/lib/python3.6/site-packages/notebook/static/tree/js/main.min.js
12/5/2018 2:49:44 PM[I 2018-12-05 13:49:44.856 SingleUserNotebookApp log:158] 200 GET /jupyter/user/demo/tree?redirects=1 (demo@::ffff:172.17.0.1) 318.83ms
12/5/2018 2:49:44 PM[D 2018-12-05 13:49:44.989 SingleUserNotebookApp auth:778] Allowing whitelisted Hub user demo
12/5/2018 2:49:44 PM[D 2018-12-05 13:49:44.989 SingleUserNotebookApp handlers:724] Path custom.css served from /opt/conda/lib/python3.6/site-packages/notebook/static/custom/custom.css
12/5/2018 2:49:44 PM[D 2018-12-05 13:49:44.990 SingleUserNotebookApp log:158] 304 GET /jupyter/user/demo/custom/custom.css (demo@::ffff:172.17.0.1) 2.18ms
12/5/2018 2:49:45 PM[D 2018-12-05 13:49:45.257 SingleUserNotebookApp auth:778] Allowing whitelisted Hub user demo
12/5/2018 2:49:45 PM[D 2018-12-05 13:49:45.258 SingleUserNotebookApp handlers:724] Path services/contents.js served from /opt/conda/lib/python3.6/site-packages/notebook/static/services/contents.js
12/5/2018 2:49:45 PM[D 2018-12-05 13:49:45.267 SingleUserNotebookApp log:158] 200 GET /jupyter/user/demo/static/services/contents.js?v=20181205134940 (demo@::ffff:172.17.0.1) 10.44ms
12/5/2018 2:49:45 PM[D 2018-12-05 13:49:45.322 SingleUserNotebookApp auth:778] Allowing whitelisted Hub user demo
12/5/2018 2:49:45 PM[D 2018-12-05 13:49:45.323 SingleUserNotebookApp config_manager:80] Paths used for configuration of tree:
12/5/2018 2:49:45 PM    	/etc/jupyter/nbconfig/tree.json
12/5/2018 2:49:45 PM[D 2018-12-05 13:49:45.324 SingleUserNotebookApp config_manager:80] Paths used for configuration of tree:
12/5/2018 2:49:45 PM    	/usr/local/etc/jupyter/nbconfig/tree.json
12/5/2018 2:49:45 PM[D 2018-12-05 13:49:45.332 SingleUserNotebookApp config_manager:80] Paths used for configuration of tree:
12/5/2018 2:49:45 PM    	/opt/conda/etc/jupyter/nbconfig/tree.json
12/5/2018 2:49:45 PM[D 2018-12-05 13:49:45.333 SingleUserNotebookApp config_manager:80] Paths used for configuration of tree:
12/5/2018 2:49:45 PM    	/home/jovyan/.jupyter/nbconfig/tree.json
12/5/2018 2:49:45 PM[I 2018-12-05 13:49:45.334 SingleUserNotebookApp log:158] 200 GET /jupyter/user/demo/api/config/tree?_=1544017727822 (demo@::ffff:172.17.0.1) 12.51ms
12/5/2018 2:49:45 PM[D 2018-12-05 13:49:45.335 SingleUserNotebookApp auth:778] Allowing whitelisted Hub user demo
12/5/2018 2:49:45 PM[I 2018-12-05 13:49:45.336 SingleUserNotebookApp log:158] 200 GET /jupyter/user/demo/api/terminals?_=1544017727824 (demo@::ffff:172.17.0.1) 1.19ms
12/5/2018 2:49:45 PM[D 2018-12-05 13:49:45.337 SingleUserNotebookApp auth:778] Allowing whitelisted Hub user demo
12/5/2018 2:49:45 PM[D 2018-12-05 13:49:45.338 SingleUserNotebookApp config_manager:80] Paths used for configuration of common:
12/5/2018 2:49:45 PM    	/etc/jupyter/nbconfig/common.json
12/5/2018 2:49:45 PM[D 2018-12-05 13:49:45.338 SingleUserNotebookApp config_manager:80] Paths used for configuration of common:
12/5/2018 2:49:45 PM    	/usr/local/etc/jupyter/nbconfig/common.json
12/5/2018 2:49:45 PM[D 2018-12-05 13:49:45.339 SingleUserNotebookApp config_manager:80] Paths used for configuration of common:
12/5/2018 2:49:45 PM    	/opt/conda/etc/jupyter/nbconfig/common.json
12/5/2018 2:49:45 PM[D 2018-12-05 13:49:45.339 SingleUserNotebookApp config_manager:80] Paths used for configuration of common:
12/5/2018 2:49:45 PM    	/home/jovyan/.jupyter/nbconfig/common.json
12/5/2018 2:49:45 PM[I 2018-12-05 13:49:45.340 SingleUserNotebookApp log:158] 200 GET /jupyter/user/demo/api/config/common?_=1544017727823 (demo@::ffff:172.17.0.1) 3.14ms
12/5/2018 2:49:45 PM[D 2018-12-05 13:49:45.341 SingleUserNotebookApp auth:778] Allowing whitelisted Hub user demo
12/5/2018 2:49:45 PM[D 2018-12-05 13:49:45.357 SingleUserNotebookApp kernelspec:169] Found kernel python3 in /opt/conda/share/jupyter/kernels
12/5/2018 2:49:45 PM[D 2018-12-05 13:49:45.380 SingleUserNotebookApp log:158] 304 GET /jupyter/user/demo/api/kernelspecs (demo@::ffff:172.17.0.1) 39.36ms
12/5/2018 2:49:45 PM[D 2018-12-05 13:49:45.381 SingleUserNotebookApp auth:778] Allowing whitelisted Hub user demo
12/5/2018 2:49:45 PM[I 2018-12-05 13:49:45.414 SingleUserNotebookApp log:158] 200 GET /jupyter/user/demo/api/sessions?_=1544017727825 (demo@::ffff:172.17.0.1) 33.08ms
12/5/2018 2:49:45 PM[D 2018-12-05 13:49:45.415 SingleUserNotebookApp auth:778] Allowing whitelisted Hub user demo
12/5/2018 2:49:45 PM[I 2018-12-05 13:49:45.416 SingleUserNotebookApp log:158] 200 GET /jupyter/user/demo/api/terminals?_=1544017727826 (demo@::ffff:172.17.0.1) 1.06ms
12/5/2018 2:49:45 PM[D 2018-12-05 13:49:45.417 SingleUserNotebookApp auth:778] Allowing whitelisted Hub user demo
12/5/2018 2:49:45 PM[D 2018-12-05 13:49:45.417 SingleUserNotebookApp handlers:724] Path custom.js served from /opt/conda/lib/python3.6/site-packages/notebook/static/custom/custom.js
12/5/2018 2:49:45 PM[D 2018-12-05 13:49:45.418 SingleUserNotebookApp log:158] 200 GET /jupyter/user/demo/custom/custom.js?v=20181205134940 (demo@::ffff:172.17.0.1) 2.10ms
12/5/2018 2:49:45 PM[D 2018-12-05 13:49:45.432 SingleUserNotebookApp auth:778] Allowing whitelisted Hub user demo
12/5/2018 2:49:45 PM[I 2018-12-05 13:49:45.436 SingleUserNotebookApp log:158] 200 GET /jupyter/user/demo/api/contents?type=directory&_=1544017727827 (demo@::ffff:172.17.0.1) 4.98ms

@Mohitsharma44
Copy link

Mohitsharma44 commented Dec 6, 2018

Hi, I'm facing a similar issue of very slow spawning (~40 - 60secs) on swarmspawner as well.
Attaching logs for the hub & proxy and the service being spawned by the hub:

hub and proxy:

Starting jupyterhub_proxy_1 ... done
Starting jupyterhub_hub_1   ... done
Attaching to jupyterhub_hub_1, jupyterhub_proxy_1
hub_1    | [I 2018-12-06 04:10:04.879 JupyterHub app:1667] Using Authenticator: oauthenticator.generic.GenericOAuthenticator-0.8.0
hub_1    | [I 2018-12-06 04:10:04.879 JupyterHub app:1667] Using Spawner: dockerspawner.swarmspawner.SwarmSpawner-0.10.0
hub_1    | [I 2018-12-06 04:10:04.882 JupyterHub app:1014] Loading cookie_secret from /srv/jupyterhub/jupyterhub_cookie_secret
hub_1    | [D 2018-12-06 04:10:04.883 JupyterHub app:1069] Connecting to db: sqlite:///jupyterhub.sqlite
hub_1    | [D 2018-12-06 04:10:04.900 JupyterHub orm:685] database schema version found: 896818069c98
hub_1    | [W 2018-12-06 04:10:04.906 JupyterHub app:1171] No admin users, admin interface will be unavailable.
hub_1    | [W 2018-12-06 04:10:04.906 JupyterHub app:1172] Add any administrative users to `c.Authenticator.admin_users` in config.
hub_1    | [I 2018-12-06 04:10:04.906 JupyterHub app:1199] Not using whitelist. Any authenticated user will be allowed.
hub_1    | [D 2018-12-06 04:10:04.936 JupyterHub app:1471] Loading state for foo from db
hub_1    | [D 2018-12-06 04:10:04.938 JupyterHub app:1487] Loaded users:
hub_1    |          foo
hub_1    | [W 2018-12-06 04:10:04.940 JupyterHub app:1513] Deleting OAuth client jupyterhub-user-foo
hub_1    | [I 2018-12-06 04:10:04.956 JupyterHub app:1849] Hub API listening on http://0.0.0.0:8081/hub/
hub_1    | [I 2018-12-06 04:10:04.956 JupyterHub app:1851] Private Hub API connect url http://hub:8081/hub/
hub_1    | [I 2018-12-06 04:10:04.956 JupyterHub app:1864] Not starting proxy
hub_1    | [D 2018-12-06 04:10:04.956 JupyterHub proxy:296] Fetching routes to check
proxy_1  | 04:10:05.584 - warn: [ConfigProxy] REST API is not authenticated.
proxy_1  | 04:10:05.596 - info: [ConfigProxy] Proxying http://*:8000 to (no default)
hub_1    | [D 2018-12-06 04:10:04.957 JupyterHub proxy:678] Proxy: Fetching GET http://proxy:8001/api/routes
hub_1    | [I 2018-12-06 04:10:24.681 JupyterHub proxy:301] Checking routes
proxy_1  | 04:10:05.596 - info: [ConfigProxy] Proxy API at http://0.0.0.0:8001/api/routes
proxy_1  | 04:10:24.683 - info: [ConfigProxy] 200 GET /api/routes 
proxy_1  | 04:10:24.685 - info: [ConfigProxy] Adding route / -> http://hub:8081
hub_1    | [I 2018-12-06 04:10:24.682 JupyterHub proxy:370] Adding default route for Hub: / => http://hub:8081
hub_1    | [D 2018-12-06 04:10:24.682 JupyterHub proxy:678] Proxy: Fetching POST http://proxy:8001/api/routes/
hub_1    | [I 2018-12-06 04:10:24.687 JupyterHub app:1906] JupyterHub is now running at http://:8000
hub_1    | [I 2018-12-06 04:10:31.048 JupyterHub log:158] 200 GET /hub/login (@100.8.219.135) 31.61ms
hub_1    | [I 2018-12-06 04:10:35.393 JupyterHub oauth2:82] OAuth redirect: 'http://ucsl.cusp.nyu.edu/hub/oauth_callback'
hub_1    | [I 2018-12-06 04:10:35.395 JupyterHub log:158] 302 GET /hub/oauth_login?next= -> https://id.ucsl.cusp.nyu.edu/auth/realms/ucsl/protocol/openid-connect/auth?redirect_uri=http%3A%2F%2Fucsl.cusp.nyu.edu%2Fhub%2Foauth_callback&client_id=ucsl-jupy&response_type=code&state=[secret] (@100.8.219.135) 1.94ms
hub_1    | [D 2018-12-06 04:10:38.492 JupyterHub base:357] Setting cookie jupyterhub-session-id: {'httponly': True}
hub_1    | [D 2018-12-06 04:10:38.492 JupyterHub base:362] Setting cookie for foo: jupyterhub-hub-login
hub_1    | [D 2018-12-06 04:10:38.492 JupyterHub base:357] Setting cookie jupyterhub-hub-login: {'httponly': True, 'path': '/hub/'}
hub_1    | [I 2018-12-06 04:10:38.492 JupyterHub base:499] User logged in: foo
hub_1    | [I 2018-12-06 04:10:38.493 JupyterHub log:158] 302 GET /hub/oauth_callback?state=[secret]&session_state=[secret]&code=[secret] -> /user/foo/ (@100.8.219.135) 32.41ms
hub_1    | [I 2018-12-06 04:10:38.509 JupyterHub log:158] 302 GET /user/foo/ -> /hub/user/foo/ (@100.8.219.135) 0.52ms
hub_1    | [D 2018-12-06 04:10:38.533 JupyterHub user:190] Creating <class 'dockerspawner.swarmspawner.SwarmSpawner'> for foo:
hub_1    | [W 2018-12-06 04:10:38.538 JupyterHub configurable:168] Config option `remove_services` not recognized by `SwarmSpawner`.  Did you mean `remove_containers`?
hub_1    | [D 2018-12-06 04:10:38.538 JupyterHub base:603] Initiating spawn for foo
hub_1    | [D 2018-12-06 04:10:38.539 JupyterHub base:609] 0/100 concurrent spawns
hub_1    | [D 2018-12-06 04:10:38.539 JupyterHub base:612] 0 active servers
hub_1    | [D 2018-12-06 04:10:38.561 JupyterHub dockerspawner:557] Getting container 'jupyter-foo'
hub_1    | [I 2018-12-06 04:10:38.570 JupyterHub dockerspawner:564] Service 'jupyter-foo' is gone
hub_1    | [I 2018-12-06 04:10:38.576 JupyterHub dockerspawner:698] Created service jupyter-foo (id: p61xi9v) from image jupyterhub/singleuser:0.9
hub_1    | [I 2018-12-06 04:10:38.577 JupyterHub dockerspawner:721] Starting service jupyter-foo (id: p61xi9v)
hub_1    | [D 2018-12-06 04:10:38.580 JupyterHub spawner:850] Polling subprocess every 30s
hub_1    | [I 2018-12-06 04:10:41.565 JupyterHub log:158] 200 GET /hub/api (@10.0.0.45) 0.87ms
hub_1    | [D 2018-12-06 04:10:41.624 JupyterHub utils:188] Server at http://jupyter-foo:8888/user/foo/ responded with 302
hub_1    | [D 2018-12-06 04:10:41.624 JupyterHub _version:50] jupyterhub version 0.9.2 != jupyterhub-singleuser version 0.9.4.
hub_1    | [I 2018-12-06 04:10:41.624 JupyterHub base:628] User foo took 3.085 seconds to start
hub_1    | [I 2018-12-06 04:10:41.624 JupyterHub proxy:242] Adding user foo to proxy /user/foo/ => http://jupyter-foo:8888
proxy_1  | 04:10:24.687 - info: [ConfigProxy] 201 POST /api/routes/ 
hub_1    | [D 2018-12-06 04:10:41.624 JupyterHub proxy:678] Proxy: Fetching POST http://proxy:8001/api/routes/user/foo
proxy_1  | 04:10:41.626 - info: [ConfigProxy] Adding route /user/foo -> http://jupyter-foo:8888
hub_1    | [I 2018-12-06 04:10:41.627 JupyterHub log:158] 302 GET /hub/user/foo/ -> /user/foo/?redirects=1 ([email protected]) 3098.85ms
hub_1    | [I 2018-12-06 04:10:41.694 JupyterHub log:158] 302 GET /hub/api/oauth2/authorize?client_id=jupyterhub-user-foo&redirect_uri=%2Fuser%2Ffoo%2Foauth_callback&response_type=code&state=[secret] -> /user/foo/oauth_callback?code=[secret]&state=[secret] ([email protected]) 13.44ms
hub_1    | [D 2018-12-06 04:11:08.583 JupyterHub swarmspawner:137] Getting task of service 'jupyter-foo'
hub_1    | [D 2018-12-06 04:11:08.583 JupyterHub dockerspawner:557] Getting container 'jupyter-foo'
hub_1    | [D 2018-12-06 04:11:08.590 JupyterHub swarmspawner:126] Service p61xi9v status: {'ContainerStatus': {'ContainerID': '6504204b3e86476fa7881ded5fac929efcdf9dcf80ca36b31b49fa997c9754b3',
hub_1    |                          'ExitCode': 0,
hub_1    |                          'PID': 17762},
hub_1    |      'Message': 'started',
hub_1    |      'PortStatus': {},
hub_1    |      'State': 'running',
hub_1    |      'Timestamp': '2018-12-06T04:10:40.366445781Z'}
hub_1    | [I 2018-12-06 04:11:24.754 JupyterHub log:158] 200 POST /hub/api/oauth2/token ([email protected]) 19.65ms
hub_1    | [I 2018-12-06 04:11:30.925 JupyterHub log:158] 200 GET /hub/api/authorizations/token/[secret] ([email protected]) 14.26ms
hub_1    | [D 2018-12-06 04:11:38.583 JupyterHub swarmspawner:137] Getting task of service 'jupyter-foo'
hub_1    | [D 2018-12-06 04:11:38.583 JupyterHub dockerspawner:557] Getting container 'jupyter-foo'
hub_1    | [D 2018-12-06 04:11:38.590 JupyterHub swarmspawner:126] Service p61xi9v status: {'ContainerStatus': {'ContainerID': '6504204b3e86476fa7881ded5fac929efcdf9dcf80ca36b31b49fa997c9754b3',
hub_1    |                          'ExitCode': 0,
hub_1    |                          'PID': 17762},
hub_1    |      'Message': 'started',
hub_1    |      'PortStatus': {},
hub_1    |      'State': 'running',
hub_1    |      'Timestamp': '2018-12-06T04:10:40.366445781Z'}

jupy-foo

jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:10:41.194 SingleUserLabApp application:177] Searching ['/home/jovyan', '/home/jovyan/.jupyter', '/opt/conda/etc/jupyter', '/usr/local/etc/jupyter', '/etc/jupyter'] for config files
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:10:41.194 SingleUserLabApp application:555] Looking for jupyter_config in /etc/jupyter
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:10:41.194 SingleUserLabApp application:555] Looking for jupyter_config in /usr/local/etc/jupyter
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:10:41.195 SingleUserLabApp application:555] Looking for jupyter_config in /opt/conda/etc/jupyter
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:10:41.195 SingleUserLabApp application:555] Looking for jupyter_config in /home/jovyan/.jupyter
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:10:41.195 SingleUserLabApp application:555] Looking for jupyter_config in /home/jovyan
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:10:41.197 SingleUserLabApp application:555] Looking for jupyter_notebook_config in /etc/jupyter
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:10:41.198 SingleUserLabApp application:577] Loaded config file: /etc/jupyter/jupyter_notebook_config.py
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:10:41.198 SingleUserLabApp application:555] Looking for jupyter_notebook_config in /usr/local/etc/jupyter
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:10:41.198 SingleUserLabApp application:555] Looking for jupyter_notebook_config in /opt/conda/etc/jupyter
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:10:41.199 SingleUserLabApp application:577] Loaded config file: /opt/conda/etc/jupyter/jupyter_notebook_config.json
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:10:41.199 SingleUserLabApp application:555] Looking for jupyter_notebook_config in /home/jovyan/.jupyter
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:10:41.199 SingleUserLabApp application:577] Loaded config file: /home/jovyan/.jupyter/jupyter_notebook_config.py
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:10:41.199 SingleUserLabApp application:555] Looking for jupyter_notebook_config in /home/jovyan
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [W 2018-12-06 04:10:41.204 SingleUserLabApp configurable:168] Config option `open_browser` not recognized by `SingleUserLabApp`.  Did you mean `browser`?
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:10:41.536 SingleUserLabApp config_manager:98] Paths used for configuration of jupyter_notebook_config: 
jupyter-foo.1.vptx1rw1dzbf@ucsl1    |     	/etc/jupyter/jupyter_notebook_config.json
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:10:41.537 SingleUserLabApp config_manager:98] Paths used for configuration of jupyter_notebook_config: 
jupyter-foo.1.vptx1rw1dzbf@ucsl1    |     	/usr/local/etc/jupyter/jupyter_notebook_config.json
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:10:41.538 SingleUserLabApp config_manager:98] Paths used for configuration of jupyter_notebook_config: 
jupyter-foo.1.vptx1rw1dzbf@ucsl1    |     	/opt/conda/etc/jupyter/jupyter_notebook_config.d/jupyterlab.json
jupyter-foo.1.vptx1rw1dzbf@ucsl1    |     	/opt/conda/etc/jupyter/jupyter_notebook_config.json
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:10:41.539 SingleUserLabApp config_manager:98] Paths used for configuration of jupyter_notebook_config: 
jupyter-foo.1.vptx1rw1dzbf@ucsl1    |     	/home/jovyan/.jupyter/jupyter_notebook_config.json
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [I 2018-12-06 04:10:41.548 SingleUserLabApp extension:168] JupyterLab extension loaded from /opt/conda/lib/python3.7/site-packages/jupyterlab
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [I 2018-12-06 04:10:41.548 SingleUserLabApp extension:169] JupyterLab application directory is /opt/conda/share/jupyter/lab
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [W 2018-12-06 04:10:41.551 SingleUserLabApp labapp:375] JupyterLab server extension not enabled, manually loading...
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [I 2018-12-06 04:10:41.557 SingleUserLabApp extension:168] JupyterLab extension loaded from /opt/conda/lib/python3.7/site-packages/jupyterlab
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [I 2018-12-06 04:10:41.557 SingleUserLabApp extension:169] JupyterLab application directory is /opt/conda/share/jupyter/lab
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [I 2018-12-06 04:10:41.558 SingleUserLabApp singleuser:406] Starting jupyterhub-singleuser server version 0.9.4
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:10:41.567 SingleUserLabApp _version:50] jupyterhub version 0.9.2 != jupyterhub-singleuser version 0.9.4.
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [I 2018-12-06 04:10:41.567 SingleUserLabApp notebookapp:1712] Serving notebooks from local directory: /home/jovyan
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [I 2018-12-06 04:10:41.567 SingleUserLabApp notebookapp:1712] The Jupyter Notebook is running at:
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [I 2018-12-06 04:10:41.568 SingleUserLabApp notebookapp:1712] http://(6504204b3e86 or 127.0.0.1):8888/user/foo/?token=4cfb5ab7f8df4c5093fae85699112ee5
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [I 2018-12-06 04:10:41.568 SingleUserLabApp notebookapp:1713] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [C 2018-12-06 04:10:41.568 SingleUserLabApp notebookapp:1753] 
jupyter-foo.1.vptx1rw1dzbf@ucsl1    |     
jupyter-foo.1.vptx1rw1dzbf@ucsl1    |     Copy/paste this URL into your browser when you connect for the first time,
jupyter-foo.1.vptx1rw1dzbf@ucsl1    |     to login with a token:
jupyter-foo.1.vptx1rw1dzbf@ucsl1    |         http://(6504204b3e86 or 127.0.0.1):8888/user/foo/?token=4cfb5ab7f8df4c5093fae85699112ee5
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [I 2018-12-06 04:10:41.623 SingleUserLabApp log:158] 302 GET /user/foo/ -> /user/foo/lab? (@10.0.0.43) 0.84ms
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [I 2018-12-06 04:10:41.643 SingleUserLabApp log:158] 302 GET /user/foo/?redirects=1 -> /user/foo/lab?redirects=1 (@100.8.219.135) 0.74ms
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:10:41.661 SingleUserLabApp auth:421] No user identified
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:10:41.663 SingleUserLabApp auth:741] Redirecting to login url: /hub/api/oauth2/authorize?client_id=jupyterhub-user-foo&redirect_uri=%2Fuser%2Ffoo%2Foauth_callback&response_type=code&state=eyJ1dWlkIjogIjkxNzZjNzJjOGUzMjQ5ODE4MGJiODQ3Mzg0OTEzZDRhIiwgIm5leHRfdXJsIjogIi91c2VyL2Zvby9sYWI_cmVkaXJlY3RzPTEifQ
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [I 2018-12-06 04:10:41.664 SingleUserLabApp log:158] 302 GET /user/foo/lab?redirects=1 -> /hub/api/oauth2/authorize?client_id=jupyterhub-user-foo&redirect_uri=%2Fuser%2Ffoo%2Foauth_callback&response_type=code&state=[secret] (@100.8.219.135) 2.92ms
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:11:24.749 SingleUserLabApp auth:263] Cache miss: token:38c6ca34d9fa4d7b925fc946131dd906:f2a394f6-10af-4fa6-8fdc-444bae56d162
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:11:30.920 SingleUserLabApp auth:269] Received request from Hub user {'kind': 'user', 'name': 'foo', 'admin': False, 'groups': [], 'server': '/user/foo/', 'pending': None, 'created': '2018-12-06T04:00:38.735031Z', 'last_activity': '2018-12-06T04:11:30.914719Z', 'servers': None}
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [I 2018-12-06 04:11:30.921 SingleUserLabApp auth:875] Logged-in user {'kind': 'user', 'name': 'foo', 'admin': False, 'groups': [], 'server': '/user/foo/', 'pending': None, 'created': '2018-12-06T04:00:38.735031Z', 'last_activity': '2018-12-06T04:11:30.914719Z', 'servers': None}
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:11:30.921 SingleUserLabApp auth:656] Setting oauth cookie for 100.8.219.135: jupyterhub-user-foo, {'path': '/user/foo/', 'httponly': True}
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:11:30.922 SingleUserLabApp auth:421] No user identified
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [I 2018-12-06 04:11:30.922 SingleUserLabApp log:158] 302 GET /user/foo/oauth_callback?code=[secret]&state=[secret] -> /user/foo/lab?redirects=1 (@100.8.219.135) 49212.24ms
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:11:30.956 SingleUserLabApp auth:778] Allowing whitelisted Hub user foo
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:11:30.957 SingleUserLabApp handlers:264] Using contents: services/contents
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [I 2018-12-06 04:11:30.970 SingleUserLabApp log:158] 200 GET /user/foo/lab?redirects=1 ([email protected]) 14.70ms
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:11:31.008 SingleUserLabApp handlers:777] Path vendors~main.f7d700cb054103430786.js served from /opt/conda/share/jupyter/lab/static/vendors~main.f7d700cb054103430786.js
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:11:31.011 SingleUserLabApp handlers:777] Path main.a1919da7db3df31fddff.js served from /opt/conda/share/jupyter/lab/static/main.a1919da7db3df31fddff.js
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:11:31.013 SingleUserLabApp auth:778] Allowing whitelisted Hub user foo
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:11:31.013 SingleUserLabApp log:158] 200 GET /user/foo/lab/static/main.a1919da7db3df31fddff.js ([email protected]) 2.66ms
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:11:31.163 SingleUserLabApp auth:778] Allowing whitelisted Hub user foo
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:11:31.164 SingleUserLabApp log:158] 200 GET /user/foo/lab/static/vendors~main.f7d700cb054103430786.js ([email protected]) 155.29ms
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:11:31.797 SingleUserLabApp auth:263] Cache miss: token:38c6ca34d9fa4d7b925fc946131dd906:4cfb5ab7f8df4c5093fae85699112ee5
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:11:41.028 SingleUserLabApp auth:269] Received request from Hub user {'kind': 'user', 'name': 'foo', 'admin': False, 'groups': [], 'server': '/user/foo/', 'pending': None, 'created': '2018-12-06T04:00:38.735031Z', 'last_activity': '2018-12-06T04:11:41.024640Z', 'servers': None}
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:11:41.029 SingleUserLabApp auth:778] Allowing whitelisted Hub user foo
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [I 2018-12-06 04:11:41.030 SingleUserLabApp log:158] 200 GET /user/foo/api/terminals?1544069491780 ([email protected]) 9233.30ms
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:11:41.032 SingleUserLabApp auth:778] Allowing whitelisted Hub user foo
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:11:41.033 SingleUserLabApp kernelspec:169] Found kernel python3 in /opt/conda/share/jupyter/kernels
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [I 2018-12-06 04:11:41.037 SingleUserLabApp log:158] 200 GET /user/foo/api/kernelspecs?1544069491780 ([email protected]) 5.78ms
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:11:41.039 SingleUserLabApp auth:778] Allowing whitelisted Hub user foo
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [I 2018-12-06 04:11:41.042 SingleUserLabApp log:158] 200 GET /user/foo/lab/api/settings/@jupyterlab/application-extension:sidebar?1544069491824 ([email protected]) 3.31ms
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:11:41.043 SingleUserLabApp auth:778] Allowing whitelisted Hub user foo
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [I 2018-12-06 04:11:41.079 SingleUserLabApp log:158] 200 GET /user/foo/lab/api/settings/@jupyterlab/shortcuts-extension:plugin?1544069491825 ([email protected]) 36.44ms
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:11:41.081 SingleUserLabApp auth:778] Allowing whitelisted Hub user foo
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [I 2018-12-06 04:11:41.083 SingleUserLabApp log:158] 200 GET /user/foo/lab/api/settings/@jupyterlab/docmanager-extension:plugin?1544069491828 ([email protected]) 2.57ms
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:11:41.085 SingleUserLabApp auth:778] Allowing whitelisted Hub user foo
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [I 2018-12-06 04:11:41.086 SingleUserLabApp log:158] 200 GET /user/foo/lab/api/settings/@jupyterlab/apputils-extension:themes?1544069491830 ([email protected]) 2.38ms
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:11:41.088 SingleUserLabApp handlers:777] Path base/images/favicon.ico served from /opt/conda/lib/python3.7/site-packages/notebook/static/base/images/favicon.ico
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:11:41.089 SingleUserLabApp auth:778] Allowing whitelisted Hub user foo
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:11:41.089 SingleUserLabApp log:158] 200 GET /user/foo/static/base/images/favicon.ico ([email protected]) 1.44ms
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:11:41.091 SingleUserLabApp auth:778] Allowing whitelisted Hub user foo
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:11:41.094 SingleUserLabApp auth:778] Allowing whitelisted Hub user foo
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [I 2018-12-06 04:11:41.101 SingleUserLabApp log:158] 200 GET /user/foo/api/contents/?content=1&1544069492172 ([email protected]) 7.85ms
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:11:41.103 SingleUserLabApp auth:778] Allowing whitelisted Hub user foo
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [I 2018-12-06 04:11:41.105 SingleUserLabApp log:158] 200 GET /user/foo/lab/api/settings/@jupyterlab/extensionmanager-extension:plugin?1544069492178 ([email protected]) 2.99ms
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:11:41.107 SingleUserLabApp auth:778] Allowing whitelisted Hub user foo
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [I 2018-12-06 04:11:41.110 SingleUserLabApp log:158] 200 GET /user/foo/lab/api/settings/@jupyterlab/notebook-extension:tracker?1544069492186 ([email protected]) 4.30ms
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:11:41.112 SingleUserLabApp auth:778] Allowing whitelisted Hub user foo
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [I 2018-12-06 04:11:41.256 SingleUserLabApp log:158] 200 GET /user/foo/api/nbconvert?1544069492186 ([email protected]) 144.08ms
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:11:41.258 SingleUserLabApp auth:778] Allowing whitelisted Hub user foo
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [I 2018-12-06 04:11:41.261 SingleUserLabApp log:158] 200 GET /user/foo/lab/api/settings/@jupyterlab/fileeditor-extension:plugin?1544069492189 ([email protected]) 4.42ms
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:11:41.263 SingleUserLabApp auth:778] Allowing whitelisted Hub user foo
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [I 2018-12-06 04:11:41.326 SingleUserLabApp log:158] 200 GET /user/foo/api/nbconvert?1544069492223 ([email protected]) 63.50ms
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:11:41.327 SingleUserLabApp auth:778] Allowing whitelisted Hub user foo
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [I 2018-12-06 04:11:41.329 SingleUserLabApp log:158] 200 GET /user/foo/lab/api/settings/@jupyterlab/codemirror-extension:commands?1544069492226 ([email protected]) 2.46ms
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:11:41.331 SingleUserLabApp auth:778] Allowing whitelisted Hub user foo
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [I 2018-12-06 04:11:41.332 SingleUserLabApp log:158] 200 GET /user/foo/api/sessions?1544069492228 ([email protected]) 2.19ms
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:11:41.334 SingleUserLabApp auth:778] Allowing whitelisted Hub user foo
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [I 2018-12-06 04:11:41.335 SingleUserLabApp log:158] 200 GET /user/foo/api/sessions?1544069501129 ([email protected]) 1.39ms
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:11:41.337 SingleUserLabApp handlers:777] Path @jupyterlab/theme-light-extension/index.css served from /opt/conda/share/jupyter/lab/themes/@jupyterlab/theme-light-extension/index.css
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:11:41.345 SingleUserLabApp auth:778] Allowing whitelisted Hub user foo
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [W 2018-12-06 04:11:41.346 SingleUserLabApp web:1667] 404 GET /user/foo/lab/api/workspaces/user/foo/lab?1544069501200 (100.8.219.135): Workspace 'user/foo/lab' ('userfoolab-62ff') not found
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [W 2018-12-06 04:11:41.346 SingleUserLabApp handlers:568] Workspace 'user/foo/lab' ('userfoolab-62ff') not found
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [W 2018-12-06 04:11:41.346 SingleUserLabApp log:158] 404 GET /user/foo/lab/api/workspaces/user/foo/lab?1544069501200 ([email protected]) 2.29ms
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:11:41.352 SingleUserLabApp auth:778] Allowing whitelisted Hub user foo
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:11:41.352 SingleUserLabApp log:158] 200 GET /user/foo/lab/api/themes/@jupyterlab/theme-light-extension/index.css ([email protected]) 15.21ms
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:11:41.377 SingleUserLabApp auth:778] Allowing whitelisted Hub user foo
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:11:41.379 SingleUserLabApp handlers:18] Serving kernel resource from: /opt/conda/share/jupyter/kernels/python3
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:11:41.380 SingleUserLabApp log:158] 200 GET /user/foo/kernelspecs/python3/logo-64x64.png ([email protected]) 3.03ms
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:11:41.382 SingleUserLabApp auth:778] Allowing whitelisted Hub user foo
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [I 2018-12-06 04:11:41.383 SingleUserLabApp log:158] 204 PUT /user/foo/lab/api/workspaces/user/foo/lab?1544069501362 ([email protected]) 1.94ms
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [I 2018-12-06 04:11:41.456 SingleUserLabApp commands:1484] Node v8.10.0
jupyter-foo.1.vptx1rw1dzbf@ucsl1    |     
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [I 2018-12-06 04:11:41.464 SingleUserLabApp build_handler:43] Build is up to date
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [I 2018-12-06 04:11:41.465 SingleUserLabApp log:158] 200 GET /user/foo/lab/api/build?1544069492168 ([email protected]) 374.69ms
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:11:41.807 SingleUserLabApp auth:778] Allowing whitelisted Hub user foo
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [I 2018-12-06 04:11:41.808 SingleUserLabApp log:158] 200 GET /user/foo/api/sessions?1544069501783 ([email protected]) 1.70ms
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:11:41.809 SingleUserLabApp auth:778] Allowing whitelisted Hub user foo
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [I 2018-12-06 04:11:41.810 SingleUserLabApp log:158] 200 GET /user/foo/api/terminals?1544069501784 ([email protected]) 1.32ms
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:11:42.186 SingleUserLabApp auth:778] Allowing whitelisted Hub user foo
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [I 2018-12-06 04:11:42.188 SingleUserLabApp log:158] 200 GET /user/foo/api/contents/?content=1&1544069502175 ([email protected]) 2.90ms
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:11:42.245 SingleUserLabApp auth:778] Allowing whitelisted Hub user foo
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [I 2018-12-06 04:11:42.246 SingleUserLabApp log:158] 204 PUT /user/foo/lab/api/workspaces/user/foo/lab?1544069502231 ([email protected]) 1.74ms
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:11:54.380 SingleUserLabApp auth:778] Allowing whitelisted Hub user foo
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [I 2018-12-06 04:11:54.383 SingleUserLabApp log:158] 200 GET /user/foo/api/contents/?content=1&1544069514354 ([email protected]) 3.44ms
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:12:01.809 SingleUserLabApp auth:778] Allowing whitelisted Hub user foo
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [I 2018-12-06 04:12:01.810 SingleUserLabApp log:158] 200 GET /user/foo/api/terminals?1544069521786 ([email protected]) 1.79ms
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:12:01.812 SingleUserLabApp auth:778] Allowing whitelisted Hub user foo
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [I 2018-12-06 04:12:01.813 SingleUserLabApp log:158] 200 GET /user/foo/api/sessions?1544069521786 ([email protected]) 1.56ms
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:12:05.194 SingleUserLabApp auth:778] Allowing whitelisted Hub user foo
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [I 2018-12-06 04:12:05.196 SingleUserLabApp log:158] 200 GET /user/foo/api/contents/?content=1&1544069525175 ([email protected]) 3.30ms
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:12:11.811 SingleUserLabApp auth:778] Allowing whitelisted Hub user foo
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [I 2018-12-06 04:12:11.812 SingleUserLabApp log:158] 200 GET /user/foo/api/sessions?1544069531786 ([email protected]) 1.95ms
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:12:11.814 SingleUserLabApp auth:778] Allowing whitelisted Hub user foo
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [I 2018-12-06 04:12:11.814 SingleUserLabApp log:158] 200 GET /user/foo/api/terminals?1544069531786 ([email protected]) 1.20ms
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [D 2018-12-06 04:12:15.196 SingleUserLabApp auth:778] Allowing whitelisted Hub user foo
jupyter-foo.1.vptx1rw1dzbf@ucsl1    | [I 2018-12-06 04:12:15.199 SingleUserLabApp log:158] 200 GET /user/foo/api/contents/?content=1&1544069535178 ([email protected]) 3.39ms

FWIW, I'm using keycloak for oauth authentication but that seems to perform the authentication fairly quickly

@minrk
Copy link
Member

minrk commented Dec 6, 2018

From the logs, we have these key events:

# 10:31: login start
hub_1    | [I 2018-12-06 04:10:31.048 JupyterHub log:158] 200 GET /hub/login (@100.8.219.135) 31.61ms
# 10:38: login finish
hub_1    | [I 2018-12-06 04:10:38.492 JupyterHub base:499] User logged in: foo
# 10:38: spawn start
hub_1    | [D 2018-12-06 04:10:38.538 JupyterHub base:603] Initiating spawn for foo
# 10:41: server ready
hub_1    | [I 2018-12-06 04:10:41.624 JupyterHub base:628] User foo took 3.085 seconds to start
# 10:41: user redirected to server
hub_1    | [I 2018-12-06 04:10:41.627 JupyterHub log:158] 302 GET /hub/user/foo/ -> /user/foo/?redirects=1 ([email protected]) 3098.85ms
# 10:41 server handles oauth request, logs in user with hub
hub_1    | [I 2018-12-06 04:10:41.694 JupyterHub log:158] 302 GET /hub/api/oauth2/authorize?client_id=jupyterhub-user-foo&redirect_uri=%2Fuser%2Ffoo%2Foauth_callback&response_type=code&state=[secret] -> /user/foo/oauth_callback?code=[secret]&state=[secret] ([email protected]) 13.44ms
# 11:24 (30 seconds later!) hub->user oauth completes
hub_1    | [I 2018-12-06 04:11:24.754 JupyterHub log:158] 200 POST /hub/api/oauth2/token ([email protected]) 19.65ms

So everything's going smoothly and from the time login finishes to the newly spawned server first handling a request from your browser is 3 seconds. But then! somehow the oauth process between the hub and the singleuser server is taking over 30 seconds.

The hub->server oauth sequence is:

  1. (hub) GET /hub/user/foo -> /user/foo
  2. (user) GET /user/foo. No token, start oauth -> /hub/api/oauth2/authorize
  3. (hub) GET /hub/api/oauth2/authorize -> /user/foo/oauth_callback
  4. (user) /user/foo/oauth_callback (internal token check -> /hub/api/authorizations/token/

It appears to be the user-server's handling of the oauth callback that's taking ~all of the time. The token validation request doesn't occur until. Seems like there must be a bug there. Since the delay is suspiciously close to 30 seconds, it could be related to cluster dns. Any delay of 30 seconds makes me suspect a problem in dns resolution.

Can you try:

%time requests.get(os.environ['JUPYTERHUB_API_URL'])

?

in a notebook after it's launched and share how long it takes? Also whether JUPYTERHUB_API_URL uses a hostname or an ip? It's my hope that that will take ~30 seconds, since that would suggest that cluster dns is the path we want to follow.

@statiksof
Copy link
Author

@minrk this also applies to my issue?

@Mohitsharma44
Copy link

Mohitsharma44 commented Dec 6, 2018

@minrk Right on!
JUPYTERHUB_API_URL uses hostname hub and Wall time reported is 27.7s!!

os.environ['JUPYTERHUB_API_URL']
'http://hub:8081/hub/api'

%time requests.get(os.environ['JUPYTERHUB_API_URL'])
CPU times: user 6.54 ms, sys: 3.48 ms, total: 10 ms
Wall time: 27.7 s

so what do you think should be used for cluster dns? any specific configuration requirements?

@Mohitsharma44
Copy link

Another thing I noticed while troubleshooting this issue:
If I use swarmspawner on a single node swarm cluster, it spins up the containers in ~ 5 - 7 seconds (incl fresh oauth process).
The issue of increased spawn time becomes prominent when I use a multi-node swarm cluster.

@statiksof might not be ideal but see if you can simply use a single node swarm. I can attest that it works without the long spawning times.

@Mohitsharma44
Copy link

My issue is resolved (at least for now). After cleaning up the resources used by the hub and proxy containers proxy and spawning are working perfectly fine. ( more info on why I was having the issue: jupyterhub/configurable-http-proxy#185 )

I'm using docker swarm's own DNS. It's working fast enough (Wall time is now 9ms instead of 27 seconds!!). Thanks for the help.

@statiksof What environment are you running your spawner in? virtual? metal? and what specs? maybe I can try and help narrow the problem down.

@statiksof
Copy link
Author

statiksof commented Dec 6, 2018

Thanks @Mohitsharma44. Actually, I am not using SwarmSpawner, only dockerspawner. My Jupyetrhub runs in a CentOS 7 virtual machine. I also tried to run JH as systems not in a container, but same problem.
I will investigate your suggestion single node swarm.

@Mohitsharma44
Copy link

Hmm... I quickly spawned a CentOS7 minimal on virtualbox as 2 core 2 GB RAM VM and installed everything from there, spawned container using dockerspawner and didn't notice any hiccups.
I even tried with swarmspawner by creating a single node swarm, and while it did take ~1 second more than dockerspawner, didn't notice much lag (created ~5 containers in each scenario while integrating with keycloak container for authentication).

@statiksof
Copy link
Author

statiksof commented Dec 8, 2018 via email

@Mohitsharma44
Copy link

Sure, just run docker swarm init which will initialize docker swarm (engine, not the swarm mode)
and finally docker-compose up with same files as in the swarm example

@statiksof
Copy link
Author

statiksof commented Dec 8, 2018 via email

@wlohman-surfsara
Copy link
Contributor

wlohman-surfsara commented Jan 4, 2019

I'm running into a very similar issue. Jupyter notebook sometimes fails to spawn, giving a 500 error.

I notice quite a significant number of failed spawns on docker swarm. It fails after 30 seconds with a 500 error. I managed to get rid of the 500 errors, making the spawn slow but working, by setting:

c.Spawner.http_timeout = 99

On docker I see the notebook being spawned, without any issues. The jupyterhub container however, cannot connect to it.

Looking inside the jupyterhub container, I see connections hanging in a SYN_SENT state:
(prepare environment with: apt-get update&&apt-get install -y net-tools host)

root@jupyterhub:/srv/jupyterhub# netstat -atn|grep 8888
tcp        0      1 10.0.47.114:38248       10.0.47.131:8888        SYN_SENT

The problem here, is caused by a seemingly invalid DNS resolution:

root@jupyterhub:/srv/jupyterhub# Host jupyter-testaccount
jupyter-testaccount has address 10.0.47.133

Now I'm trying to get some understanding of what is going on here under water:

root@jupyterhub:/srv/jupyterhub# while true;do host jupyter-testaccount;netstat -atn|grep 8888;sleep 0.05;done|tee output.log

Run the above
At first, your container will not resolve, so the host command in the loop outputs this:

Host jupyter-testaccount not found: 3(NXDOMAIN)

The netstat command either doesn't outut anything, or outputs about old connections in CLOSE_WAIT or LAST_ACK state. These are relevant, as they give some information about your previous container.

Now spawn a container. There are two options:

  1. The container spawns in one go. Excellent. You see that the host command starts outputing the (new) IP address and after that a connection establishes to that IP address
jupyter-testaccount has address 10.0.47.135
tcp        1      1 10.0.47.114:51638       10.0.47.133:8888        LAST_ACK
tcp        0      0 10.0.47.114:38024       10.0.47.135:8888        ESTABLISHED
  1. The container is failing. You see that the host command does not produce a result when the jupyterhub tries to establish a connection to the notebook. In these cases I see it is trying to connect to the old IP address:

First this:

Host jupyter-testaccount not found: 3(NXDOMAIN)
tcp        0      1 10.0.47.114:38224       10.0.47.135:8888        SYN_SENT
tcp        1      1 10.0.47.114:38024       10.0.47.135:8888        LAST_ACK

Half a second (or so) later this:

jupyter-testaccount has address 10.0.47.137
tcp        0      1 10.0.47.114:38224       10.0.47.135:8888        SYN_SENT
tcp        1      1 10.0.47.114:38024       10.0.47.135:8888        LAST_ACK

So it seems there is some race condition between docker swarm spawning the service and jupyterhub trying to connect to it.
When the DNS does not resolve, jupyterhub will try to connect to the old IP address.
When the DNS does resolve, jupyterhub connects to the new IP address.

tcpdumping trafik to the DNS, you see over 350 failed DNS requests before answers come through. That looks like this:

Failed:

17:26:04.958598 IP (tos 0x0, ttl 64, id 39566, offset 0, flags [DF], proto UDP (17), length 161)
    127.0.0.11.53 > 127.0.0.1.44212: [bad udp cksum 0xfeaa -> 0x3507!] 42293 NXDomain q: A? jupyter-testaccount. 0/1/0 ns: . [1h41m39s] SOA a.root-servers.net. nstld.verisign-grs.com. 2018121200 1800 900 604800 86400 (133)
E.....@[email protected]..........(jupyter-testaccount...............@.a.root-servers.net..nstld.verisign-grs.com.xJ...........  :...Q.................

And finally success:
17:26:05.033451 IP (tos 0x0, ttl 64, id 39590, offset 0, flags [DF], proto UDP (17), length 142)
    127.0.0.11.53 > 127.0.0.1.54346: [bad udp cksum 0xfe97 -> 0xebfa!] 62151 q: A? jupyter-testaccount. 1/0/0 jupyter-testaccount. [10m] A 10.0.47.185 (114)
E.....@[email protected]..............(jupyter-testaccount.....(jupyter-testaccount........X..
./.................

It's during the time of the failed requests that jupyterhub wants to connect to the old IP address. After DNS starts succeeding, it will connect to the new IP address.

So, I don't know if the same symptoms apply to the other people running into the problem of slow spawning notebooks, but it might be worth looking into.

We managed to work around this by adjusting get_ip_and_port() in swarmspawner.py, adding a loop that keeps trying ip = socket.gethostbyname(ip) until the DNS gives a response. This also means we connect to the notebook on IP rather than container name. But it is a bit of an ugly solution, and I haven't figured out yet why this race condition occurs and where in the code it falls back to the old IP address.

@Mohitsharma44
Copy link

@wlohman-surfsara

In these cases I see it is trying to connect to the old IP address

I was having this same issue.
Between the restarts of container, make sure to delete the overlay network.

@wlohman-surfsara
Copy link
Contributor

Hmmm, I don't think I can?

I create the overlay network as part of the stack, similar to how it is described here:
https://github.com/jupyterhub/dockerspawner#swarmspawner

That means all notebook containers, plus the jupyterhub containers live in that network. Do you handle that differently?

Besides, deleting the network may prevent something inside jupyterhub from connecting to the old IP address but I think it's less intrusive if that same something inside jupyterhub simply doesn't connect at all if the container name doesn't resolve. Or, alternatively, get the IP address from the docker API.

@Mohitsharma44
Copy link

I was vague in my previous message. Let me clarify. I am assuming you are testing things, which means you are stopping and starting the hub container (and consequently the notebook containers)

The hub, when spawning notebooks, uses jupyter-<account/user> as the name for the container. When you re-use the overlay network in between the hub restarts, the DNS in the old overlay network maps the DNS name of your new (but same-named) notebook container (jupyter-<account/user>) to the old IP.
My assumption is that this could be the reason why the hub is trying to reach the old/previous IP address of the notebook container.

So, when you are stopping the hub, make sure to delete the overlay-network that you are using. The best way would be to create a compose file and let it handle this for you.
Something like in the example: https://github.com/jupyterhub/dockerspawner/blob/master/examples/swarm/docker-compose.yml

@wlohman-surfsara
Copy link
Contributor

Ah thanks, well the situation is a bit different, we are running it at the moment as a proof-of-concept for about 20 users or so.

The problem is not when I stop/start the hub. The problem never occurs when the hub is freshly restarted and I spawn a notebook container. The problem begins the second time I launch a notebook container (with indeed the same name as the previous one).

It's then that it seems to have a race condition, sometimes it works, sometimes it doesn't. And the way that translates into observed behaviour is what I wrote above. So with a connection in the SYN_SEND state to the old IP address.
First I thought the problem was in the docker DNS, but as I can see with the host command docker DNS doesn't return anything yet at those times the hub connects to the old IP address. And that's the problem.

Expected behaviour is that when docker DNS doesn't return anything, that it retries a few times rather than falling back on an old value.
We hacked this into it by adding a loop in get_ip_and_port() in swarmspawner.py that does this, and it does work. It's now basically this:

    @gen.coroutine
    def get_ip_and_port(self):
        if self.use_internal_ip:
            ip   = self.service_name
            port = self.port

            import time
            import socket
            time.sleep(3)
            for attempt in range(30):
                try:
                    time.sleep(1)
                    ip = socket.gethostbyname(ip)
                    self.log.info("Jupyter environment '%s' ip address is: %s",self.service_name,ip)
                    break
                except:
                    self.log.info("Jupyter environment '%s' is still unknown, retrying %s..",self.service_name,str(attempt))
                    continue
            else:
                self.log.error("Jupyter environment '%s' is still unknown, please check docker logs.", self.service_name)
        return ip, port

I hope this clarifies the situation

@minrk minrk changed the title Performance issue with DockerSpawner Spawn delay while waiting for DNS update Mar 11, 2021
@minrk
Copy link
Member

minrk commented Mar 11, 2021

A similar (asyncio) wait for DNS resolution when use_internal_hostname is set (~always for swarm spawner) would be appropriate to add if anyone is up for a PR.

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

No branches or pull requests

4 participants