mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-07 18:14:10 +00:00
Compare commits
384 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
3663d7c8fc | ||
![]() |
a30e6b539f | ||
![]() |
ca3982337e | ||
![]() |
159b3553a9 | ||
![]() |
6821e63b71 | ||
![]() |
c1c13930f7 | ||
![]() |
58f18bffff | ||
![]() |
b80906b8c8 | ||
![]() |
07aa077eae | ||
![]() |
3f74c30288 | ||
![]() |
141cb04b27 | ||
![]() |
8769864f24 | ||
![]() |
8ee72dd80f | ||
![]() |
455475724a | ||
![]() |
794be0de8e | ||
![]() |
1f633e188d | ||
![]() |
df0745985b | ||
![]() |
cad027f3fc | ||
![]() |
61a844b413 | ||
![]() |
319b404ef4 | ||
![]() |
19fb7eb7cc | ||
![]() |
cb3b0ce266 | ||
![]() |
82d8e9c433 | ||
![]() |
86ee4cad59 | ||
![]() |
add9666fcd | ||
![]() |
c93687eaad | ||
![]() |
d848873685 | ||
![]() |
c27576a41f | ||
![]() |
6d3ed95b84 | ||
![]() |
ff7cd082ff | ||
![]() |
3582ecc9cc | ||
![]() |
5f626268ef | ||
![]() |
6227f92b5f | ||
![]() |
020ba08635 | ||
![]() |
2ad175816a | ||
![]() |
3d46083dcc | ||
![]() |
dad1417b23 | ||
![]() |
9a3c2409d1 | ||
![]() |
0efb16793e | ||
![]() |
68ad36e945 | ||
![]() |
989ed216a7 | ||
![]() |
319113024d | ||
![]() |
399f7e7b80 | ||
![]() |
b4a6e5c2fe | ||
![]() |
1949ab892a | ||
![]() |
1ec34b256c | ||
![]() |
3c12a99415 | ||
![]() |
a8ced3a7ad | ||
![]() |
1af7deaeb3 | ||
![]() |
861a7c5c5e | ||
![]() |
1d02915f26 | ||
![]() |
90009f3c01 | ||
![]() |
dbce653b5e | ||
![]() |
b4443b1251 | ||
![]() |
155c76b299 | ||
![]() |
553be3e1d4 | ||
![]() |
e1e0a31afc | ||
![]() |
d78466507d | ||
![]() |
d9955a052d | ||
![]() |
2e40da09ea | ||
![]() |
490cf2dd82 | ||
![]() |
b0343ef8d8 | ||
![]() |
fb64b4f0a8 | ||
![]() |
5a747baeca | ||
![]() |
c4ce7faea6 | ||
![]() |
3a810c4fc0 | ||
![]() |
abb93ad799 | ||
![]() |
f31101432e | ||
![]() |
a2c98d016e | ||
![]() |
5581a2ba7e | ||
![]() |
1fe01ae173 | ||
![]() |
24706a1759 | ||
![]() |
182ac00e93 | ||
![]() |
ca81af2ae5 | ||
![]() |
92173c6053 | ||
![]() |
33e1a090d8 | ||
![]() |
e407808f47 | ||
![]() |
7b53330b20 | ||
![]() |
da02b024d6 | ||
![]() |
5502367832 | ||
![]() |
ddc61d2b62 | ||
![]() |
dc049a88eb | ||
![]() |
2b7a02697c | ||
![]() |
4e8acc71c6 | ||
![]() |
3bc0c18974 | ||
![]() |
3004f04a34 | ||
![]() |
e3f1fd0a16 | ||
![]() |
8367606012 | ||
![]() |
6956ffd2a9 | ||
![]() |
0b3ffe1a99 | ||
![]() |
e44ee6ed8a | ||
![]() |
45a4362bb3 | ||
![]() |
8e7df7ae7b | ||
![]() |
676a0da5ff | ||
![]() |
e802df9668 | ||
![]() |
c8e4d68978 | ||
![]() |
5ee2994504 | ||
![]() |
c194cb079e | ||
![]() |
1910bfacbd | ||
![]() |
e16ca97e1c | ||
![]() |
4bcfd52bc7 | ||
![]() |
29df06f0b5 | ||
![]() |
9ec4e6d1d1 | ||
![]() |
ce34c12349 | ||
![]() |
7b5a5541cb | ||
![]() |
731faf29c8 | ||
![]() |
bef561511f | ||
![]() |
f0b5446ec3 | ||
![]() |
629e829f8a | ||
![]() |
7c434adcb2 | ||
![]() |
3641abc70f | ||
![]() |
da790617e3 | ||
![]() |
35ba762c9c | ||
![]() |
42d9c31db7 | ||
![]() |
703af1dd1e | ||
![]() |
1dd09094a5 | ||
![]() |
b8c9717862 | ||
![]() |
06f89cb5ed | ||
![]() |
b5602028e5 | ||
![]() |
b1e45cde1e | ||
![]() |
ca117c251c | ||
![]() |
e815210cc7 | ||
![]() |
f37864cfd3 | ||
![]() |
d05d92c03a | ||
![]() |
948f4c44fd | ||
![]() |
5db76e6dcd | ||
![]() |
c944c0e54a | ||
![]() |
dd7fe85770 | ||
![]() |
b9c1831183 | ||
![]() |
5bbb292ef5 | ||
![]() |
e589b5d82a | ||
![]() |
465fb0a686 | ||
![]() |
9702c1756f | ||
![]() |
9990100f89 | ||
![]() |
a611298f43 | ||
![]() |
6a872b371e | ||
![]() |
1e298fb053 | ||
![]() |
51e1a15d63 | ||
![]() |
46e6d95364 | ||
![]() |
52c099193d | ||
![]() |
9d5784efb9 | ||
![]() |
2847c3a90c | ||
![]() |
d66f0635a3 | ||
![]() |
244ad7d38c | ||
![]() |
7fbf1826ea | ||
![]() |
b4a760234e | ||
![]() |
72a38a599d | ||
![]() |
8134d3bfbc | ||
![]() |
3df4afe7af | ||
![]() |
400c64b4ef | ||
![]() |
44dccb292f | ||
![]() |
0070e68702 | ||
![]() |
f3b1b5c7a6 | ||
![]() |
175c8d0585 | ||
![]() |
bc425a78bb | ||
![]() |
e0c4f9fc23 | ||
![]() |
2cac46fdb2 | ||
![]() |
66f8d6a626 | ||
![]() |
f163559f4a | ||
![]() |
a615f783a3 | ||
![]() |
3cafc7e49f | ||
![]() |
12ee42e8ae | ||
![]() |
9e5c837d3d | ||
![]() |
91be46784e | ||
![]() |
60a1c93801 | ||
![]() |
3a0a581782 | ||
![]() |
5cbf9399b2 | ||
![]() |
d942f52eeb | ||
![]() |
8c1620e6c5 | ||
![]() |
9fdab027da | ||
![]() |
bc32450005 | ||
![]() |
cc95d30dc1 | ||
![]() |
25ef67e8e0 | ||
![]() |
2ad1159f69 | ||
![]() |
561f4d0889 | ||
![]() |
cd0b3e05e2 | ||
![]() |
cdba57e96a | ||
![]() |
f13bd59f6f | ||
![]() |
89b0c421d5 | ||
![]() |
83ddee10ed | ||
![]() |
8a03b73086 | ||
![]() |
333b62f1fc | ||
![]() |
231d14e95d | ||
![]() |
9817610dc3 | ||
![]() |
aaf365c907 | ||
![]() |
0f93571ca5 | ||
![]() |
5b13f96162 | ||
![]() |
b41a383eae | ||
![]() |
1701149fd7 | ||
![]() |
5f8664723e | ||
![]() |
18ce8eb5a6 | ||
![]() |
d51d39728a | ||
![]() |
2255de7847 | ||
![]() |
a8c0609eb9 | ||
![]() |
66f29e0f5a | ||
![]() |
ca00c0eab0 | ||
![]() |
54baa0c31a | ||
![]() |
5d3dc509bd | ||
![]() |
9cf22e4106 | ||
![]() |
898fea9fdc | ||
![]() |
f79495e6bf | ||
![]() |
f474b31c94 | ||
![]() |
fafbe86b55 | ||
![]() |
82ad2dfbc6 | ||
![]() |
ac32ae496e | ||
![]() |
949d8d0bfa | ||
![]() |
7fd3271c9b | ||
![]() |
6267b752ae | ||
![]() |
7fcd6ad450 | ||
![]() |
dcde9f6222 | ||
![]() |
2e8ddeb114 | ||
![]() |
e07aaa603a | ||
![]() |
0bcd6adde6 | ||
![]() |
444029699a | ||
![]() |
b9bdc99c1d | ||
![]() |
c896fe05fd | ||
![]() |
424803bcd7 | ||
![]() |
9024cf1614 | ||
![]() |
a239a25ae0 | ||
![]() |
36a1ad0078 | ||
![]() |
6d696758e4 | ||
![]() |
2545cd9bb3 | ||
![]() |
096b159c23 | ||
![]() |
74958d9397 | ||
![]() |
9db18439af | ||
![]() |
2b6ad596d2 | ||
![]() |
917786f2f5 | ||
![]() |
a800496f6c | ||
![]() |
a92fee8a82 | ||
![]() |
7b1c4aedcf | ||
![]() |
572e008f1d | ||
![]() |
0379727cc0 | ||
![]() |
c9d52bea43 | ||
![]() |
263c5e838e | ||
![]() |
439e4381f0 | ||
![]() |
c34bcabcb9 | ||
![]() |
2b1bfa0ba7 | ||
![]() |
aea2eefa77 | ||
![]() |
dcde4020c2 | ||
![]() |
1225ff47be | ||
![]() |
5aaa5263fa | ||
![]() |
eca4f33afc | ||
![]() |
1e578a25d3 | ||
![]() |
41b2e6e401 | ||
![]() |
ced45d101a | ||
![]() |
03693c379e | ||
![]() |
0058ed803d | ||
![]() |
7d9a93ab5f | ||
![]() |
8a61eb1738 | ||
![]() |
cbbead3780 | ||
![]() |
146aec7e0c | ||
![]() |
f7e5904c5b | ||
![]() |
077727595c | ||
![]() |
4bfc69dc80 | ||
![]() |
8d7f55ce92 | ||
![]() |
cda7f73cfa | ||
![]() |
915664ede2 | ||
![]() |
037730761c | ||
![]() |
1d1e108e09 | ||
![]() |
6e71e617ed | ||
![]() |
9e0bb5cc71 | ||
![]() |
5fa268dab1 | ||
![]() |
1a26c1fb81 | ||
![]() |
2cc0eb885a | ||
![]() |
749b9e0997 | ||
![]() |
669dbfd449 | ||
![]() |
444f0ba00c | ||
![]() |
e46e724a70 | ||
![]() |
2e67a534cf | ||
![]() |
24c0829289 | ||
![]() |
60f5ce0ff8 | ||
![]() |
0325be3e13 | ||
![]() |
b37b13a939 | ||
![]() |
37642408a4 | ||
![]() |
9d2823e84b | ||
![]() |
ae7974564c | ||
![]() |
30c69f94c8 | ||
![]() |
47cf1915ff | ||
![]() |
9f32fc1854 | ||
![]() |
8a2eba1156 | ||
![]() |
254687e841 | ||
![]() |
aa59b1fca3 | ||
![]() |
88bff9d03d | ||
![]() |
3ca0f32ad3 | ||
![]() |
6a2876a9fa | ||
![]() |
fad6900779 | ||
![]() |
d8d58b2ebd | ||
![]() |
859dc34ea6 | ||
![]() |
8a37d2daec | ||
![]() |
41db9fe116 | ||
![]() |
8dce5a87bc | ||
![]() |
266e82755a | ||
![]() |
b237ab9e7b | ||
![]() |
7c78e6c326 | ||
![]() |
f1ed6c95f0 | ||
![]() |
2f0ce2a431 | ||
![]() |
adf3779d02 | ||
![]() |
73309b5741 | ||
![]() |
2320d59bd1 | ||
![]() |
1915ecd0c2 | ||
![]() |
d050242d0f | ||
![]() |
3d6d60b64e | ||
![]() |
fc90be8424 | ||
![]() |
1555abb2bf | ||
![]() |
8c8968c2b0 | ||
![]() |
69d0a47734 | ||
![]() |
5ae1fdf621 | ||
![]() |
c24f6b0a6a | ||
![]() |
11e32588d7 | ||
![]() |
34e44f2eed | ||
![]() |
c0464b2e47 | ||
![]() |
d686ae1ae7 | ||
![]() |
0dc3593661 | ||
![]() |
dc40cfe80e | ||
![]() |
d541c17974 | ||
![]() |
09cc8569b3 | ||
![]() |
3089d441b4 | ||
![]() |
19806899f2 | ||
![]() |
553e31235e | ||
![]() |
55323ec206 | ||
![]() |
49a5f3a654 | ||
![]() |
97c27774b1 | ||
![]() |
de11909a04 | ||
![]() |
2f15d5128e | ||
![]() |
276ef26161 | ||
![]() |
d5d315df08 | ||
![]() |
f7f82b8214 | ||
![]() |
ddece49abb | ||
![]() |
02192ee2d5 | ||
![]() |
a6b7e303df | ||
![]() |
5e5a976ea6 | ||
![]() |
c20c07ec87 | ||
![]() |
bac34e394b | ||
![]() |
2ce223c811 | ||
![]() |
e107c84162 | ||
![]() |
1cea503292 | ||
![]() |
19da170435 | ||
![]() |
30cfdcaa83 | ||
![]() |
e9c78422b5 | ||
![]() |
844817297e | ||
![]() |
b624116be7 | ||
![]() |
38cf95523f | ||
![]() |
d6d8590acb | ||
![]() |
da460064ae | ||
![]() |
8a6de3006c | ||
![]() |
9e35ba5bef | ||
![]() |
c83777ccdc | ||
![]() |
aaad55e076 | ||
![]() |
c1e359bd38 | ||
![]() |
53f5dbd902 | ||
![]() |
9e7b0c0bfd | ||
![]() |
0aca778a9e | ||
![]() |
83af28c137 | ||
![]() |
bfbf2c0521 | ||
![]() |
09edf38a35 | ||
![]() |
e4d4e059bd | ||
![]() |
2967383654 | ||
![]() |
85f5ae1a37 | ||
![]() |
ecafe4add9 | ||
![]() |
9462511aa5 | ||
![]() |
31736eea9a | ||
![]() |
f97ef7eaac | ||
![]() |
2065099338 | ||
![]() |
d4df579fa6 | ||
![]() |
4378603e83 | ||
![]() |
40db4edc6d | ||
![]() |
ccf13979e9 | ||
![]() |
76f134c393 | ||
![]() |
77d4c1f23d | ||
![]() |
5856f46e1d | ||
![]() |
edfd1eb6cf | ||
![]() |
1ae6678360 | ||
![]() |
7794eea3fb | ||
![]() |
f51e6a1ca0 | ||
![]() |
ab00a19be1 | ||
![]() |
7742bfdda5 | ||
![]() |
f3878d8216 | ||
![]() |
d17cb637fe | ||
![]() |
5b63efe63c | ||
![]() |
54816b0a7c | ||
![]() |
41fc73db42 | ||
![]() |
984d6be542 | ||
![]() |
74a457f6b5 | ||
![]() |
137a044f96 |
@@ -19,3 +19,57 @@ jobs:
|
||||
name: smoke test jupyterhub
|
||||
command: |
|
||||
docker run --rm -it jupyterhub/jupyterhub jupyterhub --help
|
||||
|
||||
docs:
|
||||
# This is the base environment that Circle will use
|
||||
docker:
|
||||
- image: circleci/python:3.6-stretch
|
||||
steps:
|
||||
# Get our data and merge with upstream
|
||||
- run: sudo apt-get update
|
||||
- checkout
|
||||
# Update our path
|
||||
- run: echo "export PATH=~/.local/bin:$PATH" >> $BASH_ENV
|
||||
# Restore cached files to speed things up
|
||||
- restore_cache:
|
||||
keys:
|
||||
- cache-pip
|
||||
# Install the packages needed to build our documentation
|
||||
- run:
|
||||
name: Install NodeJS
|
||||
command: |
|
||||
# From https://github.com/nodesource/distributions/blob/master/README.md#debinstall
|
||||
curl -sL https://deb.nodesource.com/setup_13.x | sudo -E bash -
|
||||
sudo apt-get install -y nodejs
|
||||
|
||||
- run:
|
||||
name: Install dependencies
|
||||
command: |
|
||||
python3 -m pip install --user -r dev-requirements.txt
|
||||
python3 -m pip install --user -r docs/requirements.txt
|
||||
sudo npm install -g configurable-http-proxy
|
||||
sudo python3 -m pip install --editable .
|
||||
|
||||
# Cache some files for a speedup in subsequent builds
|
||||
- save_cache:
|
||||
key: cache-pip
|
||||
paths:
|
||||
- ~/.cache/pip
|
||||
# Build the docs
|
||||
- run:
|
||||
name: Build docs to store
|
||||
command: |
|
||||
cd docs
|
||||
make html
|
||||
# Tell Circle to store the documentation output in a folder that we can access later
|
||||
- store_artifacts:
|
||||
path: docs/build/html/
|
||||
destination: html
|
||||
|
||||
# Tell CircleCI to use this workflow when it builds the site
|
||||
workflows:
|
||||
version: 2
|
||||
default:
|
||||
jobs:
|
||||
- build
|
||||
- docs
|
||||
|
36
.github/ISSUE_TEMPLATE/bug_report.md
vendored
36
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@@ -1,37 +1,39 @@
|
||||
---
|
||||
name: Bug report
|
||||
name: Issue report
|
||||
about: Create a report to help us improve
|
||||
|
||||
---
|
||||
|
||||
<!---
|
||||
Hi! Thanks for using JupyterHub.
|
||||
|
||||
If you are reporting an issue with JupyterHub, please use the [GitHub issue](https://github.com/jupyterhub/jupyterhub/issues) search feature to check if your issue has been asked already. If it has, please add your comments to the existing issue.
|
||||
If you are reporting an issue with JupyterHub, please use the GitHub search feature to check if your issue has been asked already. If it has, please add your comments to the existing issue.
|
||||
|
||||
Some tips:
|
||||
- Running `jupyter troubleshoot` from the command line, if possible, and posting
|
||||
its output would also be helpful.
|
||||
- Running JupyterHub in `--debug` mode (`jupyterhub --debug`) can also be helpful for troubleshooting.
|
||||
--->
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
<!---Add description here--->
|
||||
|
||||
**To Reproduce**
|
||||
Steps to reproduce the behavior:
|
||||
<!---
|
||||
Please share the steps to reproduce the behavior:
|
||||
1. Go to '...'
|
||||
2. Click on '....'
|
||||
3. Scroll down to '....'
|
||||
4. See error
|
||||
--->
|
||||
|
||||
**Expected behavior**
|
||||
<!---
|
||||
A clear and concise description of what you expected to happen.
|
||||
--->
|
||||
|
||||
**Screenshots**
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
**Desktop (please complete the following information):**
|
||||
- OS: [e.g. iOS]
|
||||
- Browser [e.g. chrome, safari]
|
||||
- Version [e.g. 22]
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here.
|
||||
|
||||
- Running `jupyter troubleshoot` from the command line, if possible, and posting
|
||||
its output would also be helpful.
|
||||
- Running in `--debug` mode can also be helpful for troubleshooting.
|
||||
**Compute Information**
|
||||
- Operating System
|
||||
- JupyterHub Version [e.g. 22]
|
||||
|
@@ -1,7 +1,22 @@
|
||||
---
|
||||
name: Installation and configuration issues
|
||||
name: Installation and configuration questions
|
||||
about: Installation and configuration assistance
|
||||
|
||||
---
|
||||
|
||||
If you are having issues with installation or configuration, you may ask for help on the JupyterHub gitter channel or file an issue here.
|
||||
<!---
|
||||
If you are reading this message, you have probably already searched the existing
|
||||
GitHub issues for JupyterHub. If you haven't tried a search, we encourage you to do so.
|
||||
|
||||
If you are unsure where to ask your question (Jupyter, JupyterHub, JupyterLab, etc.),
|
||||
please ask on our [Discourse Q&A channel](https://discourse.jupyter.org/c/questions).
|
||||
|
||||
If you have a quick question about JupyterHub installation or configuratation, you
|
||||
may ask on the [JupyterHub gitter channel](https://gitter.im/jupyterhub/jupyterhub).
|
||||
|
||||
:sunny: Please be patient. We are volunteers and will address your question when we are able. :sunny:
|
||||
|
||||
If after trying the above steps, you still have an in-depth installation or
|
||||
configuration question, such as a possible bug, please file an issue below and include
|
||||
any relevant details.
|
||||
--->
|
||||
|
0
.github/PULL_REQUEST_TEMPLATE/.keep
vendored
0
.github/PULL_REQUEST_TEMPLATE/.keep
vendored
@@ -1,15 +1,15 @@
|
||||
repos:
|
||||
- repo: https://github.com/asottile/reorder_python_imports
|
||||
rev: v1.3.5
|
||||
rev: v1.8.0
|
||||
hooks:
|
||||
- id: reorder-python-imports
|
||||
language_version: python3.6
|
||||
- repo: https://github.com/ambv/black
|
||||
rev: 18.9b0
|
||||
rev: 19.10b0
|
||||
hooks:
|
||||
- id: black
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v2.1.0
|
||||
rev: v2.4.0
|
||||
hooks:
|
||||
- id: end-of-file-fixer
|
||||
- id: check-json
|
||||
|
108
.travis.yml
108
.travis.yml
@@ -1,21 +1,18 @@
|
||||
dist: bionic
|
||||
language: python
|
||||
sudo: false
|
||||
cache:
|
||||
- pip
|
||||
python:
|
||||
- 3.6
|
||||
- 3.5
|
||||
- nightly
|
||||
env:
|
||||
global:
|
||||
- ASYNC_TEST_TIMEOUT=15
|
||||
- MYSQL_HOST=127.0.0.1
|
||||
- MYSQL_TCP_PORT=13306
|
||||
|
||||
# request additional services for the jobs to access
|
||||
services:
|
||||
- postgres
|
||||
- postgresql
|
||||
- docker
|
||||
|
||||
# installing dependencies
|
||||
# install dependencies for running pytest (but not linting)
|
||||
before_install:
|
||||
- set -e
|
||||
- nvm install 6; nvm use 6
|
||||
@@ -27,68 +24,71 @@ before_install:
|
||||
unset MYSQL_UNIX_PORT
|
||||
DB=mysql bash ci/docker-db.sh
|
||||
DB=mysql bash ci/init-db.sh
|
||||
pip install 'mysql-connector-python'
|
||||
# FIXME: mysql-connector-python 8.0.16 incorrectly decodes bytes to str
|
||||
# ref: https://bugs.mysql.com/bug.php?id=94944
|
||||
pip install 'mysql-connector-python==8.0.11'
|
||||
elif [[ $JUPYTERHUB_TEST_DB_URL == postgresql* ]]; then
|
||||
psql -c "CREATE USER $PGUSER WITH PASSWORD '$PGPASSWORD';" -U postgres
|
||||
DB=postgres bash ci/init-db.sh
|
||||
pip install psycopg2-binary
|
||||
fi
|
||||
|
||||
# install general dependencies
|
||||
install:
|
||||
- pip install --upgrade pip
|
||||
- pip install --upgrade --pre -r dev-requirements.txt .
|
||||
- pip freeze
|
||||
|
||||
# running tests
|
||||
# run tests
|
||||
script:
|
||||
- |
|
||||
# run tests
|
||||
if [[ -z "$TEST" ]]; then
|
||||
pytest -v --maxfail=2 --cov=jupyterhub jupyterhub/tests
|
||||
fi
|
||||
- |
|
||||
# run autoformat
|
||||
if [[ "$TEST" == "lint" ]]; then
|
||||
pre-commit run --all-files
|
||||
fi
|
||||
- |
|
||||
# build docs
|
||||
if [[ "$TEST" == "docs" ]]; then
|
||||
pushd docs
|
||||
pip install --upgrade -r requirements.txt
|
||||
pip install --upgrade alabaster_jupyterhub
|
||||
make html
|
||||
popd
|
||||
fi
|
||||
- pytest -v --maxfail=2 --cov=jupyterhub jupyterhub/tests
|
||||
|
||||
# collect test coverage information
|
||||
after_success:
|
||||
- codecov
|
||||
after_failure:
|
||||
- |
|
||||
# point to auto-lint-fix
|
||||
if [[ "$TEST" == "lint" ]]; then
|
||||
echo "You can install pre-commit hooks to automatically run formatting"
|
||||
echo "on each commit with:"
|
||||
echo " pre-commit install"
|
||||
echo "or you can run by hand on staged files with"
|
||||
echo " pre-commit run"
|
||||
echo "or after-the-fact on already committed files with"
|
||||
echo " pre-commit run --all-files"
|
||||
fi
|
||||
|
||||
matrix:
|
||||
fast_finish: true
|
||||
# list the jobs
|
||||
jobs:
|
||||
include:
|
||||
- python: 3.6
|
||||
env: TEST=lint
|
||||
- python: 3.6
|
||||
env: TEST=docs
|
||||
- python: 3.6
|
||||
- name: autoformatting check
|
||||
python: 3.6
|
||||
# NOTE: It does not suffice to override to: null, [], or [""]. Travis will
|
||||
# fall back to the default if we do.
|
||||
before_install: echo "Do nothing before install."
|
||||
script:
|
||||
- pre-commit run --all-files
|
||||
after_success: echo "Do nothing after success."
|
||||
after_failure:
|
||||
- |
|
||||
echo "You can install pre-commit hooks to automatically run formatting"
|
||||
echo "on each commit with:"
|
||||
echo " pre-commit install"
|
||||
echo "or you can run by hand on staged files with"
|
||||
echo " pre-commit run"
|
||||
echo "or after-the-fact on already committed files with"
|
||||
echo " pre-commit run --all-files"
|
||||
# When we run pytest, we want to run it with python>=3.5 as well as with
|
||||
# various configurations. We increment the python version at the same time
|
||||
# as we test new configurations in order to reduce the number of test jobs.
|
||||
- name: python:3.5 + dist:xenial
|
||||
python: 3.5
|
||||
dist: xenial
|
||||
- name: python:3.6 + subdomain
|
||||
python: 3.6
|
||||
env: JUPYTERHUB_TEST_SUBDOMAIN_HOST=http://localhost.jovyan.org:8000
|
||||
- python: 3.6
|
||||
- name: python:3.7 + mysql
|
||||
python: 3.7
|
||||
env:
|
||||
- JUPYTERHUB_TEST_DB_URL=mysql+mysqlconnector://root@127.0.0.1:$MYSQL_TCP_PORT/jupyterhub
|
||||
- python: 3.6
|
||||
- name: python:3.8 + postgresql
|
||||
python: 3.8
|
||||
env:
|
||||
- JUPYTERHUB_TEST_DB_URL=postgresql://postgres@127.0.0.1/jupyterhub
|
||||
- python: 3.7
|
||||
dist: xenial
|
||||
- PGUSER=jupyterhub
|
||||
- PGPASSWORD=hub[test/:?
|
||||
# The password in url below is url-encoded with: urllib.parse.quote($PGPASSWORD, safe='')
|
||||
- JUPYTERHUB_TEST_DB_URL=postgresql://jupyterhub:hub%5Btest%2F%3A%3F@127.0.0.1/jupyterhub
|
||||
- name: python:nightly
|
||||
python: nightly
|
||||
allow_failures:
|
||||
- python: nightly
|
||||
- name: python:nightly
|
||||
fast_finish: true
|
||||
|
@@ -97,6 +97,35 @@ and other collections of tests for different components.
|
||||
When writing a new test, there should usually be a test of
|
||||
similar functionality already written and related tests should
|
||||
be added nearby.
|
||||
When in doubt, feel free to ask.
|
||||
|
||||
TODO: describe some details about fixtures, etc.
|
||||
The fixtures live in `jupyterhub/tests/conftest.py`. There are
|
||||
fixtures that can be used for JupyterHub components, such as:
|
||||
|
||||
- `app`: an instance of JupyterHub with mocked parts
|
||||
- `auth_state_enabled`: enables persisting auth_state (like authentication tokens)
|
||||
- `db`: a sqlite in-memory DB session
|
||||
- `io_loop`: a Tornado event loop
|
||||
- `event_loop`: a new asyncio event loop
|
||||
- `user`: creates a new temporary user
|
||||
- `admin_user`: creates a new temporary admin user
|
||||
- single user servers
|
||||
- `cleanup_after`: allows cleanup of single user servers between tests
|
||||
- mocked service
|
||||
- `MockServiceSpawner`: a spawner that mocks services for testing with a short poll interval
|
||||
- `mockservice`: mocked service with no external service url
|
||||
- `mockservice_url`: mocked service with a url to test external services
|
||||
|
||||
And fixtures to add functionality or spawning behavior:
|
||||
|
||||
- `admin_access`: grants admin access
|
||||
- `no_patience`: sets slow-spawning timeouts to zero
|
||||
- `slow_spawn`: enables the SlowSpawner (a spawner that takes a few seconds to start)
|
||||
- `never_spawn`: enables the NeverSpawner (a spawner that will never start)
|
||||
- `bad_spawn`: enables the BadSpawner (a spawner that fails immediately)
|
||||
- `slow_bad_spawn`: enables the SlowBadSpawner (a spawner that fails after a short delay)
|
||||
|
||||
To read more about fixtures check out the
|
||||
[pytest docs](https://docs.pytest.org/en/latest/fixture.html)
|
||||
for how to use the existing fixtures, and how to create new ones.
|
||||
|
||||
When in doubt, feel free to ask.
|
||||
|
90
Dockerfile
90
Dockerfile
@@ -21,40 +21,84 @@
|
||||
# your jupyterhub_config.py will be added automatically
|
||||
# from your docker directory.
|
||||
|
||||
FROM ubuntu:18.04
|
||||
LABEL maintainer="Jupyter Project <jupyter@googlegroups.com>"
|
||||
# https://github.com/tianon/docker-brew-ubuntu-core/commit/d4313e13366d24a97bd178db4450f63e221803f1
|
||||
ARG BASE_IMAGE=ubuntu:bionic-20191029@sha256:6e9f67fa63b0323e9a1e587fd71c561ba48a034504fb804fd26fd8800039835d
|
||||
FROM $BASE_IMAGE AS builder
|
||||
|
||||
USER root
|
||||
|
||||
# install nodejs, utf8 locale, set CDN because default httpredir is unreliable
|
||||
ENV DEBIAN_FRONTEND noninteractive
|
||||
RUN apt-get -y update && \
|
||||
apt-get -y upgrade && \
|
||||
apt-get -y install wget git bzip2 && \
|
||||
apt-get purge && \
|
||||
apt-get clean && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
ENV LANG C.UTF-8
|
||||
RUN apt-get update \
|
||||
&& apt-get install -yq --no-install-recommends \
|
||||
build-essential \
|
||||
ca-certificates \
|
||||
locales \
|
||||
python3-dev \
|
||||
python3-pip \
|
||||
python3-pycurl \
|
||||
nodejs \
|
||||
npm \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# install Python + NodeJS with conda
|
||||
RUN wget -q https://repo.continuum.io/miniconda/Miniconda3-4.5.11-Linux-x86_64.sh -O /tmp/miniconda.sh && \
|
||||
echo 'e1045ee415162f944b6aebfe560b8fee */tmp/miniconda.sh' | md5sum -c - && \
|
||||
bash /tmp/miniconda.sh -f -b -p /opt/conda && \
|
||||
/opt/conda/bin/conda install --yes -c conda-forge \
|
||||
python=3.6 sqlalchemy tornado jinja2 traitlets requests pip pycurl \
|
||||
nodejs configurable-http-proxy && \
|
||||
/opt/conda/bin/pip install --upgrade pip && \
|
||||
rm /tmp/miniconda.sh
|
||||
ENV PATH=/opt/conda/bin:$PATH
|
||||
# copy only what we need to avoid unnecessary rebuilds
|
||||
COPY package.json \
|
||||
pyproject.toml \
|
||||
README.md \
|
||||
requirements.txt \
|
||||
setup.py \
|
||||
/src/jupyterhub/
|
||||
COPY jupyterhub/ /src/jupyterhub/jupyterhub
|
||||
COPY share/ /src/jupyterhub/share
|
||||
|
||||
ADD . /src/jupyterhub
|
||||
WORKDIR /src/jupyterhub
|
||||
RUN python3 -m pip install --upgrade setuptools pip wheel
|
||||
RUN python3 -m pip wheel -v --wheel-dir wheelhouse .
|
||||
|
||||
RUN pip install . && \
|
||||
rm -rf $PWD ~/.cache ~/.npm
|
||||
|
||||
FROM $BASE_IMAGE
|
||||
|
||||
USER root
|
||||
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
RUN apt-get update \
|
||||
&& apt-get install -yq --no-install-recommends \
|
||||
ca-certificates \
|
||||
curl \
|
||||
gnupg \
|
||||
locales \
|
||||
python3-pip \
|
||||
python3-pycurl \
|
||||
nodejs \
|
||||
npm \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
ENV SHELL=/bin/bash \
|
||||
LC_ALL=en_US.UTF-8 \
|
||||
LANG=en_US.UTF-8 \
|
||||
LANGUAGE=en_US.UTF-8
|
||||
|
||||
RUN locale-gen $LC_ALL
|
||||
|
||||
# always make sure pip is up to date!
|
||||
RUN python3 -m pip install --no-cache --upgrade setuptools pip
|
||||
|
||||
RUN npm install -g configurable-http-proxy@^4.2.0 \
|
||||
&& rm -rf ~/.npm
|
||||
|
||||
# install the wheels we built in the first stage
|
||||
COPY --from=builder /src/jupyterhub/wheelhouse /tmp/wheelhouse
|
||||
COPY --from=builder /src/jupyterhub/share /src/jupyterhub/share
|
||||
RUN python3 -m pip install --no-cache /tmp/wheelhouse/*
|
||||
|
||||
RUN mkdir -p /srv/jupyterhub/
|
||||
WORKDIR /srv/jupyterhub/
|
||||
|
||||
EXPOSE 8000
|
||||
|
||||
LABEL maintainer="Jupyter Project <jupyter@googlegroups.com>"
|
||||
LABEL org.jupyter.service="jupyterhub"
|
||||
|
||||
CMD ["jupyterhub"]
|
||||
|
32
README.md
32
README.md
@@ -10,14 +10,16 @@
|
||||
# [JupyterHub](https://github.com/jupyterhub/jupyterhub)
|
||||
|
||||
|
||||
[](https://pypi.python.org/pypi/jupyterhub)
|
||||
[](https://jupyterhub.readthedocs.org/en/latest/?badge=latest)
|
||||
[](https://travis-ci.org/jupyterhub/jupyterhub)
|
||||
[](https://circleci.com/gh/jupyterhub/jupyterhub)
|
||||
[](https://codecov.io/github/jupyterhub/jupyterhub?branch=master)
|
||||
[](https://github.com/jupyterhub/jupyterhub/issues)
|
||||
[](https://discourse.jupyter.org/c/jupyterhub)
|
||||
[](https://gitter.im/jupyterhub/jupyterhub)
|
||||
[](https://pypi.python.org/pypi/jupyterhub)
|
||||
[](https://www.npmjs.com/package/jupyterhub)
|
||||
[](https://jupyterhub.readthedocs.org/en/latest/)
|
||||
[](https://travis-ci.org/jupyterhub/jupyterhub)
|
||||
[](https://hub.docker.com/r/jupyterhub/jupyterhub/tags)
|
||||
[](https://circleci.com/gh/jupyterhub/jupyterhub)<!-- CircleCI Token: b5b65862eb2617b9a8d39e79340b0a6b816da8cc -->
|
||||
[](https://codecov.io/gh/jupyterhub/jupyterhub)
|
||||
[](https://github.com/jupyterhub/jupyterhub/issues)
|
||||
[](https://discourse.jupyter.org/c/jupyterhub)
|
||||
[](https://gitter.im/jupyterhub/jupyterhub)
|
||||
|
||||
With [JupyterHub](https://jupyterhub.readthedocs.io) you can create a
|
||||
**multi-user Hub** which spawns, manages, and proxies multiple instances of the
|
||||
@@ -145,12 +147,12 @@ To start the Hub on a specific url and port ``10.0.1.2:443`` with **https**:
|
||||
|
||||
### Authenticators
|
||||
|
||||
| Authenticator | Description |
|
||||
| --------------------------------------------------------------------------- | ------------------------------------------------- |
|
||||
| PAMAuthenticator | Default, built-in authenticator |
|
||||
| [OAuthenticator](https://github.com/jupyterhub/oauthenticator) | OAuth + JupyterHub Authenticator = OAuthenticator |
|
||||
| [ldapauthenticator](https://github.com/jupyterhub/ldapauthenticator) | Simple LDAP Authenticator Plugin for JupyterHub |
|
||||
| [kdcAuthenticator](https://github.com/bloomberg/jupyterhub-kdcauthenticator)| Kerberos Authenticator Plugin for JupyterHub |
|
||||
| Authenticator | Description |
|
||||
| ---------------------------------------------------------------------------- | ------------------------------------------------- |
|
||||
| PAMAuthenticator | Default, built-in authenticator |
|
||||
| [OAuthenticator](https://github.com/jupyterhub/oauthenticator) | OAuth + JupyterHub Authenticator = OAuthenticator |
|
||||
| [ldapauthenticator](https://github.com/jupyterhub/ldapauthenticator) | Simple LDAP Authenticator Plugin for JupyterHub |
|
||||
| [kerberosauthenticator](https://github.com/jupyterhub/kerberosauthenticator) | Kerberos Authenticator Plugin for JupyterHub |
|
||||
|
||||
### Spawners
|
||||
|
||||
@@ -162,6 +164,7 @@ To start the Hub on a specific url and port ``10.0.1.2:443`` with **https**:
|
||||
| [sudospawner](https://github.com/jupyterhub/sudospawner) | Spawn single-user servers without being root |
|
||||
| [systemdspawner](https://github.com/jupyterhub/systemdspawner) | Spawn single-user notebook servers using systemd |
|
||||
| [batchspawner](https://github.com/jupyterhub/batchspawner) | Designed for clusters using batch scheduling software |
|
||||
| [yarnspawner](https://github.com/jupyterhub/yarnspawner) | Spawn single-user notebook servers distributed on a Hadoop cluster |
|
||||
| [wrapspawner](https://github.com/jupyterhub/wrapspawner) | WrapSpawner and ProfilesSpawner enabling runtime configuration of spawners |
|
||||
|
||||
## Docker
|
||||
@@ -241,6 +244,7 @@ our JupyterHub [Gitter](https://gitter.im/jupyterhub/jupyterhub) channel.
|
||||
- [Documentation for JupyterHub's REST API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/jupyterhub/master/docs/rest-api.yml#/default)
|
||||
- [Documentation for Project Jupyter](http://jupyter.readthedocs.io/en/latest/index.html) | [PDF](https://media.readthedocs.org/pdf/jupyter/latest/jupyter.pdf)
|
||||
- [Project Jupyter website](https://jupyter.org)
|
||||
- [Project Jupyter community](https://jupyter.org/community)
|
||||
|
||||
JupyterHub follows the Jupyter [Community Guides](https://jupyter.readthedocs.io/en/latest/community/content-community.html).
|
||||
|
||||
|
@@ -2,7 +2,7 @@
|
||||
# source this file to setup postgres and mysql
|
||||
# for local testing (as similar as possible to docker)
|
||||
|
||||
set -e
|
||||
set -eu
|
||||
|
||||
export MYSQL_HOST=127.0.0.1
|
||||
export MYSQL_TCP_PORT=${MYSQL_TCP_PORT:-13306}
|
||||
@@ -40,6 +40,15 @@ for i in {1..60}; do
|
||||
done
|
||||
$CHECK
|
||||
|
||||
case "$DB" in
|
||||
"mysql")
|
||||
;;
|
||||
"postgres")
|
||||
# create the user
|
||||
psql --user postgres -c "CREATE USER $PGUSER WITH PASSWORD '$PGPASSWORD';"
|
||||
;;
|
||||
*)
|
||||
esac
|
||||
|
||||
echo -e "
|
||||
Set these environment variables:
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
# initialize jupyterhub databases for testing
|
||||
|
||||
set -e
|
||||
set -eu
|
||||
|
||||
MYSQL="mysql --user root --host $MYSQL_HOST --port $MYSQL_TCP_PORT -e "
|
||||
PSQL="psql --user postgres -c "
|
||||
@@ -23,5 +23,5 @@ set -x
|
||||
|
||||
for SUFFIX in '' _upgrade_072 _upgrade_081 _upgrade_094; do
|
||||
$SQL "DROP DATABASE jupyterhub${SUFFIX};" 2>/dev/null || true
|
||||
$SQL "CREATE DATABASE jupyterhub${SUFFIX} ${EXTRA_CREATE};"
|
||||
$SQL "CREATE DATABASE jupyterhub${SUFFIX} ${EXTRA_CREATE:-};"
|
||||
done
|
||||
|
@@ -14,4 +14,7 @@ pytest-asyncio
|
||||
pytest-cov
|
||||
pytest>=3.3
|
||||
requests-mock
|
||||
# blacklist urllib3 releases affected by https://github.com/urllib3/urllib3/issues/1683
|
||||
# I *think* this should only affect testing, not production
|
||||
urllib3!=1.25.4,!=1.25.5
|
||||
virtualenv
|
||||
|
@@ -12,7 +12,7 @@ Dockerfile.alpine contains base image for jupyterhub. It does not work independ
|
||||
|
||||
* start configurable-http-proxy in another container
|
||||
* specify CONFIGPROXY_AUTH_TOKEN env in both containers
|
||||
* put both containers on the same network (e.g. docker create network jupyterhub; docker run ... --net jupyterhub)
|
||||
* put both containers on the same network (e.g. docker network create jupyterhub; docker run ... --net jupyterhub)
|
||||
* tell jupyterhub where CHP is (e.g. c.ConfigurableHTTPProxy.api_url = 'http://chp:8001')
|
||||
* tell jupyterhub not to start the proxy itself (c.ConfigurableHTTPProxy.should_start = False)
|
||||
* Use dummy authenticator for ease of testing. Update following in jupyterhub_config file
|
||||
|
@@ -4,22 +4,17 @@ name: jhub_docs
|
||||
channels:
|
||||
- conda-forge
|
||||
dependencies:
|
||||
- pip
|
||||
- nodejs
|
||||
- python=3.6
|
||||
- alembic
|
||||
- jinja2
|
||||
- pamela
|
||||
- recommonmark==0.6.0
|
||||
- requests
|
||||
- sqlalchemy>=1
|
||||
- tornado>=5.0
|
||||
- traitlets>=4.1
|
||||
- sphinx>=1.7
|
||||
- pip:
|
||||
- entrypoints
|
||||
- oauthlib>=2.0
|
||||
- recommonmark==0.5.0
|
||||
- async_generator
|
||||
- prometheus_client
|
||||
- attrs>=17.4.0
|
||||
- sphinx-copybutton
|
||||
- alabaster_jupyterhub
|
||||
- -r requirements.txt
|
||||
|
@@ -2,6 +2,9 @@
|
||||
# if you change this file
|
||||
-r ../requirements.txt
|
||||
alabaster_jupyterhub
|
||||
autodoc-traits
|
||||
git+https://github.com/pandas-dev/pandas-sphinx-theme.git@master
|
||||
recommonmark==0.5.0
|
||||
sphinx-copybutton
|
||||
sphinx-jsonschema
|
||||
sphinx>=1.7
|
||||
|
@@ -1,4 +1,4 @@
|
||||
# see me at: http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/jupyterhub/master/docs/rest-api.yml#/default
|
||||
# see me at: http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyterhub/jupyterhub/master/docs/rest-api.yml#/default
|
||||
swagger: '2.0'
|
||||
info:
|
||||
title: JupyterHub
|
||||
@@ -7,7 +7,7 @@ info:
|
||||
license:
|
||||
name: BSD-3-Clause
|
||||
schemes:
|
||||
- [http, https]
|
||||
[http, https]
|
||||
securityDefinitions:
|
||||
token:
|
||||
type: apiKey
|
||||
@@ -190,7 +190,7 @@ paths:
|
||||
in: path
|
||||
required: true
|
||||
type: string
|
||||
- body:
|
||||
- name: body
|
||||
in: body
|
||||
schema:
|
||||
type: object
|
||||
@@ -202,34 +202,37 @@ paths:
|
||||
Timestamp of last-seen activity for this user.
|
||||
Only needed if this is not activity associated
|
||||
with using a given server.
|
||||
required: false
|
||||
servers:
|
||||
description: |
|
||||
Register activity for specific servers by name.
|
||||
The keys of this dict are the names of servers.
|
||||
The default server has an empty name ('').
|
||||
required: false
|
||||
type: object
|
||||
properties:
|
||||
'<server name>':
|
||||
description: |
|
||||
Activity for a single server.
|
||||
type: object
|
||||
required:
|
||||
- last_activity
|
||||
properties:
|
||||
last_activity:
|
||||
required: true
|
||||
type: string
|
||||
format: date-time
|
||||
description: |
|
||||
Timestamp of last-seen activity on this server.
|
||||
example:
|
||||
last_activity: '2019-02-06T12:54:14Z'
|
||||
servers:
|
||||
'':
|
||||
last_activity: '2019-02-06T12:54:14Z'
|
||||
gpu:
|
||||
last_activity: '2019-02-06T12:54:14Z'
|
||||
|
||||
example:
|
||||
last_activity: '2019-02-06T12:54:14Z'
|
||||
servers:
|
||||
'':
|
||||
last_activity: '2019-02-06T12:54:14Z'
|
||||
gpu:
|
||||
last_activity: '2019-02-06T12:54:14Z'
|
||||
responses:
|
||||
'401':
|
||||
$ref: '#/responses/Unauthorized'
|
||||
'404':
|
||||
description: No such user
|
||||
/users/{name}/server:
|
||||
post:
|
||||
summary: Start a user's single-user notebook server
|
||||
@@ -239,7 +242,7 @@ paths:
|
||||
in: path
|
||||
required: true
|
||||
type: string
|
||||
- options:
|
||||
- name: options
|
||||
description: |
|
||||
Spawn options can be passed as a JSON body
|
||||
when spawning via the API instead of spawn form.
|
||||
@@ -247,7 +250,8 @@ paths:
|
||||
will depend on the Spawner's configuration.
|
||||
in: body
|
||||
required: false
|
||||
type: object
|
||||
schema:
|
||||
type: object
|
||||
responses:
|
||||
'201':
|
||||
description: The user's notebook server has started
|
||||
@@ -280,7 +284,7 @@ paths:
|
||||
in: path
|
||||
required: true
|
||||
type: string
|
||||
- options:
|
||||
- name: options
|
||||
description: |
|
||||
Spawn options can be passed as a JSON body
|
||||
when spawning via the API instead of spawn form.
|
||||
@@ -288,7 +292,8 @@ paths:
|
||||
will depend on the Spawner's configuration.
|
||||
in: body
|
||||
required: false
|
||||
type: object
|
||||
schema:
|
||||
type: object
|
||||
responses:
|
||||
'201':
|
||||
description: The user's notebook named-server has started
|
||||
@@ -313,13 +318,20 @@ paths:
|
||||
Removing a server deletes things like the state of the stopped server.
|
||||
in: body
|
||||
required: false
|
||||
type: boolean
|
||||
schema:
|
||||
type: boolean
|
||||
responses:
|
||||
'204':
|
||||
description: The user's notebook named-server has stopped
|
||||
'202':
|
||||
description: The user's notebook named-server has not yet stopped as it is taking a while to stop
|
||||
/users/{name}/tokens:
|
||||
parameters:
|
||||
- name: name
|
||||
description: username
|
||||
in: path
|
||||
required: true
|
||||
type: string
|
||||
get:
|
||||
summary: List tokens for the user
|
||||
responses:
|
||||
@@ -329,25 +341,43 @@ paths:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/definitions/Token'
|
||||
'401':
|
||||
$ref: '#/responses/Unauthorized'
|
||||
'404':
|
||||
description: No such user
|
||||
post:
|
||||
summary: Create a new token for the user
|
||||
parameters:
|
||||
- name: expires_in
|
||||
type: number
|
||||
required: false
|
||||
- name: token_params
|
||||
in: body
|
||||
description: lifetime (in seconds) after which the requested token will expire.
|
||||
- name: note
|
||||
type: string
|
||||
required: false
|
||||
in: body
|
||||
description: A note attached to the token for future bookkeeping
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
expires_in:
|
||||
type: number
|
||||
description: lifetime (in seconds) after which the requested token will expire.
|
||||
note:
|
||||
type: string
|
||||
description: A note attached to the token for future bookkeeping
|
||||
responses:
|
||||
'201':
|
||||
description: The newly created token
|
||||
schema:
|
||||
$ref: '#/definitions/Token'
|
||||
'400':
|
||||
description: Body must be a JSON dict or empty
|
||||
/users/{name}/tokens/{token_id}:
|
||||
parameters:
|
||||
- name: name
|
||||
description: username
|
||||
in: path
|
||||
required: true
|
||||
type: string
|
||||
- name: token_id
|
||||
in: path
|
||||
required: true
|
||||
type: string
|
||||
get:
|
||||
summary: Get the model for a token by id
|
||||
responses:
|
||||
@@ -361,12 +391,13 @@ paths:
|
||||
'204':
|
||||
description: The token has been deleted
|
||||
/user:
|
||||
summary: Return authenticated user's model
|
||||
description:
|
||||
parameters:
|
||||
responses:
|
||||
'200':
|
||||
description: The authenticated user's model is returned.
|
||||
get:
|
||||
summary: Return authenticated user's model
|
||||
responses:
|
||||
'200':
|
||||
description: The authenticated user's model is returned.
|
||||
schema:
|
||||
$ref: '#/definitions/User'
|
||||
/groups:
|
||||
get:
|
||||
summary: List groups
|
||||
@@ -539,14 +570,15 @@ paths:
|
||||
Logging in via this method is only available when the active Authenticator
|
||||
accepts passwords (e.g. not OAuth).
|
||||
parameters:
|
||||
- name: username
|
||||
- name: credentials
|
||||
in: body
|
||||
required: false
|
||||
type: string
|
||||
- name: password
|
||||
in: body
|
||||
required: false
|
||||
type: string
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
username:
|
||||
type: string
|
||||
password:
|
||||
type: string
|
||||
responses:
|
||||
'200':
|
||||
description: The new API token
|
||||
@@ -562,10 +594,10 @@ paths:
|
||||
get:
|
||||
summary: Identify a user or service from an API token
|
||||
parameters:
|
||||
- name: token
|
||||
in: path
|
||||
required: true
|
||||
type: string
|
||||
- name: token
|
||||
in: path
|
||||
required: true
|
||||
type: string
|
||||
responses:
|
||||
'200':
|
||||
description: The user or service identified by the API token
|
||||
@@ -576,14 +608,14 @@ paths:
|
||||
summary: Identify a user from a cookie
|
||||
description: Used by single-user notebook servers to hand off cookie authentication to the Hub
|
||||
parameters:
|
||||
- name: cookie_name
|
||||
in: path
|
||||
required: true
|
||||
type: string
|
||||
- name: cookie_value
|
||||
in: path
|
||||
required: true
|
||||
type: string
|
||||
- name: cookie_name
|
||||
in: path
|
||||
required: true
|
||||
type: string
|
||||
- name: cookie_value
|
||||
in: path
|
||||
required: true
|
||||
type: string
|
||||
responses:
|
||||
'200':
|
||||
description: The user identified by the cookie
|
||||
@@ -618,6 +650,11 @@ paths:
|
||||
in: query
|
||||
required: true
|
||||
type: string
|
||||
responses:
|
||||
'200':
|
||||
description: Success
|
||||
'400':
|
||||
description: OAuth2Error
|
||||
/oauth2/token:
|
||||
post:
|
||||
summary: Request an OAuth2 token
|
||||
@@ -629,27 +666,27 @@ paths:
|
||||
parameters:
|
||||
- name: client_id
|
||||
description: The client id
|
||||
in: form
|
||||
in: formData
|
||||
required: true
|
||||
type: string
|
||||
- name: client_secret
|
||||
description: The client secret
|
||||
in: form
|
||||
in: formData
|
||||
required: true
|
||||
type: string
|
||||
- name: grant_type
|
||||
description: The grant type (always 'authorization_code')
|
||||
in: form
|
||||
in: formData
|
||||
required: true
|
||||
type: string
|
||||
- name: code
|
||||
description: The code provided by the authorization redirect
|
||||
in: form
|
||||
in: formData
|
||||
required: true
|
||||
type: string
|
||||
- name: redirect_uri
|
||||
description: The redirect url
|
||||
in: form
|
||||
in: formData
|
||||
required: true
|
||||
type: string
|
||||
responses:
|
||||
@@ -668,14 +705,28 @@ paths:
|
||||
post:
|
||||
summary: Shutdown the Hub
|
||||
parameters:
|
||||
- name: proxy
|
||||
- name: body
|
||||
in: body
|
||||
type: boolean
|
||||
description: Whether the proxy should be shutdown as well (default from Hub config)
|
||||
- name: servers
|
||||
in: body
|
||||
type: boolean
|
||||
description: Whether users' notebook servers should be shutdown as well (default from Hub config)
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
proxy:
|
||||
type: boolean
|
||||
description: Whether the proxy should be shutdown as well (default from Hub config)
|
||||
servers:
|
||||
type: boolean
|
||||
description: Whether users' notebook servers should be shutdown as well (default from Hub config)
|
||||
responses:
|
||||
'202':
|
||||
description: Shutdown successful
|
||||
'400':
|
||||
description: Unexpeced value for proxy or servers
|
||||
# Descriptions of common responses
|
||||
responses:
|
||||
NotFound:
|
||||
description: The specified resource was not found
|
||||
Unauthorized:
|
||||
description: Authentication/Authorization error
|
||||
definitions:
|
||||
User:
|
||||
type: object
|
||||
@@ -703,11 +754,10 @@ definitions:
|
||||
format: date-time
|
||||
description: Timestamp of last-seen activity from the user
|
||||
servers:
|
||||
type: object
|
||||
type: array
|
||||
description: The active servers for this user.
|
||||
items:
|
||||
schema:
|
||||
$ref: '#/definitions/Server'
|
||||
$ref: '#/definitions/Server'
|
||||
Server:
|
||||
type: object
|
||||
properties:
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 6.7 KiB |
@@ -1,30 +0,0 @@
|
||||
{% extends '!page.html' %}
|
||||
|
||||
{# Custom template for page.html
|
||||
|
||||
Alabaster theme does not provide blocks for prev/next at bottom of each page.
|
||||
This is _in addition_ to the prev/next in the sidebar. The "Prev/Next" text
|
||||
or symbols are handled by CSS classes in _static/custom.css
|
||||
#}
|
||||
|
||||
{% macro prev_next(prev, next, prev_title='', next_title='') %}
|
||||
{%- if prev %}
|
||||
<a class='left-prev' href="{{ prev.link|e }}" title="{{ _('previous chapter')}}">{{ prev_title or prev.title }}</a>
|
||||
{%- endif %}
|
||||
{%- if next %}
|
||||
<a class='right-next' href="{{ next.link|e }}" title="{{ _('next chapter')}}">{{ next_title or next.title }}</a>
|
||||
{%- endif %}
|
||||
<div style='clear:both;'></div>
|
||||
{% endmacro %}
|
||||
|
||||
|
||||
{% block body %}
|
||||
<div class='prev-next-top'>
|
||||
{{ prev_next(prev, next, 'Previous', 'Next') }}
|
||||
</div>
|
||||
|
||||
{{super()}}
|
||||
<div class='prev-next-bottom'>
|
||||
{{ prev_next(prev, next) }}
|
||||
</div>
|
||||
{% endblock %}
|
@@ -18,7 +18,7 @@ JupyterHub is painless, quick and with minimal user interruption.
|
||||
Read the Changelog
|
||||
==================
|
||||
|
||||
The `changelog <changelog.html>`_ contains information on what has
|
||||
The `changelog <../changelog.html>`_ contains information on what has
|
||||
changed with the new JupyterHub release, and any deprecation warnings.
|
||||
Read these notes to familiarize yourself with the coming changes. There
|
||||
might be new releases of authenticators & spawners you are using, so
|
||||
|
@@ -1,8 +1,8 @@
|
||||
.. _api-index:
|
||||
|
||||
##################
|
||||
The JupyterHub API
|
||||
##################
|
||||
##############
|
||||
JupyterHub API
|
||||
##############
|
||||
|
||||
:Release: |release|
|
||||
:Date: |today|
|
||||
|
@@ -7,9 +7,151 @@ command line for details.
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## 1.1
|
||||
|
||||
### [1.1.0] 2020-01-17
|
||||
|
||||
1.1 is a release with lots of accumulated fixes and improvements,
|
||||
especially in performance, metrics, and customization.
|
||||
There are no database changes in 1.1, so no database upgrade is required
|
||||
when upgrading from 1.0 to 1.1.
|
||||
|
||||
Of particular interest to deployments with automatic health checking and/or large numbers of users is that the slow startup time
|
||||
introduced in 1.0 by additional spawner validation can now be mitigated by `JupyterHub.init_spawners_timeout`,
|
||||
allowing the Hub to become responsive before the spawners may have finished validating.
|
||||
|
||||
Several new Prometheus metrics are added (and others fixed!)
|
||||
to measure sources of common performance issues,
|
||||
such as proxy interactions and startup.
|
||||
|
||||
1.1 also begins adoption of the Jupyter telemetry project in JupyterHub,
|
||||
See [The Jupyter Telemetry docs](https://jupyter-telemetry.readthedocs.io)
|
||||
for more info. The only events so far are starting and stopping servers,
|
||||
but more will be added in future releases.
|
||||
|
||||
There are many more fixes and improvements listed below.
|
||||
Thanks to everyone who has contributed to this release!
|
||||
|
||||
|
||||
#### New
|
||||
|
||||
- LocalProcessSpawner should work on windows by using psutil.pid_exists [#2882](https://github.com/jupyterhub/jupyterhub/pull/2882) ([@ociule](https://github.com/ociule))
|
||||
- trigger auth_state_hook prior to options form, add auth_state to template namespace [#2881](https://github.com/jupyterhub/jupyterhub/pull/2881) ([@minrk](https://github.com/minrk))
|
||||
- Added guide 'install jupyterlab the hard way' #2110 [#2842](https://github.com/jupyterhub/jupyterhub/pull/2842) ([@mangecoeur](https://github.com/mangecoeur))
|
||||
- Add prometheus metric to measure hub startup time [#2799](https://github.com/jupyterhub/jupyterhub/pull/2799) ([@rajat404](https://github.com/rajat404))
|
||||
- Add Spawner.auth_state_hook [#2555](https://github.com/jupyterhub/jupyterhub/pull/2555) ([@rcthomas](https://github.com/rcthomas))
|
||||
- Link services from jupyterhub pages [#2763](https://github.com/jupyterhub/jupyterhub/pull/2763) ([@rcthomas](https://github.com/rcthomas))
|
||||
- Add Spawner.auth_state_hook [#2555](https://github.com/jupyterhub/jupyterhub/pull/2555) ([@rcthomas](https://github.com/rcthomas))
|
||||
- `JupyterHub.user_redirect_hook` is added to allow admins to customize /user-redirect/ behavior [#2790](https://github.com/jupyterhub/jupyterhub/pull/2790) ([@yuvipanda](https://github.com/yuvipanda))
|
||||
- Add prometheus metric to measure hub startup time [#2799](https://github.com/jupyterhub/jupyterhub/pull/2799) ([@rajat404](https://github.com/rajat404))
|
||||
- Add prometheus metric to measure proxy route poll times [#2798](https://github.com/jupyterhub/jupyterhub/pull/2798) ([@rajat404](https://github.com/rajat404))
|
||||
- `PROXY_DELETE_DURATION_SECONDS` prometheus metric is added, to measure proxy route deletion times [#2788](https://github.com/jupyterhub/jupyterhub/pull/2788) ([@rajat404](https://github.com/rajat404))
|
||||
- `Service.oauth_no_confirm` is added, it is useful for admin-managed services that are considered part of the Hub and shouldn't need to prompt the user for access [#2767](https://github.com/jupyterhub/jupyterhub/pull/2767) ([@minrk](https://github.com/minrk))
|
||||
- `JupyterHub.default_server_name` is added to make the default server be a named server with provided name [#2735](https://github.com/jupyterhub/jupyterhub/pull/2735) ([@krinsman](https://github.com/krinsman))
|
||||
- `JupyterHub.init_spawners_timeout` is introduced to combat slow startups on large JupyterHub deployments [#2721](https://github.com/jupyterhub/jupyterhub/pull/2721) ([@minrk](https://github.com/minrk))
|
||||
- The configuration `uids` for local authenticators is added to consistently assign users UNIX id's between installations [#2687](https://github.com/jupyterhub/jupyterhub/pull/2687) ([@rgerkin](https://github.com/rgerkin))
|
||||
- `JupyterHub.activity_resolution` is introduced with a default value of 30s improving performance by not updating the database with user activity too often [#2605](https://github.com/jupyterhub/jupyterhub/pull/2605) ([@minrk](https://github.com/minrk))
|
||||
- [HubAuth](https://jupyterhub.readthedocs.io/en/stable/api/services.auth.html#jupyterhub.services.auth.HubAuth)'s SSL configuration can now be set through environment variables [#2588](https://github.com/jupyterhub/jupyterhub/pull/2588) ([@cmd-ntrf](https://github.com/cmd-ntrf))
|
||||
- Expose spawner.user_options in REST API. [#2755](https://github.com/jupyterhub/jupyterhub/pull/2755) ([@danielballan](https://github.com/danielballan))
|
||||
- add block for scripts included in head [#2828](https://github.com/jupyterhub/jupyterhub/pull/2828) ([@bitnik](https://github.com/bitnik))
|
||||
- Instrument JupyterHub to record events with jupyter_telemetry [Part II] [#2698](https://github.com/jupyterhub/jupyterhub/pull/2698) ([@Zsailer](https://github.com/Zsailer))
|
||||
- Make announcements visible without custom HTML [#2570](https://github.com/jupyterhub/jupyterhub/pull/2570) ([@consideRatio](https://github.com/consideRatio))
|
||||
- Display server version on admin page [#2776](https://github.com/jupyterhub/jupyterhub/pull/2776) ([@vilhelmen](https://github.com/vilhelmen))
|
||||
|
||||
#### Fixes
|
||||
|
||||
- Bugfix: pam_normalize_username didn't return username [#2876](https://github.com/jupyterhub/jupyterhub/pull/2876) ([@rkdarst](https://github.com/rkdarst))
|
||||
- Cleanup if spawner stop fails [#2849](https://github.com/jupyterhub/jupyterhub/pull/2849) ([@gabber12](https://github.com/gabber12))
|
||||
- Fix an issue occurring with the default spawner and `internal_ssl` enabled [#2785](https://github.com/jupyterhub/jupyterhub/pull/2785) ([@rpwagner](https://github.com/rpwagner))
|
||||
- Fix named servers to not be spawnable unless activated [#2772](https://github.com/jupyterhub/jupyterhub/pull/2772) ([@bitnik](https://github.com/bitnik))
|
||||
- JupyterHub now awaits proxy availability before accepting web requests [#2750](https://github.com/jupyterhub/jupyterhub/pull/2750) ([@minrk](https://github.com/minrk))
|
||||
- Fix a no longer valid assumption that MySQL and MariaDB need to have `innodb_file_format` and `innodb_large_prefix` configured [#2712](https://github.com/jupyterhub/jupyterhub/pull/2712) ([@chicocvenancio](https://github.com/chicocvenancio))
|
||||
- Login/Logout button now updates to Login on logout [#2705](https://github.com/jupyterhub/jupyterhub/pull/2705) ([@aar0nTw](https://github.com/aar0nTw))
|
||||
- Fix handling of exceptions within `pre_spawn_start` hooks [#2684](https://github.com/jupyterhub/jupyterhub/pull/2684) ([@GeorgianaElena](https://github.com/GeorgianaElena))
|
||||
- Fix an issue where a user could end up spawning a default server instead of a named server as intended [#2682](https://github.com/jupyterhub/jupyterhub/pull/2682) ([@rcthomas](https://github.com/rcthomas))
|
||||
- /hub/admin now redirects to login if unauthenticated [#2670](https://github.com/jupyterhub/jupyterhub/pull/2670) ([@GeorgianaElena](https://github.com/GeorgianaElena))
|
||||
- Fix spawning of users with names containing characters that needs to be escaped [#2648](https://github.com/jupyterhub/jupyterhub/pull/2648) ([@nicorikken](https://github.com/nicorikken))
|
||||
- Fix `TOTAL_USERS` prometheus metric [#2637](https://github.com/jupyterhub/jupyterhub/pull/2637) ([@GeorgianaElena](https://github.com/GeorgianaElena))
|
||||
- Fix `RUNNING_SERVERS` prometheus metric [#2629](https://github.com/jupyterhub/jupyterhub/pull/2629) ([@GeorgianaElena](https://github.com/GeorgianaElena))
|
||||
- Fix faulty redirects to 404 that could occur with the use of named servers [#2594](https://github.com/jupyterhub/jupyterhub/pull/2594) ([@vilhelmen](https://github.com/vilhelmen))
|
||||
- JupyterHub API spec is now a valid OpenAPI spec [#2590](https://github.com/jupyterhub/jupyterhub/pull/2590) ([@sbrunk](https://github.com/sbrunk))
|
||||
- Use of `--help` or `--version` previously could output unrelated errors [#2584](https://github.com/jupyterhub/jupyterhub/pull/2584) ([@minrk](https://github.com/minrk))
|
||||
- No longer crash on startup in Windows [#2560](https://github.com/jupyterhub/jupyterhub/pull/2560) ([@adelcast](https://github.com/adelcast))
|
||||
- Escape usernames in the frontend [#2640](https://github.com/jupyterhub/jupyterhub/pull/2640) ([@nicorikken](https://github.com/nicorikken))
|
||||
|
||||
#### Maintenance
|
||||
|
||||
|
||||
- Optimize CI jobs and default to bionic [#2897](https://github.com/jupyterhub/jupyterhub/pull/2897) ([@consideRatio](https://github.com/consideRatio))
|
||||
- catch connection error for ssl failures [#2889](https://github.com/jupyterhub/jupyterhub/pull/2889) ([@minrk](https://github.com/minrk))
|
||||
- Fix implementation of default server name [#2887](https://github.com/jupyterhub/jupyterhub/pull/2887) ([@krinsman](https://github.com/krinsman))
|
||||
- fixup allow_failures [#2880](https://github.com/jupyterhub/jupyterhub/pull/2880) ([@minrk](https://github.com/minrk))
|
||||
- Pass tests on Python 3.8 [#2879](https://github.com/jupyterhub/jupyterhub/pull/2879) ([@minrk](https://github.com/minrk))
|
||||
- Fixup .travis.yml [#2868](https://github.com/jupyterhub/jupyterhub/pull/2868) ([@consideRatio](https://github.com/consideRatio))
|
||||
- Update README's badges [#2867](https://github.com/jupyterhub/jupyterhub/pull/2867) ([@consideRatio](https://github.com/consideRatio))
|
||||
- Dockerfile: add build-essential to builder image [#2866](https://github.com/jupyterhub/jupyterhub/pull/2866) ([@rkdarst](https://github.com/rkdarst))
|
||||
- Dockerfile: Copy share/ to the final image [#2864](https://github.com/jupyterhub/jupyterhub/pull/2864) ([@rkdarst](https://github.com/rkdarst))
|
||||
- chore: Dockerfile updates [#2853](https://github.com/jupyterhub/jupyterhub/pull/2853) ([@jgwerner](https://github.com/jgwerner))
|
||||
- simplify Dockerfile [#2840](https://github.com/jupyterhub/jupyterhub/pull/2840) ([@minrk](https://github.com/minrk))
|
||||
- docker: fix onbuild image arg [#2839](https://github.com/jupyterhub/jupyterhub/pull/2839) ([@minrk](https://github.com/minrk))
|
||||
- remove redundant pip package list in docs environment.yml [#2838](https://github.com/jupyterhub/jupyterhub/pull/2838) ([@minrk](https://github.com/minrk))
|
||||
- docs: Update docs to run tests [#2812](https://github.com/jupyterhub/jupyterhub/pull/2812) ([@jgwerner](https://github.com/jgwerner))
|
||||
- remove redundant pip package list in docs environment.yml [#2838](https://github.com/jupyterhub/jupyterhub/pull/2838) ([@minrk](https://github.com/minrk))
|
||||
- updating to pandas docs theme [#2820](https://github.com/jupyterhub/jupyterhub/pull/2820) ([@choldgraf](https://github.com/choldgraf))
|
||||
- Adding institutional faq [#2800](https://github.com/jupyterhub/jupyterhub/pull/2800) ([@choldgraf](https://github.com/choldgraf))
|
||||
- Add inline comment to test [#2826](https://github.com/jupyterhub/jupyterhub/pull/2826) ([@consideRatio](https://github.com/consideRatio))
|
||||
- Raise error on missing specified config [#2824](https://github.com/jupyterhub/jupyterhub/pull/2824) ([@consideRatio](https://github.com/consideRatio))
|
||||
- chore: Refactor Dockerfile [#2816](https://github.com/jupyterhub/jupyterhub/pull/2816) ([@jgwerner](https://github.com/jgwerner))
|
||||
- chore: Update python versions in travis matrix [#2811](https://github.com/jupyterhub/jupyterhub/pull/2811) ([@jgwerner](https://github.com/jgwerner))
|
||||
- chore: Bump package versions used in pre-commit config [#2810](https://github.com/jupyterhub/jupyterhub/pull/2810) ([@jgwerner](https://github.com/jgwerner))
|
||||
- adding docs preview to circleci [#2803](https://github.com/jupyterhub/jupyterhub/pull/2803) ([@choldgraf](https://github.com/choldgraf))
|
||||
- adding institutional faq [#2800](https://github.com/jupyterhub/jupyterhub/pull/2800) ([@choldgraf](https://github.com/choldgraf))
|
||||
- The proxy's REST API listens on port `8001` [#2795](https://github.com/jupyterhub/jupyterhub/pull/2795) ([@bnuhero](https://github.com/bnuhero))
|
||||
- cull_idle_servers.py: rebind max_age and inactive_limit locally [#2794](https://github.com/jupyterhub/jupyterhub/pull/2794) ([@rkdarst](https://github.com/rkdarst))
|
||||
- Fix deprecation warnings [#2789](https://github.com/jupyterhub/jupyterhub/pull/2789) ([@tirkarthi](https://github.com/tirkarthi))
|
||||
- Log proxy class [#2783](https://github.com/jupyterhub/jupyterhub/pull/2783) ([@GeorgianaElena](https://github.com/GeorgianaElena))
|
||||
- Add docs for fixtures in CONTRIBUTING.md [#2782](https://github.com/jupyterhub/jupyterhub/pull/2782) ([@kinow](https://github.com/kinow))
|
||||
- Fix header project name typo [#2775](https://github.com/jupyterhub/jupyterhub/pull/2775) ([@kinow](https://github.com/kinow))
|
||||
- Remove unused setupegg.py [#2774](https://github.com/jupyterhub/jupyterhub/pull/2774) ([@kinow](https://github.com/kinow))
|
||||
- Log JupyterHub version on startup [#2752](https://github.com/jupyterhub/jupyterhub/pull/2752) ([@consideRatio](https://github.com/consideRatio))
|
||||
- Reduce verbosity for "Failing suspected API request to not-running server" (new) [#2751](https://github.com/jupyterhub/jupyterhub/pull/2751) ([@rkdarst](https://github.com/rkdarst))
|
||||
- Add missing package for json schema doc build [#2744](https://github.com/jupyterhub/jupyterhub/pull/2744) ([@willingc](https://github.com/willingc))
|
||||
- blacklist urllib3 versions with encoding bug [#2743](https://github.com/jupyterhub/jupyterhub/pull/2743) ([@minrk](https://github.com/minrk))
|
||||
- Remove tornado deprecated/unnecessary AsyncIOMainLoop().install() call [#2740](https://github.com/jupyterhub/jupyterhub/pull/2740) ([@kinow](https://github.com/kinow))
|
||||
- Fix deprecated call [#2739](https://github.com/jupyterhub/jupyterhub/pull/2739) ([@kinow](https://github.com/kinow))
|
||||
- Remove duplicate hub and authenticator traitlets from Spawner [#2736](https://github.com/jupyterhub/jupyterhub/pull/2736) ([@eslavich](https://github.com/eslavich))
|
||||
- Update issue template [#2725](https://github.com/jupyterhub/jupyterhub/pull/2725) ([@willingc](https://github.com/willingc))
|
||||
- Use autodoc-traits sphinx extension [#2723](https://github.com/jupyterhub/jupyterhub/pull/2723) ([@willingc](https://github.com/willingc))
|
||||
- Add New Server: change redirecting to relative to home page in js [#2714](https://github.com/jupyterhub/jupyterhub/pull/2714) ([@bitnik](https://github.com/bitnik))
|
||||
- Create a warning when creating a service implicitly from service_tokens [#2704](https://github.com/jupyterhub/jupyterhub/pull/2704) ([@katsar0v](https://github.com/katsar0v))
|
||||
- Fix mistypos [#2702](https://github.com/jupyterhub/jupyterhub/pull/2702) ([@rlukin](https://github.com/rlukin))
|
||||
- Add Jupyter community link [#2696](https://github.com/jupyterhub/jupyterhub/pull/2696) ([@mattjshannon](https://github.com/mattjshannon))
|
||||
- Fix failing travis tests [#2695](https://github.com/jupyterhub/jupyterhub/pull/2695) ([@GeorgianaElena](https://github.com/GeorgianaElena))
|
||||
- Documentation update: hint for using services instead of service tokens. [#2679](https://github.com/jupyterhub/jupyterhub/pull/2679) ([@katsar0v](https://github.com/katsar0v))
|
||||
- Replace header logo: jupyter -> jupyterhub [#2672](https://github.com/jupyterhub/jupyterhub/pull/2672) ([@consideRatio](https://github.com/consideRatio))
|
||||
- Update spawn-form example [#2662](https://github.com/jupyterhub/jupyterhub/pull/2662) ([@kinow](https://github.com/kinow))
|
||||
- Update flask hub authentication services example in doc [#2658](https://github.com/jupyterhub/jupyterhub/pull/2658) ([@cmd-ntrf](https://github.com/cmd-ntrf))
|
||||
- close `<div class="container">` tag in home.html [#2649](https://github.com/jupyterhub/jupyterhub/pull/2649) ([@bitnik](https://github.com/bitnik))
|
||||
- Some theme updates; no double NEXT/PREV buttons. [#2647](https://github.com/jupyterhub/jupyterhub/pull/2647) ([@Carreau](https://github.com/Carreau))
|
||||
- fix typos on technical reference documentation [#2646](https://github.com/jupyterhub/jupyterhub/pull/2646) ([@ilee38](https://github.com/ilee38))
|
||||
- Update links for Hadoop-related subprojects [#2645](https://github.com/jupyterhub/jupyterhub/pull/2645) ([@jcrist](https://github.com/jcrist))
|
||||
- corrected docker network create instructions in dockerfiles README [#2632](https://github.com/jupyterhub/jupyterhub/pull/2632) ([@bartolone](https://github.com/bartolone))
|
||||
- Fixed docs and testing code to use refactored SimpleLocalProcessSpawner [#2631](https://github.com/jupyterhub/jupyterhub/pull/2631) ([@danlester](https://github.com/danlester))
|
||||
- Update the config used for testing [#2628](https://github.com/jupyterhub/jupyterhub/pull/2628) ([@jtpio](https://github.com/jtpio))
|
||||
- Update doc: do not suggest depricated config key [#2626](https://github.com/jupyterhub/jupyterhub/pull/2626) ([@lumbric](https://github.com/lumbric))
|
||||
- Add missing words [#2625](https://github.com/jupyterhub/jupyterhub/pull/2625) ([@remram44](https://github.com/remram44))
|
||||
- cull-idle: Include a hint on how to add custom culling logic [#2613](https://github.com/jupyterhub/jupyterhub/pull/2613) ([@rkdarst](https://github.com/rkdarst))
|
||||
- Replace existing redirect code by Tornado's addslash decorator [#2609](https://github.com/jupyterhub/jupyterhub/pull/2609) ([@kinow](https://github.com/kinow))
|
||||
- Hide Stop My Server red button after server stopped. [#2577](https://github.com/jupyterhub/jupyterhub/pull/2577) ([@aar0nTw](https://github.com/aar0nTw))
|
||||
- Update link of `changelog` [#2565](https://github.com/jupyterhub/jupyterhub/pull/2565) ([@iblis17](https://github.com/iblis17))
|
||||
- typo [#2564](https://github.com/jupyterhub/jupyterhub/pull/2564) ([@julienchastang](https://github.com/julienchastang))
|
||||
- Update to simplify the language related to spawner options [#2558](https://github.com/jupyterhub/jupyterhub/pull/2558) ([@NikeNano](https://github.com/NikeNano))
|
||||
- Adding the use case of the Elucidata: How Jupyter Notebook is used in… [#2548](https://github.com/jupyterhub/jupyterhub/pull/2548) ([@IamViditAgarwal](https://github.com/IamViditAgarwal))
|
||||
- Dict rewritten as literal [#2546](https://github.com/jupyterhub/jupyterhub/pull/2546) ([@remyleone](https://github.com/remyleone))
|
||||
|
||||
## 1.0
|
||||
|
||||
### [1.0.0] 2019-04-XX
|
||||
### [1.0.0] 2019-05-03
|
||||
|
||||
JupyterHub 1.0 is a major milestone for JupyterHub.
|
||||
Huge thanks to the many people who have contributed to this release,
|
||||
@@ -283,7 +425,7 @@ and tornado < 5.0.
|
||||
coroutines, and CPU/memory/FD consumption.
|
||||
- Add async `Spawner.get_options_form` alternative to `.options_form`, so it can be a coroutine.
|
||||
- Add `JupyterHub.redirect_to_server` config to govern whether
|
||||
users should be sent to their server on login or the JuptyerHub home page.
|
||||
users should be sent to their server on login or the JupyterHub home page.
|
||||
- html page templates can be more easily customized and extended.
|
||||
- Allow registering external OAuth clients for using the Hub as an OAuth provider.
|
||||
- Add basic prometheus metrics at `/hub/metrics` endpoint.
|
||||
@@ -576,8 +718,9 @@ Fix removal of `/login` page in 0.4.0, breaking some OAuth providers.
|
||||
First preview release
|
||||
|
||||
|
||||
[Unreleased]: https://github.com/jupyterhub/jupyterhub/compare/1.0.0...HEAD
|
||||
[1.0.0]: https://github.com/jupyterhub/jupyterhub/compare/0.9.5...HEAD
|
||||
[Unreleased]: https://github.com/jupyterhub/jupyterhub/compare/1.1.0...HEAD
|
||||
[1.1.0]: https://github.com/jupyterhub/jupyterhub/compare/1.0.0...1.1.0
|
||||
[1.0.0]: https://github.com/jupyterhub/jupyterhub/compare/0.9.6...1.0.0
|
||||
[0.9.6]: https://github.com/jupyterhub/jupyterhub/compare/0.9.4...0.9.6
|
||||
[0.9.4]: https://github.com/jupyterhub/jupyterhub/compare/0.9.3...0.9.4
|
||||
[0.9.3]: https://github.com/jupyterhub/jupyterhub/compare/0.9.2...0.9.3
|
||||
|
@@ -19,6 +19,7 @@ extensions = [
|
||||
'sphinx.ext.napoleon',
|
||||
'autodoc_traits',
|
||||
'sphinx_copybutton',
|
||||
'sphinx-jsonschema',
|
||||
]
|
||||
|
||||
templates_path = ['_templates']
|
||||
@@ -37,7 +38,6 @@ from os.path import dirname
|
||||
docs = dirname(dirname(__file__))
|
||||
root = dirname(docs)
|
||||
sys.path.insert(0, root)
|
||||
sys.path.insert(0, os.path.join(docs, 'sphinxext'))
|
||||
|
||||
import jupyterhub
|
||||
|
||||
@@ -74,10 +74,7 @@ source_suffix = ['.rst', '.md']
|
||||
# -- Options for HTML output ----------------------------------------------
|
||||
|
||||
# The theme to use for HTML and HTML Help pages.
|
||||
import alabaster_jupyterhub
|
||||
|
||||
html_theme = 'alabaster_jupyterhub'
|
||||
html_theme_path = [alabaster_jupyterhub.get_html_theme_path()]
|
||||
html_theme = 'pandas_sphinx_theme'
|
||||
|
||||
html_logo = '_static/images/logo/logo.png'
|
||||
html_favicon = '_static/images/logo/favicon.ico'
|
||||
@@ -85,31 +82,6 @@ html_favicon = '_static/images/logo/favicon.ico'
|
||||
# Paths that contain custom static files (such as style sheets)
|
||||
html_static_path = ['_static']
|
||||
|
||||
html_theme_options = {
|
||||
'show_related': True,
|
||||
'description': 'Documentation for JupyterHub',
|
||||
'github_user': 'jupyterhub',
|
||||
'github_repo': 'jupyterhub',
|
||||
'github_banner': False,
|
||||
'github_button': True,
|
||||
'github_type': 'star',
|
||||
'show_powered_by': False,
|
||||
'extra_nav_links': {
|
||||
'GitHub Repo': 'http://github.com/jupyterhub/jupyterhub',
|
||||
'Issue Tracker': 'http://github.com/jupyterhub/jupyterhub/issues',
|
||||
},
|
||||
}
|
||||
|
||||
html_sidebars = {
|
||||
'**': [
|
||||
'about.html',
|
||||
'searchbox.html',
|
||||
'navigation.html',
|
||||
'relations.html',
|
||||
'sourcelink.html',
|
||||
]
|
||||
}
|
||||
|
||||
htmlhelp_basename = 'JupyterHubdoc'
|
||||
|
||||
# -- Options for LaTeX output ---------------------------------------------
|
||||
@@ -192,9 +164,7 @@ intersphinx_mapping = {'https://docs.python.org/3/': None}
|
||||
# -- Read The Docs --------------------------------------------------------
|
||||
|
||||
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
|
||||
if not on_rtd:
|
||||
html_theme = 'alabaster'
|
||||
else:
|
||||
if on_rtd:
|
||||
# readthedocs.org uses their theme by default, so no need to specify it
|
||||
# build rest-api, since RTD doesn't run make
|
||||
from subprocess import check_call as sh
|
||||
|
21
docs/source/contributing/index.rst
Normal file
21
docs/source/contributing/index.rst
Normal file
@@ -0,0 +1,21 @@
|
||||
============
|
||||
Contributing
|
||||
============
|
||||
|
||||
We want you to contribute to JupyterHub in ways that are most exciting
|
||||
& useful to you. We value documentation, testing, bug reporting & code equally,
|
||||
and are glad to have your contributions in whatever form you wish :)
|
||||
|
||||
Our `Code of Conduct <https://github.com/jupyter/governance/blob/master/conduct/code_of_conduct.md>`_
|
||||
(`reporting guidelines <https://github.com/jupyter/governance/blob/master/conduct/reporting_online.md>`_)
|
||||
helps keep our community welcoming to as many people as possible.
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
community
|
||||
setup
|
||||
docs
|
||||
tests
|
||||
roadmap
|
||||
security
|
@@ -112,13 +112,12 @@ happen.
|
||||
|
||||
Happy developing!
|
||||
|
||||
Using DummyAuthenticator & SimpleSpawner
|
||||
========================================
|
||||
Using DummyAuthenticator & SimpleLocalProcessSpawner
|
||||
====================================================
|
||||
|
||||
To simplify testing of JupyterHub, it’s helpful to use
|
||||
:class:`~jupyterhub.auth.DummyAuthenticator` instead of the default JupyterHub
|
||||
authenticator and `SimpleSpawner <https://github.com/jupyterhub/simplespawner>`_
|
||||
instead of the default spawner.
|
||||
authenticator and SimpleLocalProcessSpawner instead of the default spawner.
|
||||
|
||||
There is a sample configuration file that does this in
|
||||
``testing/jupyterhub_config.py``. To launch jupyterhub with this
|
||||
@@ -126,7 +125,6 @@ configuration:
|
||||
|
||||
.. code:: bash
|
||||
|
||||
pip install jupyterhub-simplespawner
|
||||
jupyterhub -f testing/jupyterhub_config.py
|
||||
|
||||
The default JupyterHub `authenticator
|
||||
@@ -137,15 +135,15 @@ require your system to have user accounts for each user you want to log in to
|
||||
JupyterHub as.
|
||||
|
||||
DummyAuthenticator allows you to log in with any username & password,
|
||||
while SimpleSpawner allows you to start servers without having to
|
||||
while SimpleLocalProcessSpawner allows you to start servers without having to
|
||||
create a unix user for each JupyterHub user. Together, these make it
|
||||
much easier to test JupyterHub.
|
||||
|
||||
Tip: If you are working on parts of JupyterHub that are common to all
|
||||
authenticators & spawners, we recommend using both DummyAuthenticator &
|
||||
SimpleSpawner. If you are working on just authenticator related parts,
|
||||
use only SimpleSpawner. Similarly, if you are working on just spawner
|
||||
related parts, use only DummyAuthenticator.
|
||||
SimpleLocalProcessSpawner. If you are working on just authenticator related
|
||||
parts, use only SimpleLocalProcessSpawner. Similarly, if you are working on
|
||||
just spawner related parts, use only DummyAuthenticator.
|
||||
|
||||
Troubleshooting
|
||||
===============
|
||||
|
@@ -23,27 +23,28 @@ Running the tests
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
pytest --async-test-timeout 15 -v jupyterhub/tests
|
||||
pytest -v jupyterhub/tests
|
||||
|
||||
This should display progress as it runs all the tests, printing
|
||||
information about any test failures as they occur.
|
||||
|
||||
The ``--async-test-timeout`` parameter is used by `pytest-tornado
|
||||
<https://github.com/eugeniy/pytest-tornado#markers>`_ to set the
|
||||
asynchronous test timeout to 15 seconds rather than the default 5,
|
||||
since some of our tests take longer than 5s to execute.
|
||||
If you wish to confirm test coverage the run tests with the `--cov` flag:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
pytest -v --cov=jupyterhub jupyterhub/tests
|
||||
|
||||
#. You can also run tests in just a specific file:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
pytest --async-test-timeout 15 -v jupyterhub/tests/<test-file-name>
|
||||
pytest -v jupyterhub/tests/<test-file-name>
|
||||
|
||||
#. To run a specific test only, you can do:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
pytest --async-test-timeout 15 -v jupyterhub/tests/<test-file-name>::<test-name>
|
||||
pytest -v jupyterhub/tests/<test-file-name>::<test-name>
|
||||
|
||||
This runs the test with function name ``<test-name>`` defined in
|
||||
``<test-file-name>``. This is very useful when you are iteratively
|
||||
@@ -65,14 +66,3 @@ All the tests are failing
|
||||
|
||||
Make sure you have completed all the steps in :ref:`contributing/setup` sucessfully, and
|
||||
can launch ``jupyterhub`` from the terminal.
|
||||
|
||||
Tests are timing out
|
||||
--------------------
|
||||
|
||||
The ``--async-test-timeout`` parameter to ``pytest`` is used by
|
||||
`pytest-tornado <https://github.com/eugeniy/pytest-tornado#markers>`_ to set
|
||||
the asynchronous test timeout to a higher value than the default of 5s,
|
||||
since some of our tests take longer than 5s to execute. If the tests
|
||||
are still timing out, try increasing that value even more. You can
|
||||
also set an environment variable ``ASYNC_TEST_TIMEOUT`` instead of
|
||||
passing ``--async-test-timeout`` to each invocation of pytest.
|
||||
|
50
docs/source/events/index.rst
Normal file
50
docs/source/events/index.rst
Normal file
@@ -0,0 +1,50 @@
|
||||
Eventlogging and Telemetry
|
||||
==========================
|
||||
|
||||
JupyterHub can be configured to record structured events from a running server using Jupyter's `Telemetry System`_. The types of events that JupyterHub emits are defined by `JSON schemas`_ listed below_
|
||||
|
||||
emitted as JSON data, defined and validated by the JSON schemas listed below.
|
||||
|
||||
|
||||
.. _logging: https://docs.python.org/3/library/logging.html
|
||||
.. _`Telemetry System`: https://github.com/jupyter/telemetry
|
||||
.. _`JSON schemas`: https://json-schema.org/
|
||||
|
||||
How to emit events
|
||||
------------------
|
||||
|
||||
Event logging is handled by its ``Eventlog`` object. This leverages Python's standing logging_ library to emit, filter, and collect event data.
|
||||
|
||||
|
||||
To begin recording events, you'll need to set two configurations:
|
||||
|
||||
1. ``handlers``: tells the EventLog *where* to route your events. This trait is a list of Python logging handlers that route events to
|
||||
2. ``allows_schemas``: tells the EventLog *which* events should be recorded. No events are emitted by default; all recorded events must be listed here.
|
||||
|
||||
Here's a basic example:
|
||||
|
||||
.. code-block::
|
||||
|
||||
import logging
|
||||
|
||||
c.EventLog.handlers = [
|
||||
logging.FileHandler('event.log'),
|
||||
]
|
||||
|
||||
c.EventLog.allowed_schemas = [
|
||||
'hub.jupyter.org/server-action'
|
||||
]
|
||||
|
||||
The output is a file, ``"event.log"``, with events recorded as JSON data.
|
||||
|
||||
|
||||
|
||||
.. _below:
|
||||
|
||||
Event schemas
|
||||
-------------
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
server-actions.rst
|
1
docs/source/events/server-actions.rst
Normal file
1
docs/source/events/server-actions.rst
Normal file
@@ -0,0 +1 @@
|
||||
.. jsonschema:: ../../../jupyterhub/event-schemas/server-actions/v1.yaml
|
@@ -77,13 +77,17 @@ easy to do with RStudio too.
|
||||
- Earth Lab at CU
|
||||
- [Tutorial on Parallel R on JupyterHub](https://earthdatascience.org/tutorials/parallel-r-on-jupyterhub/)
|
||||
|
||||
### George Washington University
|
||||
|
||||
- [Jupyter Hub](http://go.gwu.edu/jupyter) with university single-sign-on. Deployed early 2017.
|
||||
|
||||
### HTCondor
|
||||
|
||||
- [HTCondor Python Bindings Tutorial from HTCondor Week 2017 includes information on their JupyterHub tutorials](https://research.cs.wisc.edu/htcondor/HTCondorWeek2017/presentations/TueBockelman_Python.pdf)
|
||||
|
||||
### University of Illinois
|
||||
|
||||
- https://datascience.business.illinois.edu
|
||||
- https://datascience.business.illinois.edu (currently down; checked 04/26/19)
|
||||
|
||||
### IllustrisTNG Simulation Project
|
||||
|
||||
@@ -110,6 +114,10 @@ easy to do with RStudio too.
|
||||
- [Data Science (DICE) group](https://dice.cs.uni-paderborn.de/)
|
||||
- [nbgraderutils](https://github.com/dice-group/nbgraderutils): Use JupyterHub + nbgrader + iJava kernel for online Java exercises. Used in lecture Statistical Natural Language Processing.
|
||||
|
||||
### Penn State University
|
||||
|
||||
- [Press release](https://news.psu.edu/story/523093/2018/05/24/new-open-source-web-apps-available-students-and-faculty): "New open-source web apps available for students and faculty" (but Hub is currently down; checked 04/26/19)
|
||||
|
||||
### University of Rochester CIRC
|
||||
|
||||
- [JupyterHub Userguide](https://info.circ.rochester.edu/Web_Applications/JupyterHub.html) - Slurm, beehive
|
||||
@@ -134,7 +142,10 @@ easy to do with RStudio too.
|
||||
- Kristen Thyng - Oceanography
|
||||
- [Teaching with JupyterHub and nbgrader](http://kristenthyng.com/blog/2016/09/07/jupyterhub+nbgrader/)
|
||||
|
||||
|
||||
### Elucidata
|
||||
- What's new in Jupyter Notebooks @[Elucidata](https://elucidata.io/):
|
||||
- Using Jupyter Notebooks with Jupyterhub on GCP, managed by GKE
|
||||
- https://medium.com/elucidata/why-you-should-be-using-a-jupyter-notebook-8385a4ccd93d
|
||||
|
||||
## Service Providers
|
||||
|
||||
@@ -160,6 +171,10 @@ easy to do with RStudio too.
|
||||
- https://getcarina.com/blog/learning-how-to-whale/
|
||||
- http://carolynvanslyck.com/talk/carina/jupyterhub/#/
|
||||
|
||||
### Hadoop
|
||||
|
||||
- [Deploying JupyterHub on Hadoop](https://jupyterhub-on-hadoop.readthedocs.io)
|
||||
|
||||
|
||||
## Miscellaneous
|
||||
|
||||
|
@@ -1,5 +1,10 @@
|
||||
Getting Started
|
||||
===============
|
||||
Get Started
|
||||
===========
|
||||
|
||||
This section covers how to configure and customize JupyterHub for your
|
||||
needs. It contains information about authentication, networking, security, and
|
||||
other topics that are relevant to individuals or organizations deploying their
|
||||
own JupyterHub.
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
@@ -10,3 +15,4 @@ Getting Started
|
||||
authenticators-users-basics
|
||||
spawners-basics
|
||||
services-basics
|
||||
institutional-faq
|
||||
|
266
docs/source/getting-started/institutional-faq.md
Normal file
266
docs/source/getting-started/institutional-faq.md
Normal file
@@ -0,0 +1,266 @@
|
||||
# Institutional FAQ
|
||||
|
||||
This page contains common questions from users of JupyterHub,
|
||||
broken down by their roles within organizations.
|
||||
|
||||
## For all
|
||||
|
||||
### Is it appropriate for adoption within a larger institutional context?
|
||||
|
||||
Yes! JupyterHub has been used at-scale for large pools of users, as well
|
||||
as complex and high-performance computing. For example, UC Berkeley uses
|
||||
JupyterHub for its Data Science Education Program courses (serving over
|
||||
3,000 students). The Pangeo project uses JupyterHub to provide access
|
||||
to scalable cloud computing with Dask. JupyterHub is stable customizable
|
||||
to the use-cases of large organizations.
|
||||
|
||||
### I keep hearing about Jupyter Notebook, JupyterLab, and now JupyterHub. What’s the difference?
|
||||
|
||||
Here is a quick breakdown of these three tools:
|
||||
|
||||
* **The Jupyter Notebook** is a document specification (the `.ipynb`) file that interweaves
|
||||
narrative text with code cells and their outputs. It is also a graphical interface
|
||||
that allows users to edit these documents. There are also several other graphical interfaces
|
||||
that allow users to edit the `.ipynb` format (nteract, Jupyer Lab, Google Colab, Kaggle, etc).
|
||||
* **JupyterLab** is a flexible and extendible user interface for interactive computing. It
|
||||
has several extensions that are tailored for using Jupyter Notebooks, as well as extensions
|
||||
for other parts of the data science stack.
|
||||
* **JupyterHub** is an application that manages interactive computing sessions for **multiple users**.
|
||||
It also connects them with infrastructure those users wish to access. It can provide
|
||||
remote access to Jupyter Notebooks and Jupyter Lab for many people.
|
||||
|
||||
## For management
|
||||
|
||||
### Briefly, what problem does JupyterHub solve for us?
|
||||
|
||||
JupyterHub provides a shared platform for data science and collaboration.
|
||||
It allows users to utilize familiar data science workflows (such as the scientific python stack,
|
||||
the R tidyverse, and Jupyter Notebooks) on institutional infrastructure. It also allows administrators
|
||||
some control over access to resources, security, environments, and authentication.
|
||||
|
||||
### Is JupyterHub mature? Why should we trust it?
|
||||
|
||||
Yes - the core JupyterHub application recently
|
||||
reached 1.0 status, and is considered stable and performant for most institutions.
|
||||
JupyterHub has also been deployed (along with other tools) to work on
|
||||
scalable infrastructure, large datasets, and high-performance computing.
|
||||
|
||||
### Who else uses JupyterHub?
|
||||
|
||||
JupyterHub is used at a variety of institutions in academia,
|
||||
industry, and government research labs. It is most-commonly used by two kinds of groups:
|
||||
|
||||
* Small teams (e.g., data science teams, research labs, or collaborative projects) to provide a
|
||||
shared resource for interactive computing, collaboration, and analytics.
|
||||
* Large teams (e.g., a department, a large class, or a large group of remote users) to provide
|
||||
access to organizational hardware, data, and analytics environments at scale.
|
||||
|
||||
Here are a sample of organizations that use JupyterHub:
|
||||
|
||||
* **Universities and colleges**: UC Berkeley, UC San Diego, Cal Poly SLO, Harvard University, University of Chicago,
|
||||
University of Oslo, University of Sheffield, Université Paris Sud, University of Versailles
|
||||
* **Research laboratories**: NASA, NCAR, NOAA, the Large Synoptic Survey Telescope, Brookhaven National Lab,
|
||||
Minnesota Supercomputing Institute, ALCF, CERN, Lawrence Livermore National Laboratory
|
||||
* **Online communities**: Pangeo, Quantopian, mybinder.org, MathHub, Open Humans
|
||||
* **Computing infrastructure providers**: NERSC, San Diego Supercomputing Center, Compute Canada
|
||||
* **Companies**: Capital One, SANDVIK code, Globus
|
||||
|
||||
See the [Gallery of JupyterHub deployments](../gallery-jhub-deployments.md) for
|
||||
a more complete list of JupyterHub deployments at institutions.
|
||||
|
||||
### How does JupyterHub compare with hosted products, like Google Colaboratory, RStudio.cloud, or Anaconda Enterprise?
|
||||
|
||||
JupyterHub puts you in control of your data, infrastructure, and coding environment.
|
||||
In addition, it is vendor neutral, which reduces lock-in to a particular vendor or service.
|
||||
JupyterHub provides access to interactive computing environments in the cloud (similar to each of these services).
|
||||
Compared with the tools above, it is more flexible, more customizable, free, and
|
||||
gives administrators more control over their setup and hardware.
|
||||
|
||||
Because JupyterHub is an open-source, community-driven tool, it can be extended and
|
||||
modified to fit an institution's needs. It plays nicely with the open source data science
|
||||
stack, and can serve a variety of computing enviroments, user interfaces, and
|
||||
computational hardware. It can also be deployed anywhere - on enterprise cloud infrastructure, on
|
||||
High-Performance-Computing machines, on local hardware, or even on a single laptop, which
|
||||
is not possible with most other tools for shared interactive computing.
|
||||
|
||||
## For IT
|
||||
|
||||
### How would I set up JupyterHub on institutional hardware?
|
||||
|
||||
That depends on what kind of hardware you've got. JupyterHub is flexible enough to be deployed
|
||||
on a variety of hardware, including in-room hardware, on-prem clusters, cloud infrastructure,
|
||||
etc.
|
||||
|
||||
The most common way to set up a JupyterHub is to use a JupyterHub distribution, these are pre-configured
|
||||
and opinionated ways to set up a JupyterHub on particular kinds of infrastructure. The two distributions
|
||||
that we currently suggest are:
|
||||
|
||||
* [Zero to JupyterHub for Kubernetes](https://z2jh.jupyter.org) is a scalable JupyterHub deployment and
|
||||
guide that runs on Kubernetes. Better for larger or dynamic user groups (50-10,000) or more complex
|
||||
compute/data needs.
|
||||
* [The Littlest JupyterHub](https://tljh.jupyter.org) is a lightweight JupyterHub that runs on a single
|
||||
single machine (in the cloud or under your desk). Better for smaller usergroups (4-80) or more
|
||||
lightweight computational resources.
|
||||
|
||||
|
||||
### Does JupyterHub run well in the cloud?
|
||||
|
||||
Yes - most deployments of JupyterHub are run via cloud infrastructure and on a variety of cloud providers.
|
||||
Depending on the distribution of JupyterHub that you'd like to use, you can also connect your JupyterHub
|
||||
deployment with a number of other cloud-native services so that users have access to other resources from
|
||||
their interactive computing sessions.
|
||||
|
||||
For example, if you use the [Zero to JupyterHub for Kubernetes](https://z2jh.jupyter.org) distribution,
|
||||
you'll be able to utilize container-based workflows of other technologies such as the [dask-kubernetes](https://kubernetes.dask.org/en/latest/)
|
||||
project for distributed computing.
|
||||
|
||||
The Z2JH Helm Chart also has some functionality built in for auto-scaling your cluster up and down
|
||||
as more resources are needed - allowing you to utilize the benefits of a flexible cloud-based deployment.
|
||||
|
||||
### Is JupyterHub secure?
|
||||
|
||||
The short answer: yes. JupyterHub as a standalone application has been battle-tested at an institutional
|
||||
level for several years, and makes a number of "default" security decisions that are reasonable for most
|
||||
users.
|
||||
|
||||
* For security considerations in the base JupyterHub application,
|
||||
[see the JupyterHub security page](https://jupyterhub.readthedocs.io/en/stable/reference/websecurity.html)
|
||||
* For security considerations when deploying JupyterHub on Kubernetes, see the
|
||||
[JupyterHub on Kubernetes security page](https://zero-to-jupyterhub.readthedocs.io/en/latest/security.html).
|
||||
|
||||
The longer answer: it depends on your deployment. Because JupyterHub is very flexible, it can be used
|
||||
in a variety of deployment setups. This often entails connecting your JupyterHub to **other** infrastructure
|
||||
(such as a [Dask Gateway service](https://gateway.dask.org/)). There are many security decisions to be made
|
||||
in these cases, and the security of your JupyterHub deployment will often depend on these decisions.
|
||||
|
||||
If you are worried about security, don't hesitate to reach out to the JupyterHub community in the
|
||||
[Jupyter Community Forum](https://discourse.jupyter.org/c/jupyterhub). This community of practice has many
|
||||
individuals with experience running secure JupyterHub deployments.
|
||||
|
||||
|
||||
### Does JupyterHub provide computing or data infrastructure?
|
||||
|
||||
No - JupyterHub manages user sessions and can *control* computing infrastructure, but it does not provide these
|
||||
things itself. You are expected to run JupyterHub on your own infrastructure (local or in the cloud). Moreover,
|
||||
JupyterHub has no internal concept of "data", but is designed to be able to communicate with data repositories
|
||||
(again, either locally or remotely) for use within interactive computing sessions.
|
||||
|
||||
|
||||
### How do I manage users?
|
||||
|
||||
JupyterHub offers a few options for managing your users. Upon setting up a JupyterHub, you can choose what
|
||||
kind of **authentication** you'd like to use. For example, you can have users sign up with an institutional
|
||||
email address, or choose a username / password when they first log-in, or offload authentication onto
|
||||
another service such as an organization's OAuth.
|
||||
|
||||
The users of a JupyterHub are stored locally, and can be modified manually by an administrator of the JupyterHub.
|
||||
Moreover, the *active* users on a JupyterHub can be found on the administrator's page. This page
|
||||
gives you the abiltiy to stop or restart kernels, inspect user filesystems, and even take over user
|
||||
sessions to assist them with debugging.
|
||||
|
||||
### How do I manage software environments?
|
||||
|
||||
A key benefit of JupyterHub is the ability for an administrator to define the environment(s) that users
|
||||
have access to. There are many ways to do this, depending on what kind of infrastructure you're using for
|
||||
your JupyterHub.
|
||||
|
||||
For example, **The Littlest JupyterHub** runs on a single VM. In this case, the administrator defines
|
||||
an environment by installing packages to a shared folder that exists on the path of all users. The
|
||||
**JupyterHub for Kubernetes** deployment uses Docker images to define environments. You can create your
|
||||
own list of Docker images that users can select from, and can also control things like the amount of
|
||||
RAM available to users, or the types of machines that their sessions will use in the cloud.
|
||||
|
||||
### How does JupyterHub manage computational resources?
|
||||
|
||||
For interactive computing sessions, JupyterHub controls computational resources via a **spawner**.
|
||||
Spawners define how a new user session is created, and are customized for particular kinds of
|
||||
infrastructure. For example, the KubeSpawner knows how to control a Kubernetes deployment
|
||||
to create new pods when users log in.
|
||||
|
||||
For more sophisticated computational resources (like distributed computing), JupyterHub can
|
||||
connect with other infrastructure tools (like Dask or Spark). This allows users to control
|
||||
scalable or high-performance resources from within their JupyterHub sessions. The logic of
|
||||
how those resources are controlled is taken care of by the non-JupyterHub application.
|
||||
|
||||
|
||||
### Can JupyterHub be used with my high-performance computing resources?
|
||||
|
||||
Yes - JupyterHub can provide access to many kinds of computing infrastructure.
|
||||
Especially when combined with other open-source schedulers such as Dask, you can manage fairly
|
||||
complex computing infrastructure from the interactive sessions of a JupyterHub. For example
|
||||
[see the Dask HPC page](https://docs.dask.org/en/latest/setup/hpc.html).
|
||||
|
||||
### How much resources do user sessions take?
|
||||
|
||||
This is highly configurable by the administrator. If you wish for your users to have simple
|
||||
data analytics environments for prototyping and light data exploring, you can restrict their
|
||||
memory and CPU based on the resources that you have available. If you'd like your JupyterHub
|
||||
to serve as a gateway to high-performance compute or data resources, you may increase the
|
||||
resources available on user machines, or connect them with computing infrastructure elsewhere.
|
||||
|
||||
### Can I customize the look and feel of a JupyterHub?
|
||||
|
||||
JupyterHub provides some customization of the graphics displayed to users. The most common
|
||||
modification is to add custom branding to the JupyterHub login page, loading pages, and
|
||||
various elements that persist across all pages (such as headers).
|
||||
|
||||
## For Technical Leads
|
||||
|
||||
### Will JupyterHub “just work” with our team's interactive computing setup?
|
||||
|
||||
Depending on the complexity of your setup, you'll have different experiences with "out of the box"
|
||||
distributions of JupyterHub. If all of the resources you need will fit on a single VM, then
|
||||
[The Littlest JupyterHub](https://tljh.jupyter.org) should get you up-and-running within
|
||||
a half day or so. For more complex setups, such as scalable Kubernetes clusters or access
|
||||
to high-performance computing and data, it will require more time and expertise with
|
||||
the technologies your JupyterHub will use (e.g., dev-ops knowledge with cloud computing).
|
||||
|
||||
In general, the base JupyterHub deployment is not the bottleneck for setup, it is connecting
|
||||
your JupyterHub with the various services and tools that you wish to provide to your users.
|
||||
|
||||
|
||||
### How well does JupyterHub scale? What are JupyterHub's limitations?
|
||||
|
||||
JupyterHub works well at both a small scale (e.g., a single VM or machine) as well as a
|
||||
high scale (e.g., a scalable Kubernetes cluster). It can be used for teams as small a 2, and
|
||||
for user bases as large as 10,000. The scalability of JupyterHub largely depends on the
|
||||
infrastructure on which it is deployed. JupyterHub has been designed to be lightweight and
|
||||
flexible, so you can tailor your JupyterHub deployment to your needs.
|
||||
|
||||
|
||||
### Is JupyterHub resilient? What happens when a machine goes down?
|
||||
|
||||
For JupyterHubs that are deployed in a containerized environment (e.g., Kubernetes), it is
|
||||
possible to configure the JupyterHub to be fairly resistant to failures in the system.
|
||||
For example, if JupyterHub fails, then user sessions will not be affected (though new
|
||||
users will not be able to log in). When a JupyterHub process is restarted, it should
|
||||
seamlessly connect with the user database and the system will return to normal.
|
||||
Again, the details of your JupyterHub deployment (e.g., whether it's deployed on a scalable cluster)
|
||||
will affect the resiliency of the deployment.
|
||||
|
||||
### What interfaces does JupyterHub support?
|
||||
|
||||
Out of the box, JupyterHub supports a variety of popular data science interfaces for user sessions,
|
||||
such as JupyterLab, Jupyter Notebooks, and RStudio. Any interface that can be served
|
||||
via a web address can be served with a JupyterHub (with the right setup).
|
||||
|
||||
### Does JupyterHub make it easier for our team to collaborate?
|
||||
|
||||
JupyterHub provides a standardized environment and access to shared resources for your teams.
|
||||
This greatly reduces the cost associated with sharing analyses and content with other team
|
||||
members, and makes it easier to collaborate and build off of one another's ideas. Combined with
|
||||
access to high-performance computing and data, JupyterHub provides a common resource to
|
||||
amplify your team's ability to prototype their analyses, scale them to larger data, and then
|
||||
share their results with one another.
|
||||
|
||||
JupyterHub also provides a computational framework to share computational narratives between
|
||||
different levels of an organization. For example, data scientists can share Jupyter Notebooks
|
||||
rendered as [voila dashboards](https://voila.readthedocs.io/en/stable/) with those who are not
|
||||
familiar with programming, or create publicly-available interactive analyses to allow others to
|
||||
interact with your work.
|
||||
|
||||
### Can I use JupyterHub with R/RStudio or other languages and environments?
|
||||
|
||||
Yes, Jupyter is a polyglot project, and there are over 40 community-provided kernels for a variety
|
||||
of languages (the most common being Python, Julia, and R). You can also use a JupyterHub to provide
|
||||
access to other interfaces, such as RStudio, that provide their own access to a language kernel.
|
@@ -41,7 +41,7 @@ port.
|
||||
|
||||
## Set the Proxy's REST API communication URL (optional)
|
||||
|
||||
By default, this REST API listens on port 8081 of `localhost` only.
|
||||
By default, this REST API listens on port 8001 of `localhost` only.
|
||||
The Hub service talks to the proxy via a REST API on a secondary port. The
|
||||
API URL can be configured separately and override the default settings.
|
||||
|
||||
|
@@ -3,9 +3,9 @@
|
||||
When working with JupyterHub, a **Service** is defined as a process
|
||||
that interacts with the Hub's REST API. A Service may perform a specific
|
||||
or action or task. For example, shutting down individuals' single user
|
||||
notebook servers that have been is a good example of a task that could
|
||||
be automated by a Service. Let's look at how the [cull_idle_servers][]
|
||||
script can be used as a Service.
|
||||
notebook servers that have been idle for some time is a good example of
|
||||
a task that could be automated by a Service. Let's look at how the
|
||||
[cull_idle_servers][] script can be used as a Service.
|
||||
|
||||
## Real-world example to cull idle servers
|
||||
|
||||
|
BIN
docs/source/images/jhub-fluxogram.jpeg
Normal file
BIN
docs/source/images/jhub-fluxogram.jpeg
Normal file
Binary file not shown.
After Width: | Height: | Size: 158 KiB |
15
docs/source/index-about.rst
Normal file
15
docs/source/index-about.rst
Normal file
@@ -0,0 +1,15 @@
|
||||
=====
|
||||
About
|
||||
=====
|
||||
|
||||
JupyterHub is an open source project and community. It is a part of the
|
||||
`Jupyter Project <https://jupyter.org>`_. JupyterHub is an open and inclusive
|
||||
community, and invites contributions from anyone. This section covers information
|
||||
about our community, as well as ways that you can connect and get involved.
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
|
||||
contributor-list
|
||||
changelog
|
||||
gallery-jhub-deployments
|
13
docs/source/index-admin.rst
Normal file
13
docs/source/index-admin.rst
Normal file
@@ -0,0 +1,13 @@
|
||||
=====================
|
||||
Administrator's Guide
|
||||
=====================
|
||||
|
||||
This guide covers best-practices, tips, common questions and operations, as
|
||||
well as other information relevant to running your own JupyterHub over time.
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
troubleshooting
|
||||
admin/upgrading
|
||||
changelog
|
@@ -2,21 +2,37 @@
|
||||
JupyterHub
|
||||
==========
|
||||
|
||||
`JupyterHub`_, a multi-user **Hub**, spawns, manages, and proxies multiple
|
||||
`JupyterHub`_ is the best way to serve `Jupyter notebook`_ for multiple users.
|
||||
It can be used in a classes of students, a corporate data science group or scientific
|
||||
research group. It is a multi-user **Hub** that spawns, manages, and proxies multiple
|
||||
instances of the single-user `Jupyter notebook`_ server.
|
||||
JupyterHub can be used to serve notebooks to a class of students, a corporate
|
||||
data science group, or a scientific research group.
|
||||
|
||||
.. image:: images/jhub-parts.png
|
||||
To make life easier, JupyterHub have distributions. Be sure to
|
||||
take a look at them before continuing with the configuration of the broad
|
||||
original system of `JupyterHub`_. Today, you can find two main cases:
|
||||
|
||||
1. If you need a simple case for a small amount of users (0-100) and single server
|
||||
take a look at
|
||||
`The Littlest JupyterHub <https://github.com/jupyterhub/the-littlest-jupyterhub>`__ distribution.
|
||||
2. If you need to allow for even more users, a dynamic amount of servers can be used on a cloud,
|
||||
take a look at the `Zero to JupyterHub with Kubernetes <https://github.com/jupyterhub/zero-to-jupyterhub-k8s>`__ .
|
||||
|
||||
|
||||
Four subsystems make up JupyterHub:
|
||||
|
||||
* a **Hub** (tornado process) that is the heart of JupyterHub
|
||||
* a **configurable http proxy** (node-http-proxy) that receives the requests from the client's browser
|
||||
* multiple **single-user Jupyter notebook servers** (Python/IPython/tornado) that are monitored by Spawners
|
||||
* an **authentication class** that manages how users can access the system
|
||||
|
||||
|
||||
Besides these central pieces, you can add optional configurations through a `config.py` file and manage users kernels on an admin panel. A simplification of the whole system can be seen in the figure below:
|
||||
|
||||
.. image:: images/jhub-fluxogram.jpeg
|
||||
:alt: JupyterHub subsystems
|
||||
:width: 40%
|
||||
:align: right
|
||||
:width: 80%
|
||||
:align: center
|
||||
|
||||
Three subsystems make up JupyterHub:
|
||||
|
||||
* a multi-user **Hub** (tornado process)
|
||||
* a **configurable http proxy** (node-http-proxy)
|
||||
* multiple **single-user Jupyter notebook servers** (Python/IPython/tornado)
|
||||
|
||||
JupyterHub performs the following functions:
|
||||
|
||||
@@ -56,46 +72,41 @@ Installation Guide
|
||||
------------------
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
:maxdepth: 2
|
||||
|
||||
installation-guide
|
||||
quickstart
|
||||
quickstart-docker
|
||||
installation-basics
|
||||
|
||||
Getting Started
|
||||
---------------
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
:maxdepth: 2
|
||||
|
||||
getting-started/index
|
||||
getting-started/config-basics
|
||||
getting-started/networking-basics
|
||||
getting-started/security-basics
|
||||
getting-started/authenticators-users-basics
|
||||
getting-started/spawners-basics
|
||||
getting-started/services-basics
|
||||
|
||||
Technical Reference
|
||||
-------------------
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
:maxdepth: 2
|
||||
|
||||
reference/index
|
||||
reference/technical-overview
|
||||
reference/websecurity
|
||||
reference/authenticators
|
||||
reference/spawners
|
||||
reference/services
|
||||
reference/rest
|
||||
reference/templates
|
||||
reference/config-user-env
|
||||
reference/config-examples
|
||||
reference/config-ghoauth
|
||||
reference/config-proxy
|
||||
reference/config-sudo
|
||||
|
||||
Administrators guide
|
||||
--------------------
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
index-admin
|
||||
|
||||
API Reference
|
||||
-------------
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
api/index
|
||||
|
||||
Contributing
|
||||
------------
|
||||
@@ -109,51 +120,17 @@ Our `Code of Conduct <https://github.com/jupyter/governance/blob/master/conduct/
|
||||
helps keep our community welcoming to as many people as possible.
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
:maxdepth: 2
|
||||
|
||||
contributing/community
|
||||
contributing/setup
|
||||
contributing/docs
|
||||
contributing/tests
|
||||
contributing/roadmap
|
||||
contributing/security
|
||||
|
||||
Upgrading JupyterHub
|
||||
--------------------
|
||||
|
||||
We try to make upgrades between minor versions as painless as possible.
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
|
||||
admin/upgrading
|
||||
changelog
|
||||
|
||||
API Reference
|
||||
-------------
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
|
||||
api/index
|
||||
|
||||
Troubleshooting
|
||||
---------------
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
|
||||
troubleshooting
|
||||
contributing/index
|
||||
|
||||
About JupyterHub
|
||||
----------------
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
:maxdepth: 2
|
||||
|
||||
contributor-list
|
||||
changelog
|
||||
gallery-jhub-deployments
|
||||
index-about
|
||||
|
||||
Indices and tables
|
||||
==================
|
||||
@@ -168,24 +145,6 @@ Questions? Suggestions?
|
||||
- `Jupyter mailing list <https://groups.google.com/forum/#!forum/jupyter>`_
|
||||
- `Jupyter website <https://jupyter.org>`_
|
||||
|
||||
.. _contents:
|
||||
|
||||
Full Table of Contents
|
||||
======================
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
installation-guide
|
||||
getting-started/index
|
||||
reference/index
|
||||
api/index
|
||||
troubleshooting
|
||||
contributor-list
|
||||
gallery-jhub-deployments
|
||||
changelog
|
||||
|
||||
|
||||
.. _JupyterHub: https://github.com/jupyterhub/jupyterhub
|
||||
.. _Jupyter notebook: https://jupyter-notebook.readthedocs.io/en/latest/
|
||||
.. _REST API: http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyterhub/jupyterhub/master/docs/rest-api.yml#!/default
|
||||
|
338
docs/source/installation-guide-hard.md
Normal file
338
docs/source/installation-guide-hard.md
Normal file
@@ -0,0 +1,338 @@
|
||||
# Install JupyterHub and JupyterLab from the ground up
|
||||
|
||||
The combination of [JupyterHub](https://jupyterhub.readthedocs.io) and [JupyterLab](https://jupyterlab.readthedocs.io)
|
||||
is a great way to make shared computing resources available to a group.
|
||||
|
||||
These instructions are a guide for a manual, 'bare metal' install of [JupyterHub](https://jupyterhub.readthedocs.io)
|
||||
and [JupyterLab](https://jupyterlab.readthedocs.io). This is ideal for running on a single server: build a beast
|
||||
of a machine and share it within your lab, or use a virtual machine from any VPS or cloud provider.
|
||||
|
||||
This guide has similar goals to [The Littlest JupyterHub](https://the-littlest-jupyterhub.readthedocs.io) setup
|
||||
script. However, instead of bundling all these step for you into one installer, we will perform every step manually.
|
||||
This makes it easy to customize any part (e.g. if you want to run other services on the same system and need to make them
|
||||
work together), as well as giving you full control and understanding of your setup.
|
||||
|
||||
|
||||
## Prerequisites
|
||||
|
||||
Your own server with administrator (root) access. This could be a local machine, a remotely hosted one, or a cloud instance
|
||||
or VPS. Each user who will access JupyterHub should have a standard user account on the machine. The install will be done
|
||||
through the command line - useful if you log into your machine remotely using SSH.
|
||||
|
||||
This tutorial was tested on **Ubuntu 18.04**. No other Linux distributions have been tested, but the instructions
|
||||
should be reasonably straightforward to adapt.
|
||||
|
||||
|
||||
## Goals
|
||||
|
||||
JupyterLab enables access to a multiple 'kernels', each one being a given environment for a given language. The most
|
||||
common is a Python environment, for scientific computing usually one managed by the `conda` package manager.
|
||||
|
||||
This guide will set up JupyterHub and JupyterLab seperately from the Python environment. In other words, we treat
|
||||
JupyterHub+JupyterLab as a 'app' or webservice, which will connect to the kernels available on the system. Specifically:
|
||||
|
||||
- We will create an installation of JupyterHub and JupyterLab using a virtualenv under `/opt` using the system Python.
|
||||
|
||||
- We will install conda globally.
|
||||
|
||||
- We will create a shared conda environment which can be used (but not modified) by all users.
|
||||
|
||||
- We will show how users can create their own private conda environments, where they can install whatever they like.
|
||||
|
||||
|
||||
The default JupyterHub Authenticator uses PAM to authenticate system users with their username and password. One can
|
||||
[choose the authenticator](https://jupyterhub.readthedocs.io/en/stable/reference/authenticators.html#authenticators)
|
||||
that best suits their needs. In this guide we will use the default Authenticator because it makes it easy for everyone to manage data
|
||||
in their home folder and to mix and match different services and access methods (e.g. SSH) which all work using the
|
||||
Linux system user accounts. Therefore, each user of JupyterHub will need a standard system user account.
|
||||
|
||||
Another goal of this guide is to use system provided packages wherever possible. This has the advantage that these packages
|
||||
get automatic patches and security updates (be sure to turn on automatic updates in Ubuntu). This means less maintenance
|
||||
work and a more reliable system.
|
||||
|
||||
## Part 1: JupyterHub and JupyterLab
|
||||
|
||||
### Setup the JupyterHub and JupyterLab in a virtual environment
|
||||
|
||||
First we create a virtual environment under '/opt/jupyterhub'. The '/opt' folder is where apps not belonging to the operating
|
||||
system are [commonly installed](https://unix.stackexchange.com/questions/11544/what-is-the-difference-between-opt-and-usr-local).
|
||||
Both jupyterlab and jupyterhub will be installed into this virtualenv. Create it with the command:
|
||||
|
||||
```sh
|
||||
sudo python3 -m venv /opt/jupyterhub/
|
||||
```
|
||||
|
||||
Now we use pip to install the required Python packages into the new virtual environment. Be sure to install
|
||||
`wheel` first. Since we are separating the user interface from the computing kernels, we don't install
|
||||
any Python scientific packages here. The only exception is `ipywidgets` because this is needed to allow connection
|
||||
between interactive tools running in the kernel and the user interface.
|
||||
|
||||
Note that we use `/opt/jupyterhub/bin/python3 -m pip install` each time - this [makes sure](https://snarky.ca/why-you-should-use-python-m-pip/)
|
||||
that the packages are installed to the correct virtual environment.
|
||||
|
||||
Perform the install using the following commands:
|
||||
|
||||
```sh
|
||||
sudo /opt/jupyterhub/bin/python3 -m pip install wheel
|
||||
sudo /opt/jupyterhub/bin/python3 -m pip install jupyterhub jupyterlab
|
||||
sudo /opt/jupyterhub/bin/python3 -m pip install ipywidgets
|
||||
```
|
||||
|
||||
JupyterHub also currently defaults to requiring `configurable-http-proxy`, which needs `nodejs` and `npm`. The versions
|
||||
of these available in Ubuntu therefore need to be installed first (they are a bit old but this is ok for our needs):
|
||||
|
||||
```sh
|
||||
sudo apt install nodejs npm
|
||||
```
|
||||
|
||||
Then install `configurable-http-proxy`:
|
||||
|
||||
```sh
|
||||
npm install -g configurable-http-proxy
|
||||
```
|
||||
|
||||
### Create the configuration for JupyterHub
|
||||
|
||||
Now we start creating configuration files. To keep everything together, we put all the configuration into the folder
|
||||
created for the virtualenv, under `/opt/jupyterhub/etc/`. For each thing needing configuration, we will create a further
|
||||
subfolder and necessary files.
|
||||
|
||||
First create the folder for the JupyterHub configuration and navigate to it:
|
||||
|
||||
```sh
|
||||
sudo mkdir -p /opt/jupyterhub/etc/jupyterhub/
|
||||
cd /opt/jupyterhub/etc/jupyterhub/
|
||||
```
|
||||
Then generate the default configuration file
|
||||
|
||||
```sh
|
||||
sudo /opt/jupyterhub/bin/jupyterhub --generate-config
|
||||
```
|
||||
This will produce the default configuration file `/opt/jupyterhub/etc/jupyterhub/jupyterhub_config.py`
|
||||
|
||||
You will need to edit the configuration file to make the JupyterLab interface by the default.
|
||||
Set the following configuration option in your `jupyterhub_config.py` file:
|
||||
|
||||
```python
|
||||
c.Spawner.default_url = '/lab'
|
||||
```
|
||||
|
||||
Further configuration options may be found in the documentation.
|
||||
|
||||
### Setup Systemd service
|
||||
|
||||
We will setup JupyterHub to run as a system service using Systemd (which is responsible for managing all services and
|
||||
servers that run on startup in Ubuntu). We will create a service file in a suitable location in the virtualenv folder
|
||||
and then link it to the system services. First create the folder for the service file:
|
||||
|
||||
```sh
|
||||
sudo mkdir -p /opt/jupyterhub/etc/systemd
|
||||
```
|
||||
|
||||
Then create the following text file using your [favourite editor](https://micro-editor.github.io/) at
|
||||
```sh
|
||||
/opt/jupyterhub/etc/systemd/jupyterhub.service
|
||||
```
|
||||
|
||||
Paste the following service unit definition into the file:
|
||||
|
||||
```
|
||||
[Unit]
|
||||
Description=JupyterHub
|
||||
After=syslog.target network.target
|
||||
|
||||
[Service]
|
||||
User=root
|
||||
Environment="PATH=/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/opt/jupyterhub/bin"
|
||||
ExecStart=/opt/jupyterhub/bin/jupyterhub -f /opt/jupyterhub/etc/jupyterhub/jupyterhub_config.py
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
```
|
||||
|
||||
This sets up the environment to use the virtual environment we created, tells Systemd how to start jupyterhub using
|
||||
the configuration file we created, specifies that jupyterhub will be started as the `root` user (needed so that it can
|
||||
start jupyter on behalf of other logged in users), and specifies that jupyterhub should start on boot after the network
|
||||
is enabled.
|
||||
|
||||
Finally, we need to make systemd aware of our service file. First we symlink our file into systemd's directory:
|
||||
|
||||
```sh
|
||||
sudo ln -s /opt/jupyterhub/etc/systemd/jupyterhub.service /etc/systemd/system/jupyterhub.service
|
||||
```
|
||||
|
||||
Then tell systemd to reload its configuration files
|
||||
|
||||
```sh
|
||||
sudo systemctl daemon-reload
|
||||
```
|
||||
|
||||
And finally enable the service
|
||||
|
||||
```sh
|
||||
sudo systemctl enable jupyterhub.service
|
||||
```
|
||||
|
||||
The service will start on reboot, but we can start it straight away using:
|
||||
|
||||
```sh
|
||||
sudo systemctl start jupyterhub.service
|
||||
```
|
||||
|
||||
...and check that it's running using:
|
||||
|
||||
```sh
|
||||
sudo systemctl status jupyterhub.service
|
||||
```
|
||||
|
||||
You should now be already be able to access jupyterhub using `<your servers ip>:8000` (assuming you haven't already set
|
||||
up a firewall or something). However, when you log in the jupyter notebooks will be trying to use the Python virtualenv
|
||||
that was created to install JupyterHub, this is not what we want. So on to part 2
|
||||
|
||||
## Part 2: Conda environments
|
||||
|
||||
### Install conda for the whole system
|
||||
|
||||
We will use `conda` to manage Python environments. We will install the officially maintained `conda` packages for Ubuntu,
|
||||
this means they will get automatic updates with the rest of the system. Setup repo for the official Conda debian packages,
|
||||
instructions are copied from [here](https://docs.conda.io/projects/conda/en/latest/user-guide/install/rpm-debian.html):
|
||||
|
||||
Install Anacononda public gpg key to trusted store
|
||||
```sh
|
||||
curl https://repo.anaconda.com/pkgs/misc/gpgkeys/anaconda.asc | gpg --dearmor > conda.gpg
|
||||
sudo install -o root -g root -m 644 conda.gpg /etc/apt/trusted.gpg.d/
|
||||
```
|
||||
|
||||
Add Debian repo
|
||||
|
||||
```sh
|
||||
sudo echo "deb [arch=amd64] https://repo.anaconda.com/pkgs/misc/debrepo/conda stable main" > /etc/apt/sources.list.d/conda.list
|
||||
```
|
||||
|
||||
Install conda
|
||||
|
||||
```sh
|
||||
sudo apt update
|
||||
sudo apt install conda
|
||||
```
|
||||
|
||||
This will install conda into the folder `/opt/conda/`, with the conda command available at `/opt/conda/bin/conda`.
|
||||
|
||||
Finally, we can make conda more easily available to users by symlinking the conda shell setup script to the profile
|
||||
'drop in' folder so that it gets run on login
|
||||
|
||||
```sh
|
||||
sudo ln -s /opt/conda/etc/profile.d/conda.sh /etc/profile.d/conda.sh
|
||||
```
|
||||
|
||||
### Install a default conda environment for all users
|
||||
|
||||
First create a folder for conda envs (might exist already):
|
||||
```sh
|
||||
sudo mkdir /opt/conda/envs/
|
||||
```
|
||||
|
||||
Then create a conda environment to your liking within that folder. Here we have called it 'python' because it will
|
||||
be the obvious default - call it whatever you like. You can install whatever you like into this environment, but you MUST at least install `ipykernel`.
|
||||
|
||||
```sh
|
||||
sudo /opt/conda/bin/conda create --prefix /opt/conda/envs/python python=3.7 ipykernel
|
||||
```
|
||||
|
||||
Once your env is set up as desired, make it visible to Jupyter by installing the kernel spec. There are two options here:
|
||||
|
||||
1 ) Install into the JupyterHub virtualenv - this ensures it overrides the default python version. It will only be visible
|
||||
to the JupyterHub installation we have just created. This is useful to avoid conda environments appearing where they are not expected.
|
||||
|
||||
```sh
|
||||
sudo /opt/conda/envs/python/bin/python -m ipykernel install --prefix=/opt/jupyterhub/ --name 'python' --display-name "Python (default)"
|
||||
```
|
||||
|
||||
2 ) Install it system-wide by putting it into `/usr/local`. It will be visible to any parallel install of JupyterHub or
|
||||
JupyterLab, and will persist even if you later delete or modify the JupyterHub installation. This is useful if the kernels
|
||||
might be used by other services, or if you want to modify the JupyterHub installation independently from the conda environments.
|
||||
|
||||
```sh
|
||||
sudo /opt/conda/envs/python/bin/python -m ipykernel install --prefix /usr/local/ --name 'python' --display-name "Python (default)"
|
||||
````
|
||||
|
||||
### Setting up users' own conda environments
|
||||
|
||||
There is relatively little for the administrator to do here, as users will have to set up their own environments using the shell.
|
||||
On login they should run `conda init` or `/opt/conda/bin/conda`. The can then use conda to set up their environment,
|
||||
although they must also install `ipykernel`. Once done, they can enable their kernel using:
|
||||
|
||||
```sh
|
||||
/path/to/kernel/env/bin/python -m ipykernel install --name 'python-my-env' --display-name "Python My Env"
|
||||
```
|
||||
|
||||
This will place the kernel spec into their home folder, where Jupyter will look for it on startup.
|
||||
|
||||
|
||||
## Setting up a reverse proxy
|
||||
|
||||
The guide so far results in JupyterHub running on port 8000. It is not generally advisable to run open web services in
|
||||
this way - instead, use a reverse proxy running on standard HTTP/HTTPS ports.
|
||||
|
||||
> **Important**: Be aware of the security implications especially if you are running a server that is accessible from the open internet
|
||||
> i.e. not protected within an institutional intranet or private home/office network. You should set up a firewall and
|
||||
> HTTPS encryption, which is outside of the scope of this guide. For HTTPS consider using [LetsEncrypt](https://letsencrypt.org/)
|
||||
> or setting up a [self-signed certificate](https://www.digitalocean.com/community/tutorials/how-to-create-a-self-signed-ssl-certificate-for-nginx-in-ubuntu-18-04).
|
||||
> Firewalls may be set up using `ufs` or `firewalld` and combined with `fail2ban`.
|
||||
|
||||
### Using Nginx
|
||||
Nginx is a mature and established web server and reverse proxy and is easy to install using `sudo apt install nginx`.
|
||||
Details on using Nginx as a reverse proxy can be found elsewhere. Here, we will only outline the additional steps needed
|
||||
to setup JupyterHub with Nginx and host it at a given URL e.g. `<your-server-ip-or-url>/jupyter`.
|
||||
This could be useful for example if you are running several services or web pages on the same server.
|
||||
|
||||
To achieve this needs a few tweaks to both the JupyterHub configuration and the Nginx config. First, edit the
|
||||
configuration file `/opt/jupyterhub/etc/jupyterhub/jupyterhub_config.py` and add the line:
|
||||
|
||||
```python
|
||||
c.JupyterHub.bind_url = 'http://:8000/jupyter'
|
||||
```
|
||||
|
||||
where `/jupyter` will be the relative URL of the JupyterHub.
|
||||
|
||||
Now Nginx must be configured with a to pass all traffic from `/jupyter` to the the local address `127.0.0.1:8000`.
|
||||
Add the following snippet to your nginx configuration file (e.g. `/etc/nginx/sites-available/default`).
|
||||
|
||||
```
|
||||
location /jupyter/ {
|
||||
# NOTE important to also set base url of jupyterhub to /jupyter in its config
|
||||
proxy_pass http://127.0.0.1:8000;
|
||||
|
||||
proxy_redirect off;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
|
||||
# websocket headers
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection $connection_upgrade;
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
Nginx will not run if there are errors in the configuration, check your configuration using:
|
||||
|
||||
```sh
|
||||
nginx -t
|
||||
```
|
||||
|
||||
If there are no errors, you can restart the Nginx service for the new configuration to take effect.
|
||||
|
||||
```sh
|
||||
sudo systemctl restart nginx.service
|
||||
```
|
||||
|
||||
|
||||
## Getting started using your new JupyterHub
|
||||
|
||||
Once you have setup JupyterHub and Nginx proxy as described, you can browse to your JupyterHub IP or URL
|
||||
(e.g. if your server IP address is `123.456.789.1` and you decided to host JupyterHub at the `/jupyter` URL, browse
|
||||
to `123.456.789.1/jupyter`). You will find a login page where you enter your Linux username and password. On login
|
||||
you will be presented with the JupyterLab interface, with the file browser pane showing the contents of your users'
|
||||
home directory on the server.
|
@@ -1,5 +1,9 @@
|
||||
Installation Guide
|
||||
==================
|
||||
Installation
|
||||
============
|
||||
|
||||
These sections cover how to get up-and-running with JupyterHub. They cover
|
||||
some basics of the tools needed to deploy JupyterHub as well as how to get it
|
||||
running on your own infrastructure.
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 3
|
||||
@@ -7,3 +11,4 @@ Installation Guide
|
||||
quickstart
|
||||
quickstart-docker
|
||||
installation-basics
|
||||
installation-guide-hard
|
||||
|
@@ -17,10 +17,12 @@ satisfy the following:
|
||||
Let's start out with needed JupyterHub configuration in `jupyterhub_config.py`:
|
||||
|
||||
```python
|
||||
# Force the proxy to only listen to connections to 127.0.0.1
|
||||
c.JupyterHub.ip = '127.0.0.1'
|
||||
# Force the proxy to only listen to connections to 127.0.0.1 (on port 8000)
|
||||
c.JupyterHub.bind_url = 'http://127.0.0.1:8000'
|
||||
```
|
||||
|
||||
(For Jupyterhub < 0.9 use `c.JupyterHub.ip = '127.0.0.1'`.)
|
||||
|
||||
For high-quality SSL configuration, we also generate Diffie-Helman parameters.
|
||||
This can take a few minutes:
|
||||
|
||||
|
@@ -1,6 +1,9 @@
|
||||
Technical Reference
|
||||
===================
|
||||
|
||||
This section covers more of the details of the JupyterHub architecture, as well as
|
||||
what happens under-the-hood when you deploy and configure your JupyterHub.
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
@@ -15,6 +18,7 @@ Technical Reference
|
||||
rest
|
||||
database
|
||||
templates
|
||||
../events/index
|
||||
config-user-env
|
||||
config-examples
|
||||
config-ghoauth
|
||||
|
@@ -102,7 +102,7 @@ route to be proxied, such as `/user/name/`. A routespec will:
|
||||
### Adding a route
|
||||
|
||||
When adding a route, JupyterHub may pass a JSON-serializable dict as a `data`
|
||||
argument that should be attacked to the proxy route. When that route is
|
||||
argument that should be attached to the proxy route. When that route is
|
||||
retrieved, the `data` argument should be returned as well. If your proxy
|
||||
implementation doesn't support storing data attached to routes, then your
|
||||
Python wrapper may have to handle storing the `data` piece itself, e.g in a
|
||||
@@ -204,7 +204,7 @@ setup(
|
||||
```
|
||||
|
||||
If you have added this metadata to your package,
|
||||
users can select your authenticator with the configuration:
|
||||
users can select your proxy with the configuration:
|
||||
|
||||
```python
|
||||
c.JupyterHub.proxy_class = 'mything'
|
||||
|
@@ -249,7 +249,7 @@ prefix = os.environ.get('JUPYTERHUB_SERVICE_PREFIX', '/')
|
||||
|
||||
auth = HubAuth(
|
||||
api_token=os.environ['JUPYTERHUB_API_TOKEN'],
|
||||
cookie_cache_max_age=60,
|
||||
cache_max_age=60,
|
||||
)
|
||||
|
||||
app = Flask(__name__)
|
||||
|
@@ -25,6 +25,8 @@ Some examples include:
|
||||
run without being root, by spawning an intermediate process via `sudo`
|
||||
- [BatchSpawner](https://github.com/jupyterhub/batchspawner) for spawning remote
|
||||
servers using batch systems
|
||||
- [YarnSpawner](https://github.com/jupyterhub/yarnspawner) for spawning notebook
|
||||
servers in YARN containers on a Hadoop cluster
|
||||
- [RemoteSpawner](https://github.com/zonca/remotespawner) to spawn notebooks
|
||||
and a remote server and tunnel the port via SSH
|
||||
|
||||
@@ -72,7 +74,7 @@ It should return `None` if it is still running,
|
||||
and an integer exit status, otherwise.
|
||||
|
||||
For the local process case, `Spawner.poll` uses `os.kill(PID, 0)`
|
||||
to check if the local process is still running.
|
||||
to check if the local process is still running. On Windows, it uses `psutil.pid_exists`.
|
||||
|
||||
### Spawner.stop
|
||||
|
||||
@@ -193,7 +195,7 @@ setup(
|
||||
```
|
||||
|
||||
If you have added this metadata to your package,
|
||||
users can select your authenticator with the configuration:
|
||||
users can select your spawner with the configuration:
|
||||
|
||||
```python
|
||||
c.JupyterHub.spawner_class = 'myservice'
|
||||
|
@@ -70,7 +70,7 @@ To add announcements to be displayed on a page, you have two options:
|
||||
### Announcement Configuration Variables
|
||||
|
||||
If you set the configuration variable `JupyterHub.template_vars =
|
||||
{'announcement': 'some_text}`, the given `some_text` will be placed on
|
||||
{'announcement': 'some_text'}`, the given `some_text` will be placed on
|
||||
the top of all pages. The more specific variables
|
||||
`announcement_login`, `announcement_spawn`, `announcement_home`, and
|
||||
`announcement_logout` are more specific and only show on their
|
||||
|
@@ -76,7 +76,7 @@ resolves the cross-site issues.
|
||||
|
||||
### Disable user config
|
||||
|
||||
If subdomains are not available or not desirable, JupyterHub provides a a
|
||||
If subdomains are not available or not desirable, JupyterHub provides a
|
||||
configuration option `Spawner.disable_user_config`, which can be set to prevent
|
||||
the user-owned configuration files from being loaded. After implementing this
|
||||
option, PATHs and package installation and PATHs are the other things that the
|
||||
@@ -127,3 +127,11 @@ A handy website for testing your deployment is
|
||||
|
||||
|
||||
[configurable-http-proxy]: https://github.com/jupyterhub/configurable-http-proxy
|
||||
|
||||
## Vulnerability reporting
|
||||
|
||||
If you believe you’ve found a security vulnerability in JupyterHub, or any
|
||||
Jupyter project, please report it to
|
||||
[security@ipython.org](mailto:security@iypthon.org). If you prefer to encrypt
|
||||
your security reports, you can use [this PGP public
|
||||
key](https://jupyter-notebook.readthedocs.io/en/stable/_downloads/ipython_security.asc).
|
||||
|
@@ -1,56 +0,0 @@
|
||||
"""autodoc extension for configurable traits"""
|
||||
from sphinx.domains.python import PyClassmember
|
||||
from sphinx.ext.autodoc import AttributeDocumenter
|
||||
from sphinx.ext.autodoc import ClassDocumenter
|
||||
from traitlets import TraitType
|
||||
from traitlets import Undefined
|
||||
|
||||
|
||||
class ConfigurableDocumenter(ClassDocumenter):
|
||||
"""Specialized Documenter subclass for traits with config=True"""
|
||||
|
||||
objtype = 'configurable'
|
||||
directivetype = 'class'
|
||||
|
||||
def get_object_members(self, want_all):
|
||||
"""Add traits with .tag(config=True) to members list"""
|
||||
check, members = super().get_object_members(want_all)
|
||||
get_traits = (
|
||||
self.object.class_own_traits
|
||||
if self.options.inherited_members
|
||||
else self.object.class_traits
|
||||
)
|
||||
trait_members = []
|
||||
for name, trait in sorted(get_traits(config=True).items()):
|
||||
# put help in __doc__ where autodoc will look for it
|
||||
trait.__doc__ = trait.help
|
||||
trait_members.append((name, trait))
|
||||
return check, trait_members + members
|
||||
|
||||
|
||||
class TraitDocumenter(AttributeDocumenter):
|
||||
objtype = 'trait'
|
||||
directivetype = 'attribute'
|
||||
member_order = 1
|
||||
priority = 100
|
||||
|
||||
@classmethod
|
||||
def can_document_member(cls, member, membername, isattr, parent):
|
||||
return isinstance(member, TraitType)
|
||||
|
||||
def format_name(self):
|
||||
return 'config c.' + super().format_name()
|
||||
|
||||
def add_directive_header(self, sig):
|
||||
default = self.object.get_default_value()
|
||||
if default is Undefined:
|
||||
default_s = ''
|
||||
else:
|
||||
default_s = repr(default)
|
||||
sig = ' = {}({})'.format(self.object.__class__.__name__, default_s)
|
||||
return super().add_directive_header(sig)
|
||||
|
||||
|
||||
def setup(app):
|
||||
app.add_autodocumenter(ConfigurableDocumenter)
|
||||
app.add_autodocumenter(TraitDocumenter)
|
@@ -117,9 +117,11 @@ def cull_idle(
|
||||
futures = []
|
||||
|
||||
@coroutine
|
||||
def handle_server(user, server_name, server):
|
||||
def handle_server(user, server_name, server, max_age, inactive_limit):
|
||||
"""Handle (maybe) culling a single server
|
||||
|
||||
"server" is the entire server model from the API.
|
||||
|
||||
Returns True if server is now stopped (user removable),
|
||||
False otherwise.
|
||||
"""
|
||||
@@ -162,6 +164,20 @@ def cull_idle(
|
||||
# for running servers
|
||||
inactive = age
|
||||
|
||||
# CUSTOM CULLING TEST CODE HERE
|
||||
# Add in additional server tests here. Return False to mean "don't
|
||||
# cull", True means "cull immediately", or, for example, update some
|
||||
# other variables like inactive_limit.
|
||||
#
|
||||
# Here, server['state'] is the result of the get_state method
|
||||
# on the spawner. This does *not* contain the below by
|
||||
# default, you may have to modify your spawner to make this
|
||||
# work. The `user` variable is the user model from the API.
|
||||
#
|
||||
# if server['state']['profile_name'] == 'unlimited'
|
||||
# return False
|
||||
# inactive_limit = server['state']['culltime']
|
||||
|
||||
should_cull = (
|
||||
inactive is not None and inactive.total_seconds() >= inactive_limit
|
||||
)
|
||||
@@ -236,7 +252,7 @@ def cull_idle(
|
||||
'url': user['server'],
|
||||
}
|
||||
server_futures = [
|
||||
handle_server(user, server_name, server)
|
||||
handle_server(user, server_name, server, max_age, inactive_limit)
|
||||
for server_name, server in servers.items()
|
||||
]
|
||||
results = yield multi(server_futures)
|
||||
|
@@ -10,10 +10,15 @@ class DemoFormSpawner(LocalProcessSpawner):
|
||||
def _options_form_default(self):
|
||||
default_env = "YOURNAME=%s\n" % self.user.name
|
||||
return """
|
||||
<label for="args">Extra notebook CLI arguments</label>
|
||||
<input name="args" placeholder="e.g. --debug"></input>
|
||||
<label for="env">Environment variables (one per line)</label>
|
||||
<textarea name="env">{env}</textarea>
|
||||
<div class="form-group">
|
||||
<label for="args">Extra notebook CLI arguments</label>
|
||||
<input name="args" class="form-control"
|
||||
placeholder="e.g. --debug"></input>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="env">Environment variables (one per line)</label>
|
||||
<textarea class="form-control" name="env">{env}</textarea>
|
||||
</div>
|
||||
""".format(
|
||||
env=default_env
|
||||
)
|
||||
|
@@ -3,11 +3,11 @@
|
||||
# Distributed under the terms of the Modified BSD License.
|
||||
|
||||
version_info = (
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
"b2", # release (b1, rc1, or "" for final or dev)
|
||||
# "dev", # dev or nothing
|
||||
# "", # release (b1, rc1, or "" for final or dev)
|
||||
# "dev", # dev or nothing for beta/rc/stable releases
|
||||
)
|
||||
|
||||
# pep 440 version: no dot before beta/rc, but before .dev
|
||||
|
@@ -28,7 +28,7 @@ if 'jupyterhub' in sys.modules:
|
||||
alembic_logger.propagate = True
|
||||
alembic_logger.parent = app.log
|
||||
else:
|
||||
fileConfig(config.config_file_name)
|
||||
fileConfig(config.config_file_name, disable_existing_loggers=False)
|
||||
else:
|
||||
fileConfig(config.config_file_name)
|
||||
|
||||
|
@@ -198,14 +198,39 @@ class OAuthAuthorizeHandler(OAuthHandler, BaseHandler):
|
||||
raise
|
||||
self.send_oauth_response(headers, body, status)
|
||||
|
||||
def needs_oauth_confirm(self, user, oauth_client):
|
||||
"""Return whether the given oauth client needs to prompt for access for the given user
|
||||
|
||||
Checks whitelist for oauth clients
|
||||
|
||||
(i.e. the user's own server)
|
||||
|
||||
.. versionadded: 1.1
|
||||
"""
|
||||
# get the oauth client ids for the user's own server(s)
|
||||
own_oauth_client_ids = set(
|
||||
spawner.oauth_client_id for spawner in user.spawners.values()
|
||||
)
|
||||
if (
|
||||
# it's the user's own server
|
||||
oauth_client.identifier in own_oauth_client_ids
|
||||
# or it's in the global whitelist
|
||||
or oauth_client.identifier
|
||||
in self.settings.get('oauth_no_confirm_whitelist', set())
|
||||
):
|
||||
return False
|
||||
# default: require confirmation
|
||||
return True
|
||||
|
||||
@web.authenticated
|
||||
def get(self):
|
||||
async def get(self):
|
||||
"""GET /oauth/authorization
|
||||
|
||||
Render oauth confirmation page:
|
||||
"Server at ... would like permission to ...".
|
||||
|
||||
Users accessing their own server will skip confirmation.
|
||||
Users accessing their own server or a service whitelist
|
||||
will skip confirmation.
|
||||
"""
|
||||
|
||||
uri, http_method, body, headers = self.extract_oauth_params()
|
||||
@@ -215,20 +240,25 @@ class OAuthAuthorizeHandler(OAuthHandler, BaseHandler):
|
||||
)
|
||||
credentials = self.add_credentials(credentials)
|
||||
client = self.oauth_provider.fetch_by_client_id(credentials['client_id'])
|
||||
if client.redirect_uri.startswith(self.current_user.url):
|
||||
if not self.needs_oauth_confirm(self.current_user, client):
|
||||
self.log.debug(
|
||||
"Skipping oauth confirmation for %s accessing %s",
|
||||
self.current_user,
|
||||
client.description,
|
||||
)
|
||||
# access to my own server doesn't require oauth confirmation
|
||||
# this is the pre-1.0 behavior for all oauth
|
||||
self._complete_login(uri, headers, scopes, credentials)
|
||||
return
|
||||
|
||||
# Render oauth 'Authorize application...' page
|
||||
auth_state = await self.current_user.get_auth_state()
|
||||
self.write(
|
||||
self.render_template("oauth.html", scopes=scopes, oauth_client=client)
|
||||
self.render_template(
|
||||
"oauth.html",
|
||||
auth_state=auth_state,
|
||||
scopes=scopes,
|
||||
oauth_client=client,
|
||||
)
|
||||
)
|
||||
|
||||
# Errors that should be shown to the user on the provider website
|
||||
|
@@ -141,6 +141,7 @@ class APIHandler(BaseHandler):
|
||||
'ready': spawner.ready,
|
||||
'state': spawner.get_state() if include_state else None,
|
||||
'url': url_path_join(spawner.user.url, spawner.name, '/'),
|
||||
'user_options': spawner.user_options,
|
||||
'progress_url': spawner._progress_url,
|
||||
}
|
||||
|
||||
|
@@ -589,11 +589,14 @@ class SpawnProgressAPIHandler(APIHandler):
|
||||
async with aclosing(
|
||||
iterate_until(spawn_future, spawner._generate_progress())
|
||||
) as events:
|
||||
async for event in events:
|
||||
# don't allow events to sneakily set the 'ready' flag
|
||||
if 'ready' in event:
|
||||
event.pop('ready', None)
|
||||
await self.send_event(event)
|
||||
try:
|
||||
async for event in events:
|
||||
# don't allow events to sneakily set the 'ready' flag
|
||||
if 'ready' in event:
|
||||
event.pop('ready', None)
|
||||
await self.send_event(event)
|
||||
except asyncio.CancelledError:
|
||||
pass
|
||||
|
||||
# progress finished, wait for spawn to actually resolve,
|
||||
# in case progress finished early
|
||||
|
@@ -5,17 +5,21 @@
|
||||
import asyncio
|
||||
import atexit
|
||||
import binascii
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
import signal
|
||||
import socket
|
||||
import sys
|
||||
import time
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
from datetime import datetime
|
||||
from datetime import timedelta
|
||||
from datetime import timezone
|
||||
from functools import partial
|
||||
from getpass import getuser
|
||||
from glob import glob
|
||||
from operator import itemgetter
|
||||
from textwrap import dedent
|
||||
from urllib.parse import unquote
|
||||
@@ -36,7 +40,6 @@ from tornado.ioloop import IOLoop, PeriodicCallback
|
||||
from tornado.log import app_log, access_log, gen_log
|
||||
import tornado.options
|
||||
from tornado import gen, web
|
||||
from tornado.platform.asyncio import AsyncIOMainLoop
|
||||
|
||||
from traitlets import (
|
||||
Unicode,
|
||||
@@ -54,9 +57,12 @@ from traitlets import (
|
||||
Float,
|
||||
observe,
|
||||
default,
|
||||
validate,
|
||||
)
|
||||
from traitlets.config import Application, Configurable, catch_config_error
|
||||
|
||||
from jupyter_telemetry.eventlog import EventLog
|
||||
|
||||
here = os.path.dirname(__file__)
|
||||
|
||||
import jupyterhub
|
||||
@@ -71,7 +77,7 @@ from .oauth.provider import make_provider
|
||||
from ._data import DATA_FILES_PATH
|
||||
from .log import CoroutineLogFormatter, log_request
|
||||
from .proxy import Proxy, ConfigurableHTTPProxy
|
||||
from .traitlets import URLPrefix, Command, EntryPointType
|
||||
from .traitlets import URLPrefix, Command, EntryPointType, Callable
|
||||
from .utils import (
|
||||
maybe_future,
|
||||
url_path_join,
|
||||
@@ -79,6 +85,10 @@ from .utils import (
|
||||
print_ps_info,
|
||||
make_ssl_context,
|
||||
)
|
||||
from .metrics import HUB_STARTUP_DURATION_SECONDS
|
||||
from .metrics import INIT_SPAWNERS_DURATION_SECONDS
|
||||
from .metrics import RUNNING_SERVERS
|
||||
from .metrics import TOTAL_USERS
|
||||
|
||||
# classes for config
|
||||
from .auth import Authenticator, PAMAuthenticator
|
||||
@@ -145,8 +155,8 @@ flags = {
|
||||
}
|
||||
|
||||
COOKIE_SECRET_BYTES = (
|
||||
32
|
||||
) # the number of bytes to use when generating new cookie secrets
|
||||
32 # the number of bytes to use when generating new cookie secrets
|
||||
)
|
||||
|
||||
HEX_RE = re.compile('^([a-f0-9]{2})+$', re.IGNORECASE)
|
||||
|
||||
@@ -277,7 +287,7 @@ class JupyterHub(Application):
|
||||
try:
|
||||
cls = entry_point.load()
|
||||
except Exception as e:
|
||||
self.log.warning(
|
||||
self.log.debug(
|
||||
"Failed to load %s entrypoint %r: %r",
|
||||
trait.entry_point_group,
|
||||
key,
|
||||
@@ -303,6 +313,19 @@ class JupyterHub(Application):
|
||||
config_file = Unicode('jupyterhub_config.py', help="The config file to load").tag(
|
||||
config=True
|
||||
)
|
||||
|
||||
@validate("config_file")
|
||||
def _validate_config_file(self, proposal):
|
||||
if not os.path.isfile(proposal.value):
|
||||
print(
|
||||
"ERROR: Failed to find specified config file: {}".format(
|
||||
proposal.value
|
||||
),
|
||||
file=sys.stderr,
|
||||
)
|
||||
sys.exit(1)
|
||||
return proposal.value
|
||||
|
||||
generate_config = Bool(False, help="Generate default config file").tag(config=True)
|
||||
generate_certs = Bool(False, help="Generate certs used for internal ssl").tag(
|
||||
config=True
|
||||
@@ -325,6 +348,18 @@ class JupyterHub(Application):
|
||||
redirect_to_server = Bool(
|
||||
True, help="Redirect user to server (if running), instead of control panel."
|
||||
).tag(config=True)
|
||||
activity_resolution = Integer(
|
||||
30,
|
||||
help="""
|
||||
Resolution (in seconds) for updating activity
|
||||
|
||||
If activity is registered that is less than activity_resolution seconds
|
||||
more recent than the current value,
|
||||
the new value will be ignored.
|
||||
|
||||
This avoids too many writes to the Hub database.
|
||||
""",
|
||||
).tag(config=True)
|
||||
last_activity_interval = Integer(
|
||||
300, help="Interval (in seconds) at which to update last-activity timestamps."
|
||||
).tag(config=True)
|
||||
@@ -578,7 +613,9 @@ class JupyterHub(Application):
|
||||
|
||||
@default('logo_file')
|
||||
def _logo_file_default(self):
|
||||
return os.path.join(self.data_files_path, 'static', 'images', 'jupyter.png')
|
||||
return os.path.join(
|
||||
self.data_files_path, 'static', 'images', 'jupyterhub-80.png'
|
||||
)
|
||||
|
||||
jinja_environment_options = Dict(
|
||||
help="Supply extra arguments that will be passed to Jinja environment."
|
||||
@@ -795,14 +832,14 @@ class JupyterHub(Application):
|
||||
|
||||
api_tokens = Dict(
|
||||
Unicode(),
|
||||
help="""PENDING DEPRECATION: consider using service_tokens
|
||||
help="""PENDING DEPRECATION: consider using services
|
||||
|
||||
Dict of token:username to be loaded into the database.
|
||||
|
||||
Allows ahead-of-time generation of API tokens for use by externally managed services,
|
||||
which authenticate as JupyterHub users.
|
||||
|
||||
Consider using service_tokens for general services that talk to the JupyterHub API.
|
||||
Consider using services for general services that talk to the JupyterHub API.
|
||||
""",
|
||||
).tag(config=True)
|
||||
|
||||
@@ -895,6 +932,22 @@ class JupyterHub(Application):
|
||||
""",
|
||||
).tag(config=True)
|
||||
|
||||
default_server_name = Unicode(
|
||||
"",
|
||||
help="If named servers are enabled, default name of server to spawn or open, e.g. by user-redirect.",
|
||||
).tag(config=True)
|
||||
# Ensure that default_server_name doesn't do anything if named servers aren't allowed
|
||||
_default_server_name = Unicode(
|
||||
help="Non-configurable version exposed to JupyterHub."
|
||||
)
|
||||
|
||||
@default('_default_server_name')
|
||||
def _set_default_server_name(self):
|
||||
if self.allow_named_servers:
|
||||
return self.default_server_name
|
||||
else:
|
||||
return ""
|
||||
|
||||
# class for spawning single-user servers
|
||||
spawner_class = EntryPointType(
|
||||
default_value=LocalProcessSpawner,
|
||||
@@ -968,6 +1021,28 @@ class JupyterHub(Application):
|
||||
""",
|
||||
).tag(config=True)
|
||||
|
||||
init_spawners_timeout = Integer(
|
||||
10,
|
||||
help="""
|
||||
Timeout (in seconds) to wait for spawners to initialize
|
||||
|
||||
Checking if spawners are healthy can take a long time
|
||||
if many spawners are active at hub start time.
|
||||
|
||||
If it takes longer than this timeout to check,
|
||||
init_spawner will be left to complete in the background
|
||||
and the http server is allowed to start.
|
||||
|
||||
A timeout of -1 means wait forever,
|
||||
which can mean a slow startup of the Hub
|
||||
but ensures that the Hub is fully consistent by the time it starts responding to requests.
|
||||
This matches the behavior of jupyterhub 1.0.
|
||||
|
||||
.. versionadded: 1.1.0
|
||||
|
||||
""",
|
||||
).tag(config=True)
|
||||
|
||||
db_url = Unicode(
|
||||
'sqlite:///jupyterhub.sqlite',
|
||||
help="url for the database. e.g. `sqlite:///jupyterhub.sqlite`",
|
||||
@@ -1199,6 +1274,23 @@ class JupyterHub(Application):
|
||||
"""
|
||||
).tag(config=True)
|
||||
|
||||
user_redirect_hook = Callable(
|
||||
None,
|
||||
allow_none=True,
|
||||
help="""
|
||||
Callable to affect behavior of /user-redirect/
|
||||
|
||||
Receives 4 parameters:
|
||||
1. path - URL path that was provided after /user-redirect/
|
||||
2. request - A Tornado HTTPServerRequest representing the current request.
|
||||
3. user - The currently authenticated user.
|
||||
4. base_url - The base_url of the current hub, for relative redirects
|
||||
|
||||
It should return the new URL to redirect to, or None to preserve
|
||||
current behavior.
|
||||
""",
|
||||
).tag(config=True)
|
||||
|
||||
def init_handlers(self):
|
||||
h = []
|
||||
# load handlers from the authenticator
|
||||
@@ -1657,6 +1749,12 @@ class JupyterHub(Application):
|
||||
raise ValueError("Token name %r is not in whitelist" % name)
|
||||
if not self.authenticator.validate_username(name):
|
||||
raise ValueError("Token name %r is not valid" % name)
|
||||
if kind == 'service':
|
||||
if not any(service["name"] == name for service in self.services):
|
||||
self.log.warning(
|
||||
"Warning: service '%s' not in services, creating implicitly. It is recommended to register services using services list."
|
||||
% name
|
||||
)
|
||||
orm_token = orm.APIToken.find(db, token)
|
||||
if orm_token is None:
|
||||
obj = Class.find(db, name)
|
||||
@@ -1813,6 +1911,7 @@ class JupyterHub(Application):
|
||||
)
|
||||
|
||||
async def init_spawners(self):
|
||||
self.log.debug("Initializing spawners")
|
||||
db = self.db
|
||||
|
||||
def _user_summary(user):
|
||||
@@ -1903,6 +2002,8 @@ class JupyterHub(Application):
|
||||
else:
|
||||
self.log.debug("%s not running", spawner._log_name)
|
||||
|
||||
spawner._check_pending = False
|
||||
|
||||
# parallelize checks for running Spawners
|
||||
check_futures = []
|
||||
for orm_user in db.query(orm.User):
|
||||
@@ -1913,11 +2014,22 @@ class JupyterHub(Application):
|
||||
# spawner should be running
|
||||
# instantiate Spawner wrapper and check if it's still alive
|
||||
spawner = user.spawners[name]
|
||||
# signal that check is pending to avoid race conditions
|
||||
spawner._check_pending = True
|
||||
f = asyncio.ensure_future(check_spawner(user, name, spawner))
|
||||
check_futures.append(f)
|
||||
|
||||
TOTAL_USERS.set(len(self.users))
|
||||
|
||||
# it's important that we get here before the first await
|
||||
# so that we know all spawners are instantiated and in the check-pending state
|
||||
|
||||
# await checks after submitting them all
|
||||
await gen.multi(check_futures)
|
||||
if check_futures:
|
||||
self.log.debug(
|
||||
"Awaiting checks for %i possibly-running spawners", len(check_futures)
|
||||
)
|
||||
await gen.multi(check_futures)
|
||||
db.commit()
|
||||
|
||||
# only perform this query if we are going to log it
|
||||
@@ -1925,6 +2037,10 @@ class JupyterHub(Application):
|
||||
user_summaries = map(_user_summary, self.users.values())
|
||||
self.log.debug("Loaded users:\n%s", '\n'.join(user_summaries))
|
||||
|
||||
active_counts = self.users.count_active_users()
|
||||
RUNNING_SERVERS.set(active_counts['active'])
|
||||
return len(check_futures)
|
||||
|
||||
def init_oauth(self):
|
||||
base_url = self.hub.base_url
|
||||
self.oauth_provider = make_provider(
|
||||
@@ -2004,6 +2120,15 @@ class JupyterHub(Application):
|
||||
else:
|
||||
version_hash = datetime.now().strftime("%Y%m%d%H%M%S")
|
||||
|
||||
oauth_no_confirm_whitelist = set()
|
||||
for service in self._service_map.values():
|
||||
if service.oauth_no_confirm:
|
||||
self.log.warning(
|
||||
"Allowing service %s to complete OAuth without confirmation on an authorization web page",
|
||||
service.name,
|
||||
)
|
||||
oauth_no_confirm_whitelist.add(service.oauth_client_id)
|
||||
|
||||
settings = dict(
|
||||
log_function=log_request,
|
||||
config=self.config,
|
||||
@@ -2011,6 +2136,7 @@ class JupyterHub(Application):
|
||||
db=self.db,
|
||||
proxy=self.proxy,
|
||||
hub=self.hub,
|
||||
activity_resolution=self.activity_resolution,
|
||||
admin_users=self.authenticator.admin_users,
|
||||
admin_access=self.admin_access,
|
||||
authenticator=self.authenticator,
|
||||
@@ -2033,8 +2159,10 @@ class JupyterHub(Application):
|
||||
domain=self.domain,
|
||||
statsd=self.statsd,
|
||||
allow_named_servers=self.allow_named_servers,
|
||||
default_server_name=self._default_server_name,
|
||||
named_server_limit_per_user=self.named_server_limit_per_user,
|
||||
oauth_provider=self.oauth_provider,
|
||||
oauth_no_confirm_whitelist=oauth_no_confirm_whitelist,
|
||||
concurrent_spawn_limit=self.concurrent_spawn_limit,
|
||||
spawn_throttle_retry_range=self.spawn_throttle_retry_range,
|
||||
active_server_limit=self.active_server_limit,
|
||||
@@ -2048,6 +2176,8 @@ class JupyterHub(Application):
|
||||
internal_ssl_ca=self.internal_ssl_ca,
|
||||
trusted_alt_names=self.trusted_alt_names,
|
||||
shutdown_on_logout=self.shutdown_on_logout,
|
||||
eventlog=self.eventlog,
|
||||
app=self,
|
||||
)
|
||||
# allow configured settings to have priority
|
||||
settings.update(self.tornado_settings)
|
||||
@@ -2073,6 +2203,16 @@ class JupyterHub(Application):
|
||||
e,
|
||||
)
|
||||
|
||||
def init_eventlog(self):
|
||||
"""Set up the event logging system."""
|
||||
self.eventlog = EventLog(parent=self)
|
||||
|
||||
for dirname, _, files in os.walk(os.path.join(here, 'event-schemas')):
|
||||
for file in files:
|
||||
if not file.endswith('.yaml'):
|
||||
continue
|
||||
self.eventlog.register_schema_file(os.path.join(dirname, file))
|
||||
|
||||
def write_pid_file(self):
|
||||
pid = os.getpid()
|
||||
if self.pid_file:
|
||||
@@ -2082,11 +2222,22 @@ class JupyterHub(Application):
|
||||
|
||||
@catch_config_error
|
||||
async def initialize(self, *args, **kwargs):
|
||||
hub_startup_start_time = time.perf_counter()
|
||||
super().initialize(*args, **kwargs)
|
||||
if self.generate_config or self.generate_certs or self.subapp:
|
||||
return
|
||||
self._start_future = asyncio.Future()
|
||||
|
||||
def record_start(f):
|
||||
startup_time = time.perf_counter() - hub_startup_start_time
|
||||
self.log.debug("It took %.3f seconds for the Hub to start", startup_time)
|
||||
HUB_STARTUP_DURATION_SECONDS.observe(startup_time)
|
||||
|
||||
self._start_future.add_done_callback(record_start)
|
||||
|
||||
self.load_config_file(self.config_file)
|
||||
self.init_logging()
|
||||
self.log.info("Running JupyterHub version %s", jupyterhub.__version__)
|
||||
if 'JupyterHubApp' in self.config:
|
||||
self.log.warning(
|
||||
"Use JupyterHub in config, not JupyterHubApp. Outdated config:\n%s",
|
||||
@@ -2122,7 +2273,9 @@ class JupyterHub(Application):
|
||||
|
||||
_log_cls("Authenticator", self.authenticator_class)
|
||||
_log_cls("Spawner", self.spawner_class)
|
||||
_log_cls("Proxy", self.proxy_class)
|
||||
|
||||
self.init_eventlog()
|
||||
self.init_pycurl()
|
||||
self.init_secrets()
|
||||
self.init_internal_ssl()
|
||||
@@ -2135,11 +2288,63 @@ class JupyterHub(Application):
|
||||
self.init_services()
|
||||
await self.init_api_tokens()
|
||||
self.init_tornado_settings()
|
||||
await self.init_spawners()
|
||||
self.cleanup_oauth_clients()
|
||||
self.init_handlers()
|
||||
self.init_tornado_application()
|
||||
|
||||
# init_spawners can take a while
|
||||
init_spawners_timeout = self.init_spawners_timeout
|
||||
if init_spawners_timeout < 0:
|
||||
# negative timeout means forever (previous, most stable behavior)
|
||||
init_spawners_timeout = 86400
|
||||
print(init_spawners_timeout)
|
||||
|
||||
init_start_time = time.perf_counter()
|
||||
init_spawners_future = asyncio.ensure_future(self.init_spawners())
|
||||
|
||||
def log_init_time(f):
|
||||
n_spawners = f.result()
|
||||
spawner_initialization_time = time.perf_counter() - init_start_time
|
||||
INIT_SPAWNERS_DURATION_SECONDS.observe(spawner_initialization_time)
|
||||
self.log.info(
|
||||
"Initialized %i spawners in %.3f seconds",
|
||||
n_spawners,
|
||||
spawner_initialization_time,
|
||||
)
|
||||
|
||||
init_spawners_future.add_done_callback(log_init_time)
|
||||
|
||||
try:
|
||||
|
||||
# don't allow a zero timeout because we still need to be sure
|
||||
# that the Spawner objects are defined and pending
|
||||
await gen.with_timeout(
|
||||
timedelta(seconds=max(init_spawners_timeout, 1)), init_spawners_future
|
||||
)
|
||||
except gen.TimeoutError:
|
||||
self.log.warning(
|
||||
"init_spawners did not complete within %i seconds. "
|
||||
"Allowing to complete in the background.",
|
||||
self.init_spawners_timeout,
|
||||
)
|
||||
|
||||
if init_spawners_future.done():
|
||||
self.cleanup_oauth_clients()
|
||||
else:
|
||||
# schedule async operations after init_spawners finishes
|
||||
async def finish_init_spawners():
|
||||
await init_spawners_future
|
||||
# schedule cleanup after spawners are all set up
|
||||
# because it relies on the state resolved by init_spawners
|
||||
self.cleanup_oauth_clients()
|
||||
# trigger a proxy check as soon as all spawners are ready
|
||||
# because this may be *after* the check made as part of normal startup.
|
||||
# To avoid races with partially-complete start,
|
||||
# ensure that start is complete before running this check.
|
||||
await self._start_future
|
||||
await self.proxy.check_routes(self.users, self._service_map)
|
||||
|
||||
asyncio.ensure_future(finish_init_spawners())
|
||||
|
||||
async def cleanup(self):
|
||||
"""Shutdown managed services and various subprocesses. Cleanup runtime files."""
|
||||
|
||||
@@ -2184,7 +2389,6 @@ class JupyterHub(Application):
|
||||
self.log.info("Cleaning up PID file %s", self.pid_file)
|
||||
os.remove(self.pid_file)
|
||||
|
||||
# finally stop the loop once we are all cleaned up
|
||||
self.log.info("...done")
|
||||
|
||||
def write_config_file(self):
|
||||
@@ -2290,7 +2494,7 @@ class JupyterHub(Application):
|
||||
if self.generate_certs:
|
||||
self.load_config_file(self.config_file)
|
||||
if not self.internal_ssl:
|
||||
self.log.warn(
|
||||
self.log.warning(
|
||||
"You'll need to enable `internal_ssl` "
|
||||
"in the `jupyterhub_config` file to use "
|
||||
"these certs."
|
||||
@@ -2305,6 +2509,20 @@ class JupyterHub(Application):
|
||||
loop.stop()
|
||||
return
|
||||
|
||||
# start the proxy
|
||||
if self.proxy.should_start:
|
||||
try:
|
||||
await self.proxy.start()
|
||||
except Exception as e:
|
||||
self.log.critical("Failed to start proxy", exc_info=True)
|
||||
self.exit(1)
|
||||
else:
|
||||
self.log.info("Not starting proxy")
|
||||
|
||||
# verify that we can talk to the proxy before listening.
|
||||
# avoids delayed failure if we can't talk to the proxy
|
||||
await self.proxy.get_all_routes()
|
||||
|
||||
ssl_context = make_ssl_context(
|
||||
self.internal_ssl_key,
|
||||
self.internal_ssl_cert,
|
||||
@@ -2342,16 +2560,6 @@ class JupyterHub(Application):
|
||||
self.log.error("Failed to bind hub to %s", self.hub.bind_url)
|
||||
raise
|
||||
|
||||
# start the proxy
|
||||
if self.proxy.should_start:
|
||||
try:
|
||||
await self.proxy.start()
|
||||
except Exception as e:
|
||||
self.log.critical("Failed to start proxy", exc_info=True)
|
||||
self.exit(1)
|
||||
else:
|
||||
self.log.info("Not starting proxy")
|
||||
|
||||
# start the service(s)
|
||||
for service_name, service in self._service_map.items():
|
||||
msg = (
|
||||
@@ -2421,23 +2629,40 @@ class JupyterHub(Application):
|
||||
pc.start()
|
||||
|
||||
self.log.info("JupyterHub is now running at %s", self.proxy.public_url)
|
||||
# Use atexit for Windows, it doesn't have signal handling support
|
||||
if _mswindows:
|
||||
atexit.register(self.atexit)
|
||||
# register cleanup on both TERM and INT
|
||||
atexit.register(self.atexit)
|
||||
self.init_signal()
|
||||
self._start_future.set_result(None)
|
||||
|
||||
def init_signal(self):
|
||||
signal.signal(signal.SIGTERM, self.sigterm)
|
||||
if hasattr(signal, 'SIGINFO'):
|
||||
signal.signal(signal.SIGINFO, self.log_status)
|
||||
loop = asyncio.get_event_loop()
|
||||
for s in (signal.SIGTERM, signal.SIGINT):
|
||||
if not _mswindows:
|
||||
loop.add_signal_handler(
|
||||
s, lambda s=s: asyncio.ensure_future(self.shutdown_cancel_tasks(s))
|
||||
)
|
||||
else:
|
||||
signal.signal(s, self.win_shutdown_cancel_tasks)
|
||||
|
||||
def log_status(self, signum, frame):
|
||||
if not _mswindows:
|
||||
infosignals = [signal.SIGUSR1]
|
||||
if hasattr(signal, 'SIGINFO'):
|
||||
infosignals.append(signal.SIGINFO)
|
||||
for s in infosignals:
|
||||
loop.add_signal_handler(
|
||||
s, lambda s=s: asyncio.ensure_future(self.log_status(s))
|
||||
)
|
||||
|
||||
async def log_status(self, sig):
|
||||
"""Log current status, triggered by SIGINFO (^T in many terminals)"""
|
||||
self.log.debug("Received signal %s[%s]", signum, signal.getsignal(signum))
|
||||
self.log.critical("Received signal %s...", sig.name)
|
||||
print_ps_info()
|
||||
print_stacks()
|
||||
|
||||
def sigterm(self, signum, frame):
|
||||
self.log.critical("Received SIGTERM, shutting down")
|
||||
def win_shutdown_cancel_tasks(self, signum, frame):
|
||||
self.log.critical("Received signalnum %s, , initiating shutdown...", signum)
|
||||
raise SystemExit(128 + signum)
|
||||
|
||||
_atexit_ran = False
|
||||
@@ -2454,6 +2679,30 @@ class JupyterHub(Application):
|
||||
loop.make_current()
|
||||
loop.run_sync(self.cleanup)
|
||||
|
||||
async def shutdown_cancel_tasks(self, sig):
|
||||
"""Cancel all other tasks of the event loop and initiate cleanup"""
|
||||
self.log.critical("Received signal %s, initiating shutdown...", sig.name)
|
||||
tasks = [
|
||||
t for t in asyncio.Task.all_tasks() if t is not asyncio.Task.current_task()
|
||||
]
|
||||
|
||||
if tasks:
|
||||
self.log.debug("Cancelling pending tasks")
|
||||
[t.cancel() for t in tasks]
|
||||
|
||||
try:
|
||||
await asyncio.wait(tasks)
|
||||
except asyncio.CancelledError as e:
|
||||
self.log.debug("Caught Task CancelledError. Ignoring")
|
||||
except StopAsyncIteration as e:
|
||||
self.log.error("Caught StopAsyncIteration Exception", exc_info=True)
|
||||
|
||||
tasks = [t for t in asyncio.Task.all_tasks()]
|
||||
for t in tasks:
|
||||
self.log.debug("Task status: %s", t)
|
||||
await self.cleanup()
|
||||
asyncio.get_event_loop().stop()
|
||||
|
||||
def stop(self):
|
||||
if not self.io_loop:
|
||||
return
|
||||
@@ -2472,13 +2721,18 @@ class JupyterHub(Application):
|
||||
@classmethod
|
||||
def launch_instance(cls, argv=None):
|
||||
self = cls.instance()
|
||||
AsyncIOMainLoop().install()
|
||||
loop = IOLoop.current()
|
||||
loop.add_callback(self.launch_instance_async, argv)
|
||||
task = asyncio.ensure_future(self.launch_instance_async(argv))
|
||||
try:
|
||||
loop.start()
|
||||
except KeyboardInterrupt:
|
||||
print("\nInterrupted")
|
||||
finally:
|
||||
if task.done():
|
||||
# re-raise exceptions in launch_instance_async
|
||||
task.result()
|
||||
loop.stop()
|
||||
loop.close()
|
||||
|
||||
|
||||
NewToken.classes.append(JupyterHub)
|
||||
|
@@ -660,6 +660,15 @@ class LocalAuthenticator(Authenticator):
|
||||
# This appears to be the Linux non-interactive adduser command:
|
||||
return ['adduser', '-q', '--gecos', '""', '--disabled-password']
|
||||
|
||||
uids = Dict(
|
||||
help="""
|
||||
Dictionary of uids to use at user creation time.
|
||||
This helps ensure that users created from the database
|
||||
get the same uid each time they are created
|
||||
in temporary deployments or containers.
|
||||
"""
|
||||
).tag(config=True)
|
||||
|
||||
group_whitelist = Set(
|
||||
help="""
|
||||
Whitelist all users from this UNIX group.
|
||||
@@ -762,7 +771,13 @@ class LocalAuthenticator(Authenticator):
|
||||
Tested to work on FreeBSD and Linux, at least.
|
||||
"""
|
||||
name = user.name
|
||||
cmd = [arg.replace('USERNAME', name) for arg in self.add_user_cmd] + [name]
|
||||
cmd = [arg.replace('USERNAME', name) for arg in self.add_user_cmd]
|
||||
try:
|
||||
uid = self.uids[name]
|
||||
cmd += ['--uid', '%d' % uid]
|
||||
except KeyError:
|
||||
self.log.debug("No UID for user %s" % name)
|
||||
cmd += [name]
|
||||
self.log.info("Creating user: %s", ' '.join(map(pipes.quote, cmd)))
|
||||
p = Popen(cmd, stdout=PIPE, stderr=STDOUT)
|
||||
p.wait()
|
||||
@@ -966,6 +981,7 @@ class PAMAuthenticator(LocalAuthenticator):
|
||||
uid = pwd.getpwnam(username).pw_uid
|
||||
username = pwd.getpwuid(uid).pw_name
|
||||
username = self.username_map.get(username, username)
|
||||
return username
|
||||
else:
|
||||
return super().normalize_username(username)
|
||||
|
||||
|
59
jupyterhub/event-schemas/server-actions/v1.yaml
Normal file
59
jupyterhub/event-schemas/server-actions/v1.yaml
Normal file
@@ -0,0 +1,59 @@
|
||||
"$id": hub.jupyter.org/server-action
|
||||
version: 1
|
||||
title: JupyterHub server events
|
||||
description: |
|
||||
Record actions on user servers made via JupyterHub.
|
||||
|
||||
JupyterHub can perform various actions on user servers via
|
||||
direct interaction from users, or via the API. This event is
|
||||
recorded whenever either of those happen.
|
||||
|
||||
Limitations:
|
||||
|
||||
1. This does not record all server starts / stops, only those
|
||||
explicitly performed by JupyterHub. For example, a user's server
|
||||
can go down because the node it was running on dies. That will
|
||||
not cause an event to be recorded, since it was not initiated
|
||||
by JupyterHub. In practice this happens often, so this is not
|
||||
a complete record.
|
||||
2. Events are only recorded when an action succeeds.
|
||||
type: object
|
||||
required:
|
||||
- action
|
||||
- username
|
||||
- servername
|
||||
properties:
|
||||
action:
|
||||
enum:
|
||||
- start
|
||||
- stop
|
||||
description: |
|
||||
Action performed by JupyterHub.
|
||||
|
||||
This is a required field.
|
||||
|
||||
Possibl Values:
|
||||
|
||||
1. start
|
||||
A user's server was successfully started
|
||||
|
||||
2. stop
|
||||
A user's server was successfully stopped
|
||||
username:
|
||||
type: string
|
||||
description: |
|
||||
Name of the user whose server this action was performed on.
|
||||
|
||||
This is the normalized name used by JupyterHub itself,
|
||||
which is derived from the authentication provider used but
|
||||
might not be the same as used in the authentication provider.
|
||||
servername:
|
||||
type: string
|
||||
description: |
|
||||
Name of the server this action was performed on.
|
||||
|
||||
JupyterHub supports each user having multiple servers with
|
||||
arbitrary names, and this field specifies the name of the
|
||||
server.
|
||||
|
||||
The 'default' server is denoted by the empty string
|
@@ -26,13 +26,16 @@ from tornado.httputil import HTTPHeaders
|
||||
from tornado.httputil import url_concat
|
||||
from tornado.ioloop import IOLoop
|
||||
from tornado.log import app_log
|
||||
from tornado.web import addslash
|
||||
from tornado.web import MissingArgumentError
|
||||
from tornado.web import RequestHandler
|
||||
|
||||
from .. import __version__
|
||||
from .. import orm
|
||||
from ..metrics import PROXY_ADD_DURATION_SECONDS
|
||||
from ..metrics import PROXY_DELETE_DURATION_SECONDS
|
||||
from ..metrics import ProxyAddStatus
|
||||
from ..metrics import ProxyDeleteStatus
|
||||
from ..metrics import RUNNING_SERVERS
|
||||
from ..metrics import SERVER_POLL_DURATION_SECONDS
|
||||
from ..metrics import SERVER_SPAWN_DURATION_SECONDS
|
||||
@@ -139,6 +142,10 @@ class BaseHandler(RequestHandler):
|
||||
def hub(self):
|
||||
return self.settings['hub']
|
||||
|
||||
@property
|
||||
def app(self):
|
||||
return self.settings['app']
|
||||
|
||||
@property
|
||||
def proxy(self):
|
||||
return self.settings['proxy']
|
||||
@@ -155,6 +162,10 @@ class BaseHandler(RequestHandler):
|
||||
def oauth_provider(self):
|
||||
return self.settings['oauth_provider']
|
||||
|
||||
@property
|
||||
def eventlog(self):
|
||||
return self.settings['eventlog']
|
||||
|
||||
def finish(self, *args, **kwargs):
|
||||
"""Roll back any uncommitted transactions from the handler."""
|
||||
if self.db.dirty:
|
||||
@@ -248,10 +259,40 @@ class BaseHandler(RequestHandler):
|
||||
orm_token = orm.OAuthAccessToken.find(self.db, token)
|
||||
if orm_token is None:
|
||||
return None
|
||||
orm_token.last_activity = orm_token.user.last_activity = datetime.utcnow()
|
||||
self.db.commit()
|
||||
|
||||
now = datetime.utcnow()
|
||||
recorded = self._record_activity(orm_token, now)
|
||||
if self._record_activity(orm_token.user, now) or recorded:
|
||||
self.db.commit()
|
||||
return self._user_from_orm(orm_token.user)
|
||||
|
||||
def _record_activity(self, obj, timestamp=None):
|
||||
"""record activity on an ORM object
|
||||
|
||||
If last_activity was more recent than self.activity_resolution seconds ago,
|
||||
do nothing to avoid unnecessarily frequent database commits.
|
||||
|
||||
Args:
|
||||
obj: an ORM object with a last_activity attribute
|
||||
timestamp (datetime, optional): the timestamp of activity to register.
|
||||
Returns:
|
||||
recorded (bool): True if activity was recorded, False if not.
|
||||
"""
|
||||
if timestamp is None:
|
||||
timestamp = datetime.utcnow()
|
||||
resolution = self.settings.get("activity_resolution", 0)
|
||||
if not obj.last_activity or resolution == 0:
|
||||
self.log.debug("Recording first activity for %s", obj)
|
||||
obj.last_activity = timestamp
|
||||
return True
|
||||
if (timestamp - obj.last_activity).total_seconds() > resolution:
|
||||
# this debug line will happen just too often
|
||||
# uncomment to debug last_activity updates
|
||||
# self.log.debug("Recording activity for %s", obj)
|
||||
obj.last_activity = timestamp
|
||||
return True
|
||||
return False
|
||||
|
||||
async def refresh_auth(self, user, force=False):
|
||||
"""Refresh user authentication info
|
||||
|
||||
@@ -322,14 +363,15 @@ class BaseHandler(RequestHandler):
|
||||
|
||||
# record token activity
|
||||
now = datetime.utcnow()
|
||||
orm_token.last_activity = now
|
||||
recorded = self._record_activity(orm_token, now)
|
||||
if orm_token.user:
|
||||
# FIXME: scopes should give us better control than this
|
||||
# don't consider API requests originating from a server
|
||||
# to be activity from the user
|
||||
if not orm_token.note.startswith("Server at "):
|
||||
orm_token.user.last_activity = now
|
||||
self.db.commit()
|
||||
recorded = self._record_activity(orm_token.user, now) or recorded
|
||||
if recorded:
|
||||
self.db.commit()
|
||||
|
||||
if orm_token.service:
|
||||
return orm_token.service
|
||||
@@ -359,8 +401,8 @@ class BaseHandler(RequestHandler):
|
||||
clear()
|
||||
return
|
||||
# update user activity
|
||||
user.last_activity = datetime.utcnow()
|
||||
self.db.commit()
|
||||
if self._record_activity(user):
|
||||
self.db.commit()
|
||||
return user
|
||||
|
||||
def _user_from_orm(self, orm_user):
|
||||
@@ -452,6 +494,8 @@ class BaseHandler(RequestHandler):
|
||||
path=url_path_join(self.base_url, 'services'),
|
||||
**kwargs
|
||||
)
|
||||
# Reset _jupyterhub_user
|
||||
self._jupyterhub_user = None
|
||||
|
||||
def _set_cookie(self, key, value, encrypted=True, **overrides):
|
||||
"""Setting any cookie should go through here
|
||||
@@ -727,6 +771,7 @@ class BaseHandler(RequestHandler):
|
||||
active_counts['spawn_pending'] + active_counts['proxy_pending']
|
||||
)
|
||||
active_count = active_counts['active']
|
||||
RUNNING_SERVERS.set(active_count)
|
||||
|
||||
concurrent_spawn_limit = self.concurrent_spawn_limit
|
||||
active_server_limit = self.active_server_limit
|
||||
@@ -810,10 +855,14 @@ class BaseHandler(RequestHandler):
|
||||
"User %s took %.3f seconds to start", user_server_name, toc - tic
|
||||
)
|
||||
self.statsd.timing('spawner.success', (toc - tic) * 1000)
|
||||
RUNNING_SERVERS.inc()
|
||||
SERVER_SPAWN_DURATION_SECONDS.labels(
|
||||
status=ServerSpawnStatus.success
|
||||
).observe(time.perf_counter() - spawn_start_time)
|
||||
self.eventlog.record_event(
|
||||
'hub.jupyter.org/server-action',
|
||||
1,
|
||||
{'action': 'start', 'username': user.name, 'servername': server_name},
|
||||
)
|
||||
proxy_add_start_time = time.perf_counter()
|
||||
spawner._proxy_pending = True
|
||||
try:
|
||||
@@ -822,6 +871,7 @@ class BaseHandler(RequestHandler):
|
||||
PROXY_ADD_DURATION_SECONDS.labels(status='success').observe(
|
||||
time.perf_counter() - proxy_add_start_time
|
||||
)
|
||||
RUNNING_SERVERS.inc()
|
||||
except Exception:
|
||||
self.log.exception("Failed to add %s to proxy!", user_server_name)
|
||||
self.log.error(
|
||||
@@ -844,7 +894,7 @@ class BaseHandler(RequestHandler):
|
||||
# clear spawner._spawn_future when it's done
|
||||
# keep an exception around, though, to prevent repeated implicit spawns
|
||||
# if spawn is failing
|
||||
if f.exception() is None:
|
||||
if f.cancelled() or f.exception() is None:
|
||||
spawner._spawn_future = None
|
||||
# Now we're all done. clear _spawn_pending flag
|
||||
spawner._spawn_pending = False
|
||||
@@ -855,7 +905,7 @@ class BaseHandler(RequestHandler):
|
||||
# update failure count and abort if consecutive failure limit
|
||||
# is reached
|
||||
def _track_failure_count(f):
|
||||
if f.exception() is None:
|
||||
if f.cancelled() or f.exception() is None:
|
||||
# spawn succeeded, reset failure count
|
||||
self.settings['failure_count'] = 0
|
||||
return
|
||||
@@ -961,7 +1011,18 @@ class BaseHandler(RequestHandler):
|
||||
self.log.warning(
|
||||
"User %s server stopped, with exit code: %s", user.name, status
|
||||
)
|
||||
await self.proxy.delete_user(user, server_name)
|
||||
proxy_deletion_start_time = time.perf_counter()
|
||||
try:
|
||||
await self.proxy.delete_user(user, server_name)
|
||||
PROXY_DELETE_DURATION_SECONDS.labels(
|
||||
status=ProxyDeleteStatus.success
|
||||
).observe(time.perf_counter() - proxy_deletion_start_time)
|
||||
except Exception:
|
||||
PROXY_DELETE_DURATION_SECONDS.labels(
|
||||
status=ProxyDeleteStatus.failure
|
||||
).observe(time.perf_counter() - proxy_deletion_start_time)
|
||||
raise
|
||||
|
||||
await user.stop(server_name)
|
||||
|
||||
async def stop_single_user(self, user, server_name=''):
|
||||
@@ -984,17 +1045,32 @@ class BaseHandler(RequestHandler):
|
||||
tic = time.perf_counter()
|
||||
try:
|
||||
await self.proxy.delete_user(user, server_name)
|
||||
PROXY_DELETE_DURATION_SECONDS.labels(
|
||||
status=ProxyDeleteStatus.success
|
||||
).observe(time.perf_counter() - tic)
|
||||
|
||||
await user.stop(server_name)
|
||||
toc = time.perf_counter()
|
||||
self.log.info(
|
||||
"User %s server took %.3f seconds to stop", user.name, toc - tic
|
||||
)
|
||||
self.statsd.timing('spawner.stop', (toc - tic) * 1000)
|
||||
RUNNING_SERVERS.dec()
|
||||
SERVER_STOP_DURATION_SECONDS.labels(
|
||||
status=ServerStopStatus.success
|
||||
).observe(toc - tic)
|
||||
self.eventlog.record_event(
|
||||
'hub.jupyter.org/server-action',
|
||||
1,
|
||||
{
|
||||
'action': 'stop',
|
||||
'username': user.name,
|
||||
'servername': server_name,
|
||||
},
|
||||
)
|
||||
except:
|
||||
PROXY_DELETE_DURATION_SECONDS.labels(
|
||||
status=ProxyDeleteStatus.failure
|
||||
).observe(time.perf_counter() - tic)
|
||||
SERVER_STOP_DURATION_SECONDS.labels(
|
||||
status=ServerStopStatus.failure
|
||||
).observe(time.perf_counter() - tic)
|
||||
@@ -1055,11 +1131,22 @@ class BaseHandler(RequestHandler):
|
||||
logout_url=self.settings['logout_url'],
|
||||
static_url=self.static_url,
|
||||
version_hash=self.version_hash,
|
||||
services=self.get_accessible_services(user),
|
||||
)
|
||||
if self.settings['template_vars']:
|
||||
ns.update(self.settings['template_vars'])
|
||||
return ns
|
||||
|
||||
def get_accessible_services(self, user):
|
||||
accessible_services = []
|
||||
if user is None:
|
||||
return accessible_services
|
||||
for service in self.services.values():
|
||||
if not service.url:
|
||||
continue
|
||||
accessible_services.append(service)
|
||||
return accessible_services
|
||||
|
||||
def write_error(self, status_code, **kwargs):
|
||||
"""render custom error pages"""
|
||||
exc_info = kwargs.get('exc_info')
|
||||
@@ -1325,7 +1412,9 @@ class UserUrlHandler(BaseHandler):
|
||||
return
|
||||
|
||||
pending_url = url_concat(
|
||||
url_path_join(self.hub.base_url, 'spawn-pending', user.name, server_name),
|
||||
url_path_join(
|
||||
self.hub.base_url, 'spawn-pending', user.escaped_name, server_name
|
||||
),
|
||||
{'next': self.request.uri},
|
||||
)
|
||||
if spawner.pending or spawner._failed:
|
||||
@@ -1339,11 +1428,16 @@ class UserUrlHandler(BaseHandler):
|
||||
# without explicit user action
|
||||
self.set_status(503)
|
||||
spawn_url = url_concat(
|
||||
url_path_join(self.hub.base_url, "spawn", user.name, server_name),
|
||||
url_path_join(self.hub.base_url, "spawn", user.escaped_name, server_name),
|
||||
{"next": self.request.uri},
|
||||
)
|
||||
auth_state = await user.get_auth_state()
|
||||
html = self.render_template(
|
||||
"not_running.html", user=user, server_name=server_name, spawn_url=spawn_url
|
||||
"not_running.html",
|
||||
user=user,
|
||||
server_name=server_name,
|
||||
spawn_url=spawn_url,
|
||||
auth_state=auth_state,
|
||||
)
|
||||
self.finish(html)
|
||||
|
||||
@@ -1416,19 +1510,51 @@ class UserRedirectHandler(BaseHandler):
|
||||
|
||||
If the user is not logged in, send to login URL, redirecting back here.
|
||||
|
||||
If c.JupyterHub.user_redirect_hook is set, the return value of that
|
||||
callable is used to generate the redirect URL.
|
||||
|
||||
.. versionadded:: 0.7
|
||||
"""
|
||||
|
||||
@web.authenticated
|
||||
def get(self, path):
|
||||
user = self.current_user
|
||||
user_url = url_path_join(user.url, path)
|
||||
if self.request.query:
|
||||
user_url = url_concat(user_url, parse_qsl(self.request.query))
|
||||
async def get(self, path):
|
||||
# If hook is present to generate URL to redirect to, use that instead
|
||||
# of the default. The configurer is responsible for making sure this
|
||||
# URL is right. If None is returned by the hook, we do our normal
|
||||
# processing
|
||||
url = None
|
||||
if self.app.user_redirect_hook:
|
||||
url = await maybe_future(
|
||||
self.app.user_redirect_hook(
|
||||
path, self.request, self.current_user, self.base_url
|
||||
)
|
||||
)
|
||||
if url is None:
|
||||
user = self.current_user
|
||||
user_url = user.url
|
||||
|
||||
url = url_concat(
|
||||
url_path_join(self.hub.base_url, "spawn", user.name), {"next": user_url}
|
||||
)
|
||||
if self.app.default_server_name:
|
||||
user_url = url_path_join(user_url, self.app.default_server_name)
|
||||
|
||||
user_url = url_path_join(user_url, path)
|
||||
if self.request.query:
|
||||
user_url = url_concat(user_url, parse_qsl(self.request.query))
|
||||
|
||||
if self.app.default_server_name:
|
||||
url = url_concat(
|
||||
url_path_join(
|
||||
self.hub.base_url,
|
||||
"spawn",
|
||||
user.escaped_name,
|
||||
self.app.default_server_name,
|
||||
),
|
||||
{"next": user_url},
|
||||
)
|
||||
else:
|
||||
url = url_concat(
|
||||
url_path_join(self.hub.base_url, "spawn", user.escaped_name),
|
||||
{"next": user_url},
|
||||
)
|
||||
|
||||
self.redirect(url)
|
||||
|
||||
@@ -1450,10 +1576,9 @@ class CSPReportHandler(BaseHandler):
|
||||
class AddSlashHandler(BaseHandler):
|
||||
"""Handler for adding trailing slash to URLs that need them"""
|
||||
|
||||
def get(self, *args):
|
||||
src = urlparse(self.request.uri)
|
||||
dest = src._replace(path=src.path + '/')
|
||||
self.redirect(urlunparse(dest))
|
||||
@addslash
|
||||
def get(self):
|
||||
pass
|
||||
|
||||
|
||||
default_handlers = [
|
||||
|
@@ -18,33 +18,73 @@ class LogoutHandler(BaseHandler):
|
||||
def shutdown_on_logout(self):
|
||||
return self.settings.get('shutdown_on_logout', False)
|
||||
|
||||
async def get(self):
|
||||
async def _shutdown_servers(self, user):
|
||||
"""Shutdown servers for logout
|
||||
|
||||
Get all active servers for the provided user, stop them.
|
||||
"""
|
||||
active_servers = [
|
||||
name
|
||||
for (name, spawner) in user.spawners.items()
|
||||
if spawner.active and not spawner.pending
|
||||
]
|
||||
if active_servers:
|
||||
self.log.info("Shutting down %s's servers", user.name)
|
||||
futures = []
|
||||
for server_name in active_servers:
|
||||
futures.append(maybe_future(self.stop_single_user(user, server_name)))
|
||||
await asyncio.gather(*futures)
|
||||
|
||||
def _backend_logout_cleanup(self, name):
|
||||
"""Default backend logout actions
|
||||
|
||||
Send a log message, clear some cookies, increment the logout counter.
|
||||
"""
|
||||
self.log.info("User logged out: %s", name)
|
||||
self.clear_login_cookie()
|
||||
self.statsd.incr('logout')
|
||||
|
||||
async def default_handle_logout(self):
|
||||
"""The default logout action
|
||||
|
||||
Optionally cleans up servers, clears cookies, increments logout counter
|
||||
Cleaning up servers can be prevented by setting shutdown_on_logout to
|
||||
False.
|
||||
"""
|
||||
user = self.current_user
|
||||
if user:
|
||||
if self.shutdown_on_logout:
|
||||
active_servers = [
|
||||
name
|
||||
for (name, spawner) in user.spawners.items()
|
||||
if spawner.active and not spawner.pending
|
||||
]
|
||||
if active_servers:
|
||||
self.log.info("Shutting down %s's servers", user.name)
|
||||
futures = []
|
||||
for server_name in active_servers:
|
||||
futures.append(
|
||||
maybe_future(self.stop_single_user(user, server_name))
|
||||
)
|
||||
await asyncio.gather(*futures)
|
||||
await self._shutdown_servers(user)
|
||||
|
||||
self.log.info("User logged out: %s", user.name)
|
||||
self.clear_login_cookie()
|
||||
self.statsd.incr('logout')
|
||||
self._backend_logout_cleanup(user.name)
|
||||
|
||||
async def handle_logout(self):
|
||||
"""Custom user action during logout
|
||||
|
||||
By default a no-op, this function should be overridden in subclasses
|
||||
to have JupyterHub take a custom action on logout.
|
||||
"""
|
||||
return
|
||||
|
||||
async def render_logout_page(self):
|
||||
"""Render the logout page, if any
|
||||
|
||||
Override this function to set a custom logout page.
|
||||
"""
|
||||
if self.authenticator.auto_login:
|
||||
html = self.render_template('logout.html')
|
||||
self.finish(html)
|
||||
else:
|
||||
self.redirect(self.settings['login_url'], permanent=False)
|
||||
|
||||
async def get(self):
|
||||
"""Log the user out, call the custom action, forward the user
|
||||
to the logout page
|
||||
"""
|
||||
await self.default_handle_logout()
|
||||
await self.handle_logout()
|
||||
await self.render_logout_page()
|
||||
|
||||
|
||||
class LoginHandler(BaseHandler):
|
||||
"""Render the login page."""
|
||||
|
@@ -2,6 +2,7 @@
|
||||
# Copyright (c) Jupyter Development Team.
|
||||
# Distributed under the terms of the Modified BSD License.
|
||||
import asyncio
|
||||
import codecs
|
||||
import copy
|
||||
import time
|
||||
from collections import defaultdict
|
||||
@@ -13,6 +14,7 @@ from tornado import gen
|
||||
from tornado import web
|
||||
from tornado.httputil import url_concat
|
||||
|
||||
from .. import __version__
|
||||
from .. import orm
|
||||
from ..metrics import SERVER_POLL_DURATION_SECONDS
|
||||
from ..metrics import ServerPollStatus
|
||||
@@ -61,12 +63,14 @@ class HomeHandler(BaseHandler):
|
||||
# to establish that this is an explicit spawn request rather
|
||||
# than an implicit one, which can be caused by any link to `/user/:name(/:server_name)`
|
||||
if user.active:
|
||||
url = url_path_join(self.base_url, 'user', user.name)
|
||||
url = url_path_join(self.base_url, 'user', user.escaped_name)
|
||||
else:
|
||||
url = url_path_join(self.hub.base_url, 'spawn', user.name)
|
||||
url = url_path_join(self.hub.base_url, 'spawn', user.escaped_name)
|
||||
|
||||
auth_state = await user.get_auth_state()
|
||||
html = self.render_template(
|
||||
'home.html',
|
||||
auth_state=auth_state,
|
||||
user=user,
|
||||
url=url,
|
||||
allow_named_servers=self.allow_named_servers,
|
||||
@@ -89,10 +93,12 @@ class SpawnHandler(BaseHandler):
|
||||
|
||||
default_url = None
|
||||
|
||||
def _render_form(self, for_user, spawner_options_form, message=''):
|
||||
async def _render_form(self, for_user, spawner_options_form, message=''):
|
||||
auth_state = await for_user.get_auth_state()
|
||||
return self.render_template(
|
||||
'spawn.html',
|
||||
for_user=for_user,
|
||||
auth_state=auth_state,
|
||||
spawner_options_form=spawner_options_form,
|
||||
error_message=message,
|
||||
url=self.request.uri,
|
||||
@@ -117,6 +123,23 @@ class SpawnHandler(BaseHandler):
|
||||
if user is None:
|
||||
raise web.HTTPError(404, "No such user: %s" % for_user)
|
||||
|
||||
if server_name:
|
||||
if not self.allow_named_servers:
|
||||
raise web.HTTPError(400, "Named servers are not enabled.")
|
||||
if (
|
||||
self.named_server_limit_per_user > 0
|
||||
and server_name not in user.orm_spawners
|
||||
):
|
||||
named_spawners = list(user.all_spawners(include_default=False))
|
||||
if self.named_server_limit_per_user <= len(named_spawners):
|
||||
raise web.HTTPError(
|
||||
400,
|
||||
"User {} already has the maximum of {} named servers."
|
||||
" One must be deleted before a new server can be created".format(
|
||||
user.name, self.named_server_limit_per_user
|
||||
),
|
||||
)
|
||||
|
||||
if not self.allow_named_servers and user.running:
|
||||
url = self.get_next_url(user, default=user.server_url(server_name))
|
||||
self.log.info("User is running: %s", user.name)
|
||||
@@ -127,12 +150,13 @@ class SpawnHandler(BaseHandler):
|
||||
server_name = ''
|
||||
|
||||
spawner = user.spawners[server_name]
|
||||
|
||||
# resolve `?next=...`, falling back on the spawn-pending url
|
||||
# must not be /user/server for named servers,
|
||||
# which may get handled by the default server if they aren't ready yet
|
||||
|
||||
pending_url = url_path_join(
|
||||
self.hub.base_url, "spawn-pending", user.name, server_name
|
||||
self.hub.base_url, "spawn-pending", user.escaped_name, server_name
|
||||
)
|
||||
|
||||
if self.get_argument('next', None):
|
||||
@@ -153,10 +177,16 @@ class SpawnHandler(BaseHandler):
|
||||
|
||||
# Add handler to spawner here so you can access query params in form rendering.
|
||||
spawner.handler = self
|
||||
|
||||
# auth_state may be an input to options form,
|
||||
# so resolve the auth state hook here
|
||||
auth_state = await user.get_auth_state()
|
||||
await spawner.run_auth_state_hook(auth_state)
|
||||
|
||||
spawner_options_form = await spawner.get_options_form()
|
||||
if spawner_options_form:
|
||||
self.log.debug("Serving options form for %s", spawner._log_name)
|
||||
form = self._render_form(
|
||||
form = await self._render_form(
|
||||
for_user=user, spawner_options_form=spawner_options_form
|
||||
)
|
||||
self.finish(form)
|
||||
@@ -171,7 +201,16 @@ class SpawnHandler(BaseHandler):
|
||||
spawner._spawn_future = None
|
||||
# not running, no form. Trigger spawn and redirect back to /user/:name
|
||||
f = asyncio.ensure_future(self.spawn_single_user(user, server_name))
|
||||
await asyncio.wait([f], timeout=1)
|
||||
done, pending = await asyncio.wait([f], timeout=1)
|
||||
# If spawn_single_user throws an exception, raise a 500 error
|
||||
# otherwise it may cause a redirect loop
|
||||
if f.done() and f.exception():
|
||||
exc = f.exception()
|
||||
raise web.HTTPError(
|
||||
500,
|
||||
"Error in Authenticator.pre_spawn_start: %s %s"
|
||||
% (type(exc).__name__, str(exc)),
|
||||
)
|
||||
self.redirect(pending_url)
|
||||
|
||||
@web.authenticated
|
||||
@@ -209,7 +248,7 @@ class SpawnHandler(BaseHandler):
|
||||
"Failed to spawn single-user server with form", exc_info=True
|
||||
)
|
||||
spawner_options_form = await user.spawner.get_options_form()
|
||||
form = self._render_form(
|
||||
form = await self._render_form(
|
||||
for_user=user, spawner_options_form=spawner_options_form, message=str(e)
|
||||
)
|
||||
self.finish(form)
|
||||
@@ -219,7 +258,7 @@ class SpawnHandler(BaseHandler):
|
||||
next_url = self.get_next_url(
|
||||
user,
|
||||
default=url_path_join(
|
||||
self.hub.base_url, "spawn-pending", user.name, server_name
|
||||
self.hub.base_url, "spawn-pending", user.escaped_name, server_name
|
||||
),
|
||||
)
|
||||
self.redirect(next_url)
|
||||
@@ -270,6 +309,8 @@ class SpawnPendingHandler(BaseHandler):
|
||||
# if spawning fails for any reason, point users to /hub/home to retry
|
||||
self.extra_error_html = self.spawn_home_error
|
||||
|
||||
auth_state = await user.get_auth_state()
|
||||
|
||||
# First, check for previous failure.
|
||||
if (
|
||||
not spawner.active
|
||||
@@ -282,11 +323,14 @@ class SpawnPendingHandler(BaseHandler):
|
||||
# We should point the user to Home if the most recent spawn failed.
|
||||
exc = spawner._spawn_future.exception()
|
||||
self.log.error("Previous spawn for %s failed: %s", spawner._log_name, exc)
|
||||
spawn_url = url_path_join(self.hub.base_url, "spawn", user.escaped_name)
|
||||
spawn_url = url_path_join(
|
||||
self.hub.base_url, "spawn", user.escaped_name, server_name
|
||||
)
|
||||
self.set_status(500)
|
||||
html = self.render_template(
|
||||
"not_running.html",
|
||||
user=user,
|
||||
auth_state=auth_state,
|
||||
server_name=server_name,
|
||||
spawn_url=spawn_url,
|
||||
failed=True,
|
||||
@@ -308,7 +352,11 @@ class SpawnPendingHandler(BaseHandler):
|
||||
else:
|
||||
page = "spawn_pending.html"
|
||||
html = self.render_template(
|
||||
page, user=user, spawner=spawner, progress_url=spawner._progress_url
|
||||
page,
|
||||
user=user,
|
||||
spawner=spawner,
|
||||
progress_url=spawner._progress_url,
|
||||
auth_state=auth_state,
|
||||
)
|
||||
self.finish(html)
|
||||
return
|
||||
@@ -327,10 +375,13 @@ class SpawnPendingHandler(BaseHandler):
|
||||
# further, set status to 404 because this is not
|
||||
# serving the expected page
|
||||
if status is not None:
|
||||
spawn_url = url_path_join(self.hub.base_url, "spawn", user.escaped_name)
|
||||
spawn_url = url_path_join(
|
||||
self.hub.base_url, "spawn", user.escaped_name, server_name
|
||||
)
|
||||
html = self.render_template(
|
||||
"not_running.html",
|
||||
user=user,
|
||||
auth_state=auth_state,
|
||||
server_name=server_name,
|
||||
spawn_url=spawn_url,
|
||||
)
|
||||
@@ -348,8 +399,9 @@ class SpawnPendingHandler(BaseHandler):
|
||||
class AdminHandler(BaseHandler):
|
||||
"""Render the admin page."""
|
||||
|
||||
@web.authenticated
|
||||
@admin_only
|
||||
def get(self):
|
||||
async def get(self):
|
||||
available = {'name', 'admin', 'running', 'last_activity'}
|
||||
default_sort = ['admin', 'name']
|
||||
mapping = {'running': orm.Spawner.server_id}
|
||||
@@ -398,15 +450,18 @@ class AdminHandler(BaseHandler):
|
||||
for u in users:
|
||||
running.extend(s for s in u.spawners.values() if s.active)
|
||||
|
||||
auth_state = await self.current_user.get_auth_state()
|
||||
html = self.render_template(
|
||||
'admin.html',
|
||||
current_user=self.current_user,
|
||||
auth_state=auth_state,
|
||||
admin_access=self.settings.get('admin_access', False),
|
||||
users=users,
|
||||
running=running,
|
||||
sort={s: o for s, o in zip(sorts, orders)},
|
||||
allow_named_servers=self.allow_named_servers,
|
||||
named_server_limit_per_user=self.named_server_limit_per_user,
|
||||
server_version='{} {}'.format(__version__, self.version_hash),
|
||||
)
|
||||
self.finish(html)
|
||||
|
||||
@@ -415,7 +470,7 @@ class TokenPageHandler(BaseHandler):
|
||||
"""Handler for page requesting new API tokens"""
|
||||
|
||||
@web.authenticated
|
||||
def get(self):
|
||||
async def get(self):
|
||||
never = datetime(1900, 1, 1)
|
||||
|
||||
user = self.current_user
|
||||
@@ -484,8 +539,12 @@ class TokenPageHandler(BaseHandler):
|
||||
|
||||
oauth_clients = sorted(oauth_clients, key=sort_key, reverse=True)
|
||||
|
||||
auth_state = await self.current_user.get_auth_state()
|
||||
html = self.render_template(
|
||||
'token.html', api_tokens=api_tokens, oauth_clients=oauth_clients
|
||||
'token.html',
|
||||
api_tokens=api_tokens,
|
||||
oauth_clients=oauth_clients,
|
||||
auth_state=auth_state,
|
||||
)
|
||||
self.finish(html)
|
||||
|
||||
|
@@ -162,7 +162,7 @@ def log_request(handler):
|
||||
location='',
|
||||
)
|
||||
msg = "{status} {method} {uri}{location} ({user}@{ip}) {request_time:.2f}ms"
|
||||
if status >= 500 and status != 502:
|
||||
if status >= 500 and status not in {502, 503}:
|
||||
log_method(json.dumps(headers, indent=2))
|
||||
elif status in {301, 302}:
|
||||
# log redirect targets
|
||||
|
@@ -39,16 +39,24 @@ RUNNING_SERVERS = Gauge(
|
||||
'running_servers', 'the number of user servers currently running'
|
||||
)
|
||||
|
||||
RUNNING_SERVERS.set(0)
|
||||
|
||||
TOTAL_USERS = Gauge('total_users', 'toal number of users')
|
||||
|
||||
TOTAL_USERS.set(0)
|
||||
TOTAL_USERS = Gauge('total_users', 'total number of users')
|
||||
|
||||
CHECK_ROUTES_DURATION_SECONDS = Histogram(
|
||||
'check_routes_duration_seconds', 'Time taken to validate all routes in proxy'
|
||||
)
|
||||
|
||||
HUB_STARTUP_DURATION_SECONDS = Histogram(
|
||||
'hub_startup_duration_seconds', 'Time taken for Hub to start'
|
||||
)
|
||||
|
||||
INIT_SPAWNERS_DURATION_SECONDS = Histogram(
|
||||
'init_spawners_duration_seconds', 'Time taken for spawners to initialize'
|
||||
)
|
||||
|
||||
PROXY_POLL_DURATION_SECONDS = Histogram(
|
||||
'proxy_poll_duration_seconds', 'duration for polling all routes from proxy'
|
||||
)
|
||||
|
||||
|
||||
class ServerSpawnStatus(Enum):
|
||||
"""
|
||||
@@ -139,6 +147,29 @@ for s in ServerStopStatus:
|
||||
SERVER_STOP_DURATION_SECONDS.labels(status=s)
|
||||
|
||||
|
||||
PROXY_DELETE_DURATION_SECONDS = Histogram(
|
||||
'proxy_delete_duration_seconds',
|
||||
'duration for deleting user routes from proxy',
|
||||
['status'],
|
||||
)
|
||||
|
||||
|
||||
class ProxyDeleteStatus(Enum):
|
||||
"""
|
||||
Possible values for 'status' label of PROXY_DELETE_DURATION_SECONDS
|
||||
"""
|
||||
|
||||
success = 'success'
|
||||
failure = 'failure'
|
||||
|
||||
def __str__(self):
|
||||
return self.value
|
||||
|
||||
|
||||
for s in ProxyDeleteStatus:
|
||||
PROXY_DELETE_DURATION_SECONDS.labels(status=s)
|
||||
|
||||
|
||||
def prometheus_log_method(handler):
|
||||
"""
|
||||
Tornado log handler for recording RED metrics.
|
||||
|
@@ -213,8 +213,4 @@ class Hub(Server):
|
||||
return url_path_join(self.url, 'api')
|
||||
|
||||
def __repr__(self):
|
||||
return "<%s %s:%s>" % (
|
||||
self.__class__.__name__,
|
||||
self.server.ip,
|
||||
self.server.port,
|
||||
)
|
||||
return "<%s %s:%s>" % (self.__class__.__name__, self.ip, self.port)
|
||||
|
@@ -770,8 +770,8 @@ def mysql_large_prefix_check(engine):
|
||||
).fetchall()
|
||||
)
|
||||
if (
|
||||
variables['innodb_file_format'] == 'Barracuda'
|
||||
and variables['innodb_large_prefix'] == 'ON'
|
||||
variables.get('innodb_file_format', 'Barracuda') == 'Barracuda'
|
||||
and variables.get('innodb_large_prefix', 'ON') == 'ON'
|
||||
):
|
||||
return True
|
||||
else:
|
||||
|
@@ -42,6 +42,7 @@ from traitlets.config import LoggingConfigurable
|
||||
|
||||
from . import utils
|
||||
from .metrics import CHECK_ROUTES_DURATION_SECONDS
|
||||
from .metrics import PROXY_POLL_DURATION_SECONDS
|
||||
from .objects import Server
|
||||
from .utils import make_ssl_context
|
||||
from .utils import url_path_join
|
||||
@@ -801,6 +802,7 @@ class ConfigurableHTTPProxy(Proxy):
|
||||
|
||||
async def get_all_routes(self, client=None):
|
||||
"""Fetch the proxy's routes."""
|
||||
proxy_poll_start_time = time.perf_counter()
|
||||
resp = await self.api_request('', client=client)
|
||||
chp_routes = json.loads(resp.body.decode('utf8', 'replace'))
|
||||
all_routes = {}
|
||||
@@ -811,4 +813,5 @@ class ConfigurableHTTPProxy(Proxy):
|
||||
self.log.debug("Omitting non-jupyterhub route %r", routespec)
|
||||
continue
|
||||
all_routes[routespec] = self._reformat_routespec(routespec, chp_data)
|
||||
PROXY_POLL_DURATION_SECONDS.observe(time.perf_counter() - proxy_poll_start_time)
|
||||
return all_routes
|
||||
|
@@ -216,7 +216,7 @@ class HubAuth(SingletonConfigurable):
|
||||
return self.hub_host + url_path_join(self.hub_prefix, 'login')
|
||||
|
||||
keyfile = Unicode(
|
||||
'',
|
||||
os.getenv('JUPYTERHUB_SSL_KEYFILE', ''),
|
||||
help="""The ssl key to use for requests
|
||||
|
||||
Use with certfile
|
||||
@@ -224,7 +224,7 @@ class HubAuth(SingletonConfigurable):
|
||||
).tag(config=True)
|
||||
|
||||
certfile = Unicode(
|
||||
'',
|
||||
os.getenv('JUPYTERHUB_SSL_CERTFILE', ''),
|
||||
help="""The ssl cert to use for requests
|
||||
|
||||
Use with keyfile
|
||||
@@ -232,7 +232,7 @@ class HubAuth(SingletonConfigurable):
|
||||
).tag(config=True)
|
||||
|
||||
client_ca = Unicode(
|
||||
'',
|
||||
os.getenv('JUPYTERHUB_SSL_CLIENT_CA', ''),
|
||||
help="""The ssl certificate authority to use to verify requests
|
||||
|
||||
Use with keyfile and certfile
|
||||
@@ -428,7 +428,7 @@ class HubAuth(SingletonConfigurable):
|
||||
)
|
||||
|
||||
auth_header_name = 'Authorization'
|
||||
auth_header_pat = re.compile('token\s+(.+)', re.IGNORECASE)
|
||||
auth_header_pat = re.compile(r'token\s+(.+)', re.IGNORECASE)
|
||||
|
||||
def get_token(self, handler):
|
||||
"""Get the user token from a request
|
||||
|
@@ -147,11 +147,14 @@ class Service(LoggingConfigurable):
|
||||
|
||||
- name: str
|
||||
the name of the service
|
||||
- admin: bool(false)
|
||||
- admin: bool(False)
|
||||
whether the service should have administrative privileges
|
||||
- url: str (None)
|
||||
The URL where the service is/should be.
|
||||
If specified, the service will be added to the proxy at /services/:name
|
||||
- oauth_no_confirm: bool(False)
|
||||
Whether this service should be allowed to complete oauth
|
||||
with logged-in users without prompting for confirmation.
|
||||
|
||||
If a service is to be managed by the Hub, it has a few extra options:
|
||||
|
||||
@@ -184,6 +187,7 @@ class Service(LoggingConfigurable):
|
||||
If managed, will be passed as JUPYTERHUB_SERVICE_URL env.
|
||||
"""
|
||||
).tag(input=True)
|
||||
|
||||
api_token = Unicode(
|
||||
help="""The API token to use for the service.
|
||||
|
||||
@@ -197,6 +201,21 @@ class Service(LoggingConfigurable):
|
||||
"""
|
||||
).tag(input=True)
|
||||
|
||||
oauth_no_confirm = Bool(
|
||||
False,
|
||||
help="""Skip OAuth confirmation when users access this service.
|
||||
|
||||
By default, when users authenticate with a service using JupyterHub,
|
||||
they are prompted to confirm that they want to grant that service
|
||||
access to their credentials.
|
||||
Setting oauth_no_confirm=True skips the confirmation web page for this service.
|
||||
Skipping the confirmation page is useful for admin-managed services that are considered part of the Hub
|
||||
and shouldn't need extra prompts for login.
|
||||
|
||||
.. versionadded: 1.1
|
||||
""",
|
||||
).tag(input=True)
|
||||
|
||||
# Managed service API:
|
||||
spawner = Any()
|
||||
|
||||
|
@@ -334,8 +334,8 @@ class SingleUserNotebookApp(NotebookApp):
|
||||
login_handler_class = JupyterHubLoginHandler
|
||||
logout_handler_class = JupyterHubLogoutHandler
|
||||
port_retries = (
|
||||
0
|
||||
) # disable port-retries, since the Spawner will tell us what port to use
|
||||
0 # disable port-retries, since the Spawner will tell us what port to use
|
||||
)
|
||||
|
||||
disable_user_config = Bool(
|
||||
False,
|
||||
|
@@ -16,6 +16,8 @@ import warnings
|
||||
from subprocess import Popen
|
||||
from tempfile import mkdtemp
|
||||
|
||||
if os.name == 'nt':
|
||||
import psutil
|
||||
from async_generator import async_generator
|
||||
from async_generator import yield_
|
||||
from sqlalchemy import inspect
|
||||
@@ -86,6 +88,7 @@ class Spawner(LoggingConfigurable):
|
||||
_start_pending = False
|
||||
_stop_pending = False
|
||||
_proxy_pending = False
|
||||
_check_pending = False
|
||||
_waiting_for_response = False
|
||||
_jupyterhub_version = None
|
||||
_spawn_future = None
|
||||
@@ -121,6 +124,8 @@ class Spawner(LoggingConfigurable):
|
||||
return 'spawn'
|
||||
elif self._stop_pending:
|
||||
return 'stop'
|
||||
elif self._check_pending:
|
||||
return 'check'
|
||||
return None
|
||||
|
||||
@property
|
||||
@@ -207,8 +212,6 @@ class Spawner(LoggingConfigurable):
|
||||
return self.orm_spawner.name
|
||||
return ''
|
||||
|
||||
hub = Any()
|
||||
authenticator = Any()
|
||||
internal_ssl = Bool(False)
|
||||
internal_trust_bundles = Dict()
|
||||
internal_certs_location = Unicode('')
|
||||
@@ -627,6 +630,24 @@ class Spawner(LoggingConfigurable):
|
||||
"""
|
||||
).tag(config=True)
|
||||
|
||||
auth_state_hook = Any(
|
||||
help="""
|
||||
An optional hook function that you can implement to pass `auth_state`
|
||||
to the spawner after it has been initialized but before it starts.
|
||||
The `auth_state` dictionary may be set by the `.authenticate()`
|
||||
method of the authenticator. This hook enables you to pass some
|
||||
or all of that information to your spawner.
|
||||
|
||||
Example::
|
||||
|
||||
def userdata_hook(spawner, auth_state):
|
||||
spawner.userdata = auth_state["userdata"]
|
||||
|
||||
c.Spawner.auth_state_hook = userdata_hook
|
||||
|
||||
"""
|
||||
).tag(config=True)
|
||||
|
||||
def load_state(self, state):
|
||||
"""Restore state of spawner from database.
|
||||
|
||||
@@ -953,6 +974,14 @@ class Spawner(LoggingConfigurable):
|
||||
except Exception:
|
||||
self.log.exception("post_stop_hook failed with exception: %s", self)
|
||||
|
||||
async def run_auth_state_hook(self, auth_state):
|
||||
"""Run the auth_state_hook if defined"""
|
||||
if self.auth_state_hook is not None:
|
||||
try:
|
||||
await maybe_future(self.auth_state_hook(self, auth_state))
|
||||
except Exception:
|
||||
self.log.exception("auth_stop_hook failed with exception: %s", self)
|
||||
|
||||
@property
|
||||
def _progress_url(self):
|
||||
return self.user.progress_url(self.name)
|
||||
@@ -1351,7 +1380,8 @@ class LocalProcessSpawner(Spawner):
|
||||
home = user.pw_dir
|
||||
|
||||
# Create dir for user's certs wherever we're starting
|
||||
out_dir = "{home}/.jupyterhub/jupyterhub-certs".format(home=home)
|
||||
hub_dir = "{home}/.jupyterhub".format(home=home)
|
||||
out_dir = "{hub_dir}/jupyterhub-certs".format(hub_dir=hub_dir)
|
||||
shutil.rmtree(out_dir, ignore_errors=True)
|
||||
os.makedirs(out_dir, 0o700, exist_ok=True)
|
||||
|
||||
@@ -1365,7 +1395,7 @@ class LocalProcessSpawner(Spawner):
|
||||
ca = os.path.join(out_dir, os.path.basename(paths['cafile']))
|
||||
|
||||
# Set cert ownership to user
|
||||
for f in [out_dir, key, cert, ca]:
|
||||
for f in [hub_dir, out_dir, key, cert, ca]:
|
||||
shutil.chown(f, user=uid, group=gid)
|
||||
|
||||
return {"keyfile": key, "certfile": cert, "cafile": ca}
|
||||
@@ -1440,9 +1470,11 @@ class LocalProcessSpawner(Spawner):
|
||||
self.clear_state()
|
||||
return 0
|
||||
|
||||
# send signal 0 to check if PID exists
|
||||
# this doesn't work on Windows, but that's okay because we don't support Windows.
|
||||
alive = await self._signal(0)
|
||||
# We use pustil.pid_exists on windows
|
||||
if os.name == 'nt':
|
||||
alive = psutil.pid_exists(self.pid)
|
||||
else:
|
||||
alive = await self._signal(0)
|
||||
if not alive:
|
||||
self.clear_state()
|
||||
return 0
|
||||
@@ -1458,11 +1490,10 @@ class LocalProcessSpawner(Spawner):
|
||||
"""
|
||||
try:
|
||||
os.kill(self.pid, sig)
|
||||
except ProcessLookupError:
|
||||
return False # process is gone
|
||||
except OSError as e:
|
||||
if e.errno == errno.ESRCH:
|
||||
return False # process is gone
|
||||
else:
|
||||
raise
|
||||
raise # Can be EPERM or EINVAL
|
||||
return True # process exists
|
||||
|
||||
async def stop(self, now=False):
|
||||
|
@@ -166,8 +166,7 @@ class FormSpawner(MockSpawner):
|
||||
options_form = "IMAFORM"
|
||||
|
||||
def options_from_form(self, form_data):
|
||||
options = {}
|
||||
options['notspecified'] = 5
|
||||
options = {'notspecified': 5}
|
||||
if 'bounds' in form_data:
|
||||
options['bounds'] = [int(i) for i in form_data['bounds']]
|
||||
if 'energy' in form_data:
|
||||
|
@@ -3,9 +3,11 @@ import binascii
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import time
|
||||
from subprocess import check_output
|
||||
from subprocess import PIPE
|
||||
from subprocess import Popen
|
||||
from subprocess import run
|
||||
from tempfile import NamedTemporaryFile
|
||||
from tempfile import TemporaryDirectory
|
||||
from unittest.mock import patch
|
||||
@@ -39,6 +41,28 @@ def test_token_app():
|
||||
assert re.match(r'^[a-z0-9]+$', out)
|
||||
|
||||
|
||||
def test_raise_error_on_missing_specified_config():
|
||||
"""
|
||||
Using the -f or --config flag when starting JupyterHub should require the
|
||||
file to be found and exit if it isn't.
|
||||
"""
|
||||
# subprocess.run doesn't have a timeout flag, so if this test would fail by
|
||||
# not letting jupyterhub error out, we would wait forever. subprocess.Popen
|
||||
# allow us to manually timeout.
|
||||
process = Popen(
|
||||
[sys.executable, '-m', 'jupyterhub', '--config', 'not-available.py']
|
||||
)
|
||||
# wait inpatiently for the process to exit like we want it to
|
||||
for i in range(100):
|
||||
time.sleep(0.1)
|
||||
returncode = process.poll()
|
||||
if returncode is not None:
|
||||
break
|
||||
else:
|
||||
process.kill()
|
||||
assert returncode == 1
|
||||
|
||||
|
||||
def test_generate_config():
|
||||
with NamedTemporaryFile(prefix='jupyterhub_config', suffix='.py') as tf:
|
||||
cfg_file = tf.name
|
||||
|
@@ -30,7 +30,7 @@ def generate_old_db(env_dir, hub_version, db_url):
|
||||
if 'mysql' in db_url:
|
||||
pkgs.append('mysql-connector-python')
|
||||
elif 'postgres' in db_url:
|
||||
pkgs.append('psycopg2')
|
||||
pkgs.append('psycopg2-binary')
|
||||
check_call([env_pip, 'install'] + pkgs)
|
||||
check_call([env_py, populate_db, db_url])
|
||||
|
||||
|
80
jupyterhub/tests/test_eventlog.py
Normal file
80
jupyterhub/tests/test_eventlog.py
Normal file
@@ -0,0 +1,80 @@
|
||||
"""Tests for Eventlogging in JupyterHub.
|
||||
|
||||
To test a new schema or event, simply add it to the
|
||||
`valid_events` and `invalid_events` variables below.
|
||||
|
||||
You *shouldn't* need to write new tests.
|
||||
"""
|
||||
import io
|
||||
import json
|
||||
import logging
|
||||
from unittest import mock
|
||||
|
||||
import jsonschema
|
||||
import pytest
|
||||
from traitlets.config import Config
|
||||
|
||||
from .mocking import MockHub
|
||||
|
||||
|
||||
# To test new schemas, add them to the `valid_events`
|
||||
# and `invalid_events` dictionary below.
|
||||
|
||||
# To test valid events, add event item with the form:
|
||||
# { ( '<schema id>', <version> ) : { <event_data> } }
|
||||
valid_events = [
|
||||
(
|
||||
'hub.jupyter.org/server-action',
|
||||
1,
|
||||
dict(action='start', username='test-username', servername='test-servername'),
|
||||
)
|
||||
]
|
||||
|
||||
# To test invalid events, add event item with the form:
|
||||
# { ( '<schema id>', <version> ) : { <event_data> } }
|
||||
invalid_events = [
|
||||
# Missing required keys
|
||||
('hub.jupyter.org/server-action', 1, dict(action='start'))
|
||||
]
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def eventlog_sink(app):
|
||||
"""Return eventlog and sink objects"""
|
||||
sink = io.StringIO()
|
||||
handler = logging.StreamHandler(sink)
|
||||
# Update the EventLog config with handler
|
||||
cfg = Config()
|
||||
cfg.EventLog.handlers = [handler]
|
||||
|
||||
with mock.patch.object(app.config, 'EventLog', cfg.EventLog):
|
||||
# recreate the eventlog object with our config
|
||||
app.init_eventlog()
|
||||
# return the sink from the fixture
|
||||
yield app.eventlog, sink
|
||||
# reset eventlog with original config
|
||||
app.init_eventlog()
|
||||
|
||||
|
||||
@pytest.mark.parametrize('schema, version, event', valid_events)
|
||||
def test_valid_events(eventlog_sink, schema, version, event):
|
||||
eventlog, sink = eventlog_sink
|
||||
eventlog.allowed_schemas = [schema]
|
||||
# Record event
|
||||
eventlog.record_event(schema, version, event)
|
||||
# Inspect consumed event
|
||||
output = sink.getvalue()
|
||||
assert output
|
||||
data = json.loads(output)
|
||||
# Verify event data was recorded
|
||||
assert data is not None
|
||||
|
||||
|
||||
@pytest.mark.parametrize('schema, version, event', invalid_events)
|
||||
def test_invalid_events(eventlog_sink, schema, version, event):
|
||||
eventlog, sink = eventlog_sink
|
||||
eventlog.allowed_schemas = [schema]
|
||||
|
||||
# Make sure an error is thrown when bad events are recorded
|
||||
with pytest.raises(jsonschema.ValidationError):
|
||||
recorded_event = eventlog.record_event(schema, version, event)
|
@@ -6,6 +6,7 @@ from unittest import mock
|
||||
from urllib.parse import urlparse
|
||||
|
||||
import pytest
|
||||
from requests.exceptions import ConnectionError
|
||||
from requests.exceptions import SSLError
|
||||
from tornado import gen
|
||||
|
||||
@@ -15,6 +16,9 @@ from .utils import async_requests
|
||||
|
||||
ssl_enabled = True
|
||||
|
||||
# possible errors raised by ssl failures
|
||||
SSL_ERROR = (SSLError, ConnectionError)
|
||||
|
||||
|
||||
@gen.coroutine
|
||||
def wait_for_spawner(spawner, timeout=10):
|
||||
@@ -41,7 +45,7 @@ def wait_for_spawner(spawner, timeout=10):
|
||||
|
||||
async def test_connection_hub_wrong_certs(app):
|
||||
"""Connecting to the internal hub url fails without correct certs"""
|
||||
with pytest.raises(SSLError):
|
||||
with pytest.raises(SSL_ERROR):
|
||||
kwargs = {'verify': False}
|
||||
r = await async_requests.get(app.hub.url, **kwargs)
|
||||
r.raise_for_status()
|
||||
@@ -49,7 +53,7 @@ async def test_connection_hub_wrong_certs(app):
|
||||
|
||||
async def test_connection_proxy_api_wrong_certs(app):
|
||||
"""Connecting to the proxy api fails without correct certs"""
|
||||
with pytest.raises(SSLError):
|
||||
with pytest.raises(SSL_ERROR):
|
||||
kwargs = {'verify': False}
|
||||
r = await async_requests.get(app.proxy.api_url, **kwargs)
|
||||
r.raise_for_status()
|
||||
@@ -68,7 +72,7 @@ async def test_connection_notebook_wrong_certs(app):
|
||||
status = await spawner.poll()
|
||||
assert status is None
|
||||
|
||||
with pytest.raises(SSLError):
|
||||
with pytest.raises(SSL_ERROR):
|
||||
kwargs = {'verify': False}
|
||||
r = await async_requests.get(spawner.server.url, **kwargs)
|
||||
r.raise_for_status()
|
||||
|
@@ -1,6 +1,8 @@
|
||||
"""Tests for named servers"""
|
||||
import asyncio
|
||||
import json
|
||||
from unittest import mock
|
||||
from urllib.parse import urlencode
|
||||
from urllib.parse import urlparse
|
||||
|
||||
import pytest
|
||||
@@ -27,6 +29,17 @@ def named_servers(app):
|
||||
yield
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def default_server_name(app, named_servers):
|
||||
"""configure app to use a default server name"""
|
||||
server_name = 'myserver'
|
||||
try:
|
||||
app.default_server_name = server_name
|
||||
yield server_name
|
||||
finally:
|
||||
app.default_server_name = ''
|
||||
|
||||
|
||||
async def test_default_server(app, named_servers):
|
||||
"""Test the default /users/:user/server handler when named servers are enabled"""
|
||||
username = 'rosie'
|
||||
@@ -57,6 +70,7 @@ async def test_default_server(app, named_servers):
|
||||
username
|
||||
),
|
||||
'state': {'pid': 0},
|
||||
'user_options': {},
|
||||
}
|
||||
},
|
||||
}
|
||||
@@ -116,6 +130,7 @@ async def test_create_named_server(app, named_servers):
|
||||
username, servername
|
||||
),
|
||||
'state': {'pid': 0},
|
||||
'user_options': {},
|
||||
}
|
||||
for name in [servername]
|
||||
},
|
||||
@@ -232,7 +247,7 @@ async def test_named_server_limit(app, named_servers):
|
||||
assert r.text == ''
|
||||
|
||||
|
||||
async def test_named_server_spawn_form(app, username):
|
||||
async def test_named_server_spawn_form(app, username, named_servers):
|
||||
server_name = "myserver"
|
||||
base_url = public_url(app)
|
||||
cookies = await app.login_user(username)
|
||||
@@ -265,3 +280,91 @@ async def test_named_server_spawn_form(app, username):
|
||||
assert server_name in user.spawners
|
||||
spawner = user.spawners[server_name]
|
||||
spawner.user_options == {'energy': '938MeV', 'bounds': [-10, 10], 'notspecified': 5}
|
||||
|
||||
|
||||
async def test_user_redirect_default_server_name(
|
||||
app, username, named_servers, default_server_name
|
||||
):
|
||||
name = username
|
||||
server_name = default_server_name
|
||||
cookies = await app.login_user(name)
|
||||
|
||||
r = await api_request(app, 'users', username, 'servers', server_name, method='post')
|
||||
r.raise_for_status()
|
||||
assert r.status_code == 201
|
||||
assert r.text == ''
|
||||
|
||||
r = await get_page('/user-redirect/tree/top/', app)
|
||||
r.raise_for_status()
|
||||
print(urlparse(r.url))
|
||||
path = urlparse(r.url).path
|
||||
assert path == url_path_join(app.base_url, '/hub/login')
|
||||
query = urlparse(r.url).query
|
||||
assert query == urlencode(
|
||||
{'next': url_path_join(app.hub.base_url, '/user-redirect/tree/top/')}
|
||||
)
|
||||
|
||||
r = await get_page('/user-redirect/notebooks/test.ipynb', app, cookies=cookies)
|
||||
r.raise_for_status()
|
||||
print(urlparse(r.url))
|
||||
path = urlparse(r.url).path
|
||||
while '/spawn-pending/' in path:
|
||||
await asyncio.sleep(0.1)
|
||||
r = await async_requests.get(r.url, cookies=cookies)
|
||||
path = urlparse(r.url).path
|
||||
assert path == url_path_join(
|
||||
app.base_url, '/user/{}/{}/notebooks/test.ipynb'.format(name, server_name)
|
||||
)
|
||||
|
||||
|
||||
async def test_user_redirect_hook_default_server_name(
|
||||
app, username, named_servers, default_server_name
|
||||
):
|
||||
"""
|
||||
Test proper behavior of user_redirect_hook when c.JupyterHub.default_server_name is set
|
||||
"""
|
||||
name = username
|
||||
server_name = default_server_name
|
||||
cookies = await app.login_user(name)
|
||||
|
||||
r = await api_request(app, 'users', username, 'servers', server_name, method='post')
|
||||
r.raise_for_status()
|
||||
assert r.status_code == 201
|
||||
assert r.text == ''
|
||||
|
||||
async def dummy_redirect(path, request, user, base_url):
|
||||
assert base_url == app.base_url
|
||||
assert path == 'redirect-to-terminal'
|
||||
assert request.uri == url_path_join(
|
||||
base_url, 'hub', 'user-redirect', 'redirect-to-terminal'
|
||||
)
|
||||
# exclude custom server_name
|
||||
# custom hook is respected exactly
|
||||
url = url_path_join(user.url, '/terminals/1')
|
||||
return url
|
||||
|
||||
app.user_redirect_hook = dummy_redirect
|
||||
|
||||
r = await get_page('/user-redirect/redirect-to-terminal', app)
|
||||
r.raise_for_status()
|
||||
print(urlparse(r.url))
|
||||
path = urlparse(r.url).path
|
||||
assert path == url_path_join(app.base_url, '/hub/login')
|
||||
query = urlparse(r.url).query
|
||||
assert query == urlencode(
|
||||
{'next': url_path_join(app.hub.base_url, '/user-redirect/redirect-to-terminal')}
|
||||
)
|
||||
|
||||
# We don't actually want to start the server by going through spawn - just want to make sure
|
||||
# the redirect is to the right place
|
||||
r = await get_page(
|
||||
'/user-redirect/redirect-to-terminal',
|
||||
app,
|
||||
cookies=cookies,
|
||||
allow_redirects=False,
|
||||
)
|
||||
r.raise_for_status()
|
||||
redirected_url = urlparse(r.headers['Location'])
|
||||
assert redirected_url.path == url_path_join(
|
||||
app.base_url, 'user', username, 'terminals/1'
|
||||
)
|
||||
|
@@ -74,6 +74,16 @@ def test_user(db):
|
||||
assert found is None
|
||||
|
||||
|
||||
def test_user_escaping(db):
|
||||
orm_user = orm.User(name='company\\user@company.com,\"quoted\"')
|
||||
db.add(orm_user)
|
||||
db.commit()
|
||||
user = User(orm_user)
|
||||
assert user.name == 'company\\user@company.com,\"quoted\"'
|
||||
assert user.escaped_name == 'company%5Cuser@company.com%2C%22quoted%22'
|
||||
assert user.json_escaped_name == 'company\\\\user@company.com,\\\"quoted\\\"'
|
||||
|
||||
|
||||
def test_tokens(db):
|
||||
user = orm.User(name='inara')
|
||||
db.add(user)
|
||||
|
@@ -92,8 +92,9 @@ async def test_home_auth(app):
|
||||
|
||||
|
||||
async def test_admin_no_auth(app):
|
||||
r = await get_page('admin', app)
|
||||
assert r.status_code == 403
|
||||
r = await get_page('admin', app, allow_redirects=False)
|
||||
assert r.status_code == 302
|
||||
assert '/hub/login' in r.headers['Location']
|
||||
|
||||
|
||||
async def test_admin_not_admin(app):
|
||||
@@ -109,6 +110,13 @@ async def test_admin(app):
|
||||
assert r.url.endswith('/admin')
|
||||
|
||||
|
||||
async def test_admin_version(app):
|
||||
cookies = await app.login_user('admin')
|
||||
r = await get_page('admin', app, cookies=cookies, allow_redirects=False)
|
||||
r.raise_for_status()
|
||||
assert "version_footer" in r.text
|
||||
|
||||
|
||||
@pytest.mark.parametrize('sort', ['running', 'last_activity', 'admin', 'name'])
|
||||
async def test_admin_sort(app, sort):
|
||||
cookies = await app.login_user('admin')
|
||||
@@ -393,11 +401,52 @@ async def test_user_redirect(app, username):
|
||||
path = urlparse(r.url).path
|
||||
while '/spawn-pending/' in path:
|
||||
await asyncio.sleep(0.1)
|
||||
r = await get_page(r.url, app, cookies=cookies)
|
||||
r = await async_requests.get(r.url, cookies=cookies)
|
||||
path = urlparse(r.url).path
|
||||
assert path == ujoin(app.base_url, '/user/%s/notebooks/test.ipynb' % name)
|
||||
|
||||
|
||||
async def test_user_redirect_hook(app, username):
|
||||
"""
|
||||
Test proper behavior of user_redirect_hook
|
||||
"""
|
||||
name = username
|
||||
cookies = await app.login_user(name)
|
||||
|
||||
async def dummy_redirect(path, request, user, base_url):
|
||||
assert base_url == app.base_url
|
||||
assert path == 'redirect-to-terminal'
|
||||
assert request.uri == ujoin(
|
||||
base_url, 'hub', 'user-redirect', 'redirect-to-terminal'
|
||||
)
|
||||
url = ujoin(user.url, '/terminals/1')
|
||||
return url
|
||||
|
||||
app.user_redirect_hook = dummy_redirect
|
||||
|
||||
r = await get_page('/user-redirect/redirect-to-terminal', app)
|
||||
r.raise_for_status()
|
||||
print(urlparse(r.url))
|
||||
path = urlparse(r.url).path
|
||||
assert path == ujoin(app.base_url, '/hub/login')
|
||||
query = urlparse(r.url).query
|
||||
assert query == urlencode(
|
||||
{'next': ujoin(app.hub.base_url, '/user-redirect/redirect-to-terminal')}
|
||||
)
|
||||
|
||||
# We don't actually want to start the server by going through spawn - just want to make sure
|
||||
# the redirect is to the right place
|
||||
r = await get_page(
|
||||
'/user-redirect/redirect-to-terminal',
|
||||
app,
|
||||
cookies=cookies,
|
||||
allow_redirects=False,
|
||||
)
|
||||
r.raise_for_status()
|
||||
redirected_url = urlparse(r.headers['Location'])
|
||||
assert redirected_url.path == ujoin(app.base_url, 'user', username, 'terminals/1')
|
||||
|
||||
|
||||
async def test_user_redirect_deprecated(app, username):
|
||||
"""redirecting from /user/someonelse/ URLs (deprecated)"""
|
||||
name = username
|
||||
@@ -611,7 +660,9 @@ async def test_static_files(app):
|
||||
r = await async_requests.get(ujoin(base_url, 'logo'))
|
||||
r.raise_for_status()
|
||||
assert r.headers['content-type'] == 'image/png'
|
||||
r = await async_requests.get(ujoin(base_url, 'static', 'images', 'jupyter.png'))
|
||||
r = await async_requests.get(
|
||||
ujoin(base_url, 'static', 'images', 'jupyterhub-80.png')
|
||||
)
|
||||
r.raise_for_status()
|
||||
assert r.headers['content-type'] == 'image/png'
|
||||
r = await async_requests.get(ujoin(base_url, 'static', 'css', 'style.min.css'))
|
||||
@@ -787,3 +838,42 @@ async def test_metrics_auth(app):
|
||||
async def test_health_check_request(app):
|
||||
r = await get_page('health', app)
|
||||
assert r.status_code == 200
|
||||
|
||||
|
||||
async def test_pre_spawn_start_exc_no_form(app):
|
||||
exc = "pre_spawn_start error"
|
||||
|
||||
# throw exception from pre_spawn_start
|
||||
@gen.coroutine
|
||||
def mock_pre_spawn_start(user, spawner):
|
||||
raise Exception(exc)
|
||||
|
||||
with mock.patch.object(app.authenticator, 'pre_spawn_start', mock_pre_spawn_start):
|
||||
cookies = await app.login_user('summer')
|
||||
# spawn page should thow a 500 error and show the pre_spawn_start error message
|
||||
r = await get_page('spawn', app, cookies=cookies)
|
||||
assert r.status_code == 500
|
||||
assert exc in r.text
|
||||
|
||||
|
||||
async def test_pre_spawn_start_exc_options_form(app):
|
||||
exc = "pre_spawn_start error"
|
||||
|
||||
# throw exception from pre_spawn_start
|
||||
@gen.coroutine
|
||||
def mock_pre_spawn_start(user, spawner):
|
||||
raise Exception(exc)
|
||||
|
||||
with mock.patch.dict(
|
||||
app.users.settings, {'spawner_class': FormSpawner}
|
||||
), mock.patch.object(app.authenticator, 'pre_spawn_start', mock_pre_spawn_start):
|
||||
cookies = await app.login_user('spring')
|
||||
user = app.users['spring']
|
||||
# spawn page shouldn't throw any error until the spawn is started
|
||||
r = await get_page('spawn', app, cookies=cookies)
|
||||
assert r.url.endswith('/spawn')
|
||||
r.raise_for_status()
|
||||
assert FormSpawner.options_form in r.text
|
||||
# spawning the user server should throw the pre_spawn_start error
|
||||
with pytest.raises(Exception, match="%s" % exc):
|
||||
await user.spawn()
|
||||
|
@@ -76,7 +76,8 @@ async def test_spawner(db, request):
|
||||
assert status is None
|
||||
await spawner.stop()
|
||||
status = await spawner.poll()
|
||||
assert status == 1
|
||||
assert status is not None
|
||||
assert isinstance(status, int)
|
||||
|
||||
|
||||
async def wait_for_spawner(spawner, timeout=10):
|
||||
|
@@ -159,6 +159,10 @@ async def api_request(
|
||||
|
||||
|
||||
def get_page(path, app, hub=True, **kw):
|
||||
if "://" in path:
|
||||
raise ValueError(
|
||||
"Not a hub page path: %r. Did you mean async_requests.get?" % path
|
||||
)
|
||||
if hub:
|
||||
prefix = app.hub.base_url
|
||||
else:
|
||||
|
@@ -1,5 +1,6 @@
|
||||
# Copyright (c) Jupyter Development Team.
|
||||
# Distributed under the terms of the Modified BSD License.
|
||||
import json
|
||||
import warnings
|
||||
from collections import defaultdict
|
||||
from datetime import datetime
|
||||
@@ -21,6 +22,7 @@ from .crypto import decrypt
|
||||
from .crypto import encrypt
|
||||
from .crypto import EncryptionUnavailable
|
||||
from .crypto import InvalidToken
|
||||
from .metrics import RUNNING_SERVERS
|
||||
from .metrics import TOTAL_USERS
|
||||
from .objects import Server
|
||||
from .spawner import LocalProcessSpawner
|
||||
@@ -349,6 +351,11 @@ class User:
|
||||
"""My name, escaped for use in URLs, cookies, etc."""
|
||||
return quote(self.name, safe='@~')
|
||||
|
||||
@property
|
||||
def json_escaped_name(self):
|
||||
"""The user name, escaped for use in javascript inserts, etc."""
|
||||
return json.dumps(self.name)[1:-1]
|
||||
|
||||
@property
|
||||
def proxy_spec(self):
|
||||
"""The proxy routespec for my default server"""
|
||||
@@ -522,17 +529,24 @@ class User:
|
||||
|
||||
# trigger pre-spawn hook on authenticator
|
||||
authenticator = self.authenticator
|
||||
if authenticator:
|
||||
await maybe_future(authenticator.pre_spawn_start(self, spawner))
|
||||
|
||||
spawner._start_pending = True
|
||||
# update spawner start time, and activity for both spawner and user
|
||||
self.last_activity = (
|
||||
spawner.orm_spawner.started
|
||||
) = spawner.orm_spawner.last_activity = datetime.utcnow()
|
||||
db.commit()
|
||||
# wait for spawner.start to return
|
||||
try:
|
||||
spawner._start_pending = True
|
||||
|
||||
if authenticator:
|
||||
# pre_spawn_start can thow errors that can lead to a redirect loop
|
||||
# if left uncaught (see https://github.com/jupyterhub/jupyterhub/issues/2683)
|
||||
await maybe_future(authenticator.pre_spawn_start(self, spawner))
|
||||
|
||||
# trigger auth_state hook
|
||||
auth_state = await self.get_auth_state()
|
||||
await spawner.run_auth_state_hook(auth_state)
|
||||
|
||||
# update spawner start time, and activity for both spawner and user
|
||||
self.last_activity = (
|
||||
spawner.orm_spawner.started
|
||||
) = spawner.orm_spawner.last_activity = datetime.utcnow()
|
||||
db.commit()
|
||||
# wait for spawner.start to return
|
||||
# run optional preparation work to bootstrap the notebook
|
||||
await maybe_future(spawner.run_pre_spawn_hook())
|
||||
if self.settings.get('internal_ssl'):
|
||||
@@ -718,6 +732,7 @@ class User:
|
||||
spawner = self.spawners[server_name]
|
||||
spawner._spawn_pending = False
|
||||
spawner._start_pending = False
|
||||
spawner._check_pending = False
|
||||
spawner.stop_polling()
|
||||
spawner._stop_pending = True
|
||||
|
||||
@@ -753,7 +768,9 @@ class User:
|
||||
self.db.delete(oauth_client)
|
||||
self.db.commit()
|
||||
self.log.debug("Finished stopping %s", spawner._log_name)
|
||||
RUNNING_SERVERS.dec()
|
||||
finally:
|
||||
spawner.server = None
|
||||
spawner.orm_spawner.started = None
|
||||
self.db.commit()
|
||||
# trigger post-stop hook
|
||||
|
@@ -1,12 +1,12 @@
|
||||
# JupyterHub Dockerfile that loads your jupyterhub_config.py
|
||||
#
|
||||
# Adds ONBUILD step to jupyter/jupyterhub to load your juptyerhub_config.py into the image
|
||||
# Adds ONBUILD step to jupyter/jupyterhub to load your jupyterhub_config.py into the image
|
||||
#
|
||||
# Derivative images must have jupyterhub_config.py next to the Dockerfile.
|
||||
|
||||
ARG BASE_IMAGE=jupyterhub/jupyterhub
|
||||
FROM ${BASE_IMAGE}
|
||||
ARG BASE_IMAGE=jupyterhub/jupyterhub:latest
|
||||
FROM $BASE_IMAGE
|
||||
|
||||
ONBUILD ADD jupyterhub_config.py /srv/jupyterhub/jupyterhub_config.py
|
||||
ONBUILD COPY jupyterhub_config.py /srv/jupyterhub/jupyterhub_config.py
|
||||
|
||||
CMD ["jupyterhub", "-f", "/srv/jupyterhub/jupyterhub_config.py"]
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
If you base a Dockerfile on this image:
|
||||
|
||||
FROM juptyerhub/jupyterhub-onbuild:0.6
|
||||
FROM jupyterhub/jupyterhub-onbuild:0.6
|
||||
...
|
||||
|
||||
then your `jupyterhub_config.py` adjacent to your Dockerfile will be loaded into the image and used by JupyterHub.
|
||||
|
@@ -3,9 +3,11 @@ async_generator>=1.8
|
||||
certipy>=0.1.2
|
||||
entrypoints
|
||||
jinja2
|
||||
jupyter_telemetry
|
||||
oauthlib>=3.0
|
||||
pamela
|
||||
prometheus_client>=0.0.21
|
||||
psutil>=5.6.5; sys_platform == 'win32'
|
||||
python-dateutil
|
||||
requests
|
||||
SQLAlchemy>=1.1
|
||||
|
2
setup.py
2
setup.py
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env python3
|
||||
# coding: utf-8
|
||||
# Copyright (c) Juptyer Development Team.
|
||||
# Copyright (c) Jupyter Development Team.
|
||||
# Distributed under the terms of the Modified BSD License.
|
||||
# -----------------------------------------------------------------------------
|
||||
# Minimal Python version sanity check (from IPython)
|
||||
|
@@ -1,7 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
"""Wrapper to run setup.py using setuptools."""
|
||||
# Import setuptools and call the actual setup
|
||||
import setuptools
|
||||
|
||||
with open('setup.py', 'rb') as f:
|
||||
exec(compile(f.read(), 'setup.py', 'exec'))
|
@@ -90,6 +90,7 @@ require(["jquery", "moment", "jhapi", "utils"], function(
|
||||
});
|
||||
api.stop_server(user, {
|
||||
success: function() {
|
||||
$("#stop").hide();
|
||||
$("#start")
|
||||
.text("Start My Server")
|
||||
.attr("title", "Start your default server")
|
||||
@@ -102,7 +103,12 @@ require(["jquery", "moment", "jhapi", "utils"], function(
|
||||
$(".new-server-btn").click(function() {
|
||||
var row = getRow($(this));
|
||||
var serverName = row.find(".new-server-name").val();
|
||||
window.location.href = "../spawn/" + user + "/" + serverName;
|
||||
if (serverName === "") {
|
||||
// ../spawn/user/ causes a 404, ../spawn/user redirects correctly to the default server
|
||||
window.location.href = "./spawn/" + user;
|
||||
} else {
|
||||
window.location.href = "./spawn/" + user + "/" + serverName;
|
||||
}
|
||||
});
|
||||
|
||||
$(".stop-server").click(stopServer);
|
||||
|
@@ -2,7 +2,7 @@
|
||||
// Original Copyright (c) IPython Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
|
||||
// Modifications Copyright (c) Juptyer Development Team.
|
||||
// Modifications Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
|
||||
define(["jquery"], function($) {
|
||||
|
@@ -1,3 +1,9 @@
|
||||
i.sort-icon {
|
||||
margin-left: 4px;
|
||||
}
|
||||
|
||||
.version_footer {
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
@@ -103,6 +103,11 @@
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="container-fluid navbar-default small version_footer">
|
||||
<div class="navbar-text">
|
||||
JupyterHub {{ server_version }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% call modal('Delete User', btn_class='btn-danger delete-button') %}
|
||||
Are you sure you want to delete user <span class="delete-username">USER</span>?
|
||||
|
@@ -4,7 +4,6 @@
|
||||
{% endif %}
|
||||
|
||||
{% block main %}
|
||||
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="text-center">
|
||||
@@ -83,7 +82,8 @@
|
||||
</tbody>
|
||||
</table>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
</div>
|
||||
{% endblock main %}
|
||||
|
||||
{% block script %}
|
||||
{{ super() }}
|
||||
|
@@ -34,9 +34,11 @@
|
||||
{% block stylesheet %}
|
||||
<link rel="stylesheet" href="{{ static_url("css/style.min.css") }}" type="text/css"/>
|
||||
{% endblock %}
|
||||
{% block scripts %}
|
||||
<script src="{{static_url("components/requirejs/require.js") }}" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="{{static_url("components/jquery/dist/jquery.min.js") }}" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="{{static_url("components/bootstrap/dist/js/bootstrap.min.js") }}" type="text/javascript" charset="utf-8"></script>
|
||||
{% endblock %}
|
||||
<script>
|
||||
require.config({
|
||||
{% if version_hash %}
|
||||
@@ -63,7 +65,7 @@
|
||||
base_url: "{{base_url}}",
|
||||
prefix: "{{prefix}}",
|
||||
{% if user %}
|
||||
user: "{{user.name}}",
|
||||
user: "{{user.json_escaped_name}}",
|
||||
{% endif %}
|
||||
{% if admin_access %}
|
||||
admin_access: true,
|
||||
@@ -118,6 +120,16 @@
|
||||
{% if user.admin %}
|
||||
<li><a href="{{base_url}}admin">Admin</a></li>
|
||||
{% endif %}
|
||||
{% if services %}
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Services<span class="caret"></span></a>
|
||||
<ul class="dropdown-menu">
|
||||
{% for service in services %}
|
||||
<li><a class="dropdown-item" href="{{service.prefix}}">{{service.name}}</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
@@ -148,7 +160,7 @@
|
||||
|
||||
{% block announcement %}
|
||||
{% if announcement %}
|
||||
<div class="container text-center announcement">
|
||||
<div class="container text-center announcement alert alert-warning">
|
||||
{{ announcement | safe }}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
@@ -8,7 +8,7 @@
|
||||
<div class="container">
|
||||
{% block heading %}
|
||||
<div class="row text-center">
|
||||
<h1>Spawner Options</h1>
|
||||
<h1>Server Options</h1>
|
||||
</div>
|
||||
{% endblock %}
|
||||
<div class="row col-sm-offset-2 col-sm-8">
|
||||
@@ -23,7 +23,7 @@
|
||||
<form enctype="multipart/form-data" id="spawn_form" action="{{url}}" method="post" role="form">
|
||||
{{spawner_options_form | safe}}
|
||||
<br>
|
||||
<input type="submit" value="Spawn" class="btn btn-jupyter form-control">
|
||||
<input type="submit" value="Start" class="btn btn-jupyter form-control">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -13,6 +13,6 @@ c.JupyterHub.authenticator_class = DummyAuthenticator
|
||||
# Optionally set a global password that all users must use
|
||||
# c.DummyAuthenticator.password = "your_password"
|
||||
|
||||
from jupyterhub.spawners import SimpleSpawner
|
||||
from jupyterhub.spawner import SimpleLocalProcessSpawner
|
||||
|
||||
c.JupyterHub.spawner_class = SimpleSpawner
|
||||
c.JupyterHub.spawner_class = SimpleLocalProcessSpawner
|
||||
|
Reference in New Issue
Block a user