Skip to content

Instantly share code, notes, and snippets.

@rcthomas
Last active September 27, 2017 17:32
Show Gist options
  • Save rcthomas/760fe8efd2f2b108cbc5911dd5e85149 to your computer and use it in GitHub Desktop.
Save rcthomas/760fe8efd2f2b108cbc5911dd5e85149 to your computer and use it in GitHub Desktop.
Dockerfile for wrapspawner issue
FROM ubuntu:16.04
MAINTAINER Rollin Thomas <rcthomas@lbl.gov>
# Base Ubuntu packages
ENV DEBIAN_FRONTEND noninteractive
ENV LANG C.UTF-8
RUN \
apt-get update && \
apt-get --yes upgrade && \
apt-get --yes install \
bzip2 \
curl \
git \
libffi-dev \
lsb-release \
tzdata \
vim \
wget
# Python 3 Miniconda and dependencies for JupyterHub we can get via conda
RUN \
wget -q -O /tmp/miniconda3.sh https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh && \
bash /tmp/miniconda3.sh -f -b -p /opt/anaconda3 && \
rm -rf /tmp/anaconda3.sh && \
/opt/anaconda3/bin/conda update --yes conda && \
/opt/anaconda3/bin/conda install --yes \
decorator \
jinja2 \
mako \
markupsafe \
nodejs \
notebook \
pyopenssl \
python-dateutil \
sqlalchemy \
tornado \
traitlets
# Install JupyterHub
ENV PATH=/opt/anaconda3/bin:$PATH
WORKDIR /tmp
RUN \
npm install -g configurable-http-proxy && \
git clone https://github.com/jupyterhub/jupyterhub.git && \
cd jupyterhub && \
git checkout tags/0.8.0rc1 && \
/opt/anaconda3/bin/python setup.py js && \
/opt/anaconda3/bin/pip install . && \
rm -rf ~/.cache ~/.npm
# Note this is coming from our fork at NERSC, see this issue I filed last week:
# https://github.com/jupyterhub/wrapspawner/issues/10
RUN \
pip install git+https://github.com/NERSC/wrapspawner@non-fatal-if-no-db
WORKDIR /srv/
EXPOSE 8000
LABEL org.jupyter.service="jupyterhub"
RUN \
adduser --gecos "" --disabled-password ernest && \
echo ernest:cyclotron | chpasswd
ADD jupyterhub_config.py /srv/jupyterhub_config.py
CMD ["jupyterhub", "--debug"]
#c.JupyterHub.spawner_class = 'jupyterhub.spawner.LocalProcessSpawner'
c.JupyterHub.spawner_class = 'wrapspawner.ProfilesSpawner'
c.ProfilesSpawner.profiles = [
('Local Process', 'local_process', 'jupyterhub.spawner.LocalProcessSpawner', {'ip':'0.0.0.0'}),
]

Instructions to reproduce.

[1] Grab the Dockerfile and jupyterhub_config.py files and put them in a directory.

[2] Then do:

docker build -t wrapspawner-issue .
docker run -p 0.0.0.0:8000:8000 -p 0.0.0.0:8081:8081 wrapspawner-issue:latest

[3] Start a web browser, point at http://localhost:8000/

[4] Log in, see Dockerfile.

[5] Start server.

[6] Select local process spawner option from form.

[7] In the log you should see this error for instance:

[D 2017-09-27 16:39:08.463 JupyterHub base:420] Initiating spawn for ernest
[I 2017-09-27 16:39:08.585 JupyterHub spawner:978] Spawning jupyterhub-singleuser '--ip="0.0.0.0"' --port=50583
[D 2017-09-27 16:39:08.601 JupyterHub spawner:727] Polling subprocess every 30s
[D 2017-09-27 16:39:08.644 JupyterHub base:426] 0/100 concurrent spawns
[D 2017-09-27 16:39:08.645 JupyterHub base:429] 0 active servers
Traceback (most recent call last):
  File "/opt/anaconda3/lib/python3.6/site-packages/traitlets/traitlets.py", line 528, in get
    value = obj._trait_values[self.name]
KeyError: 'oauth_client_id'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/anaconda3/bin/jupyterhub-singleuser", line 6, in <module>
    main()
  File "/opt/anaconda3/lib/python3.6/site-packages/jupyterhub/singleuser.py", line 455, in main
    return SingleUserNotebookApp.launch_instance(argv)
  File "/opt/anaconda3/lib/python3.6/site-packages/jupyter_core/application.py", line 267, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "/opt/anaconda3/lib/python3.6/site-packages/traitlets/config/application.py", line 657, in launch_instance
    app.initialize(argv)
  File "<decorator-gen-7>", line 2, in initialize
  File "/opt/anaconda3/lib/python3.6/site-packages/traitlets/config/application.py", line 87, in catch_config_error
    return method(app, *args, **kwargs)
  File "/opt/anaconda3/lib/python3.6/site-packages/notebook/notebookapp.py", line 1296, in initialize
    self.init_webapp()
  File "/opt/anaconda3/lib/python3.6/site-packages/jupyterhub/singleuser.py", line 393, in init_webapp
    self.init_hub_auth()
  File "/opt/anaconda3/lib/python3.6/site-packages/jupyterhub/singleuser.py", line 388, in init_hub_auth
    if not self.hub_auth.oauth_client_id:
  File "/opt/anaconda3/lib/python3.6/site-packages/traitlets/traitlets.py", line 556, in __get__
    return self.get(obj, cls)
  File "/opt/anaconda3/lib/python3.6/site-packages/traitlets/traitlets.py", line 535, in get
value = self._validate(obj, dynamic_default())
  File "/opt/anaconda3/lib/python3.6/site-packages/traitlets/traitlets.py", line 593, in _validate
    value = self._cross_validate(obj, value)
  File "/opt/anaconda3/lib/python3.6/site-packages/traitlets/traitlets.py", line 599, in _cross_validate
    value = obj._trait_validators[self.name](obj, proposal)
  File "/opt/anaconda3/lib/python3.6/site-packages/traitlets/traitlets.py", line 907, in __call__
    return self.func(*args, **kwargs)
  File "/opt/anaconda3/lib/python3.6/site-packages/jupyterhub/services/auth.py", line 437, in _ensure_not_empty
    raise ValueError("%s cannot be empty." % proposal.trait.name)
ValueError: oauth_client_id cannot be empty.

[8] Go back to the jupyterhub_config.py, swap the spawner_class to LocalProcessSpawner and rebuild, restart. This works fine. This suggests something with wrapspawner/profilespawner is happening that with 0.8.0 ends up trying to register a service?

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