Skip to content
This repository has been archived by the owner on Apr 29, 2021. It is now read-only.

Commit

Permalink
Merge pull request #59 from NERSC/19-04
Browse files Browse the repository at this point in the history
19 04
  • Loading branch information
rcthomas authored Apr 25, 2019
2 parents ccb3096 + b98e897 commit 88d17cf
Show file tree
Hide file tree
Showing 38 changed files with 57 additions and 15 deletions.
4 changes: 3 additions & 1 deletion jupyter-base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,13 @@ RUN \
/opt/anaconda3/bin/conda install --yes \
alembic \
decorator \
entrypoints \
jinja2 \
mako \
markupsafe \
nodejs \
oauthlib=2 \
pamela \
psycopg2 \
pyopenssl \
python-dateutil \
Expand All @@ -57,7 +60,6 @@ RUN \
npm install -g configurable-http-proxy && \
git clone https://github.com/jupyterhub/jupyterhub.git && \
cd jupyterhub && \
# git checkout tags/0.9.4 && \
/opt/anaconda3/bin/python setup.py js && \
/opt/anaconda3/bin/pip --no-cache-dir install . && \
cp examples/cull-idle/cull_idle_servers.py /opt/anaconda3/bin/. && \
Expand Down
2 changes: 1 addition & 1 deletion jupyter-base/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ branch=$(git symbolic-ref --short HEAD)

docker build \
--no-cache \
--tag registry.spin.nersc.gov/das/jupyter-base.$branch:latest .
--tag registry.spin.nersc.gov/das/jupyter-base-$branch:latest .
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ RUN \
echo "python 3.6.*" >> /opt/anaconda3/conda-meta/pinned && \
/opt/anaconda3/bin/conda update --yes conda && \
/opt/anaconda3/bin/pip install --no-cache-dir \
pika
pika==0.13.1

ENV PATH=/opt/anaconda3/bin:$PATH

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ branch=$(git symbolic-ref --short HEAD)

docker build \
"$@" \
--tag registry.spin.nersc.gov/das/jupyter-nersc-mods.$branch:latest .
--tag registry.spin.nersc.gov/das/app-monitoring.jupyter-nersc-$branch:latest .
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def parse_arguments():
parser.add_argument("--queue", "-q",
default="text")
parser.add_argument("--api-url", "-a",
default="http://web:8081/hub/api")
default="http://web-jupyterhub:8081/hub/api")
parser.add_argument("--api-token", "-o",
default=os.environ["MODS_JUPYTERHUB_API_TOKEN"])
parser.add_argument("--subcategory", "-s",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ARG branch=unknown

FROM registry.spin.nersc.gov/das/jupyter-base.${branch}:latest
FROM registry.spin.nersc.gov/das/jupyter-base-${branch}:latest
LABEL maintainer="Rollin Thomas <[email protected]>"
WORKDIR /srv

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ branch=$(git symbolic-ref --short HEAD)
docker build \
--build-arg branch=$branch \
"$@" \
--tag registry.spin.nersc.gov/das/jupyter-nersc-app.$branch:latest .
--tag registry.spin.nersc.gov/das/app-notebooks.jupyter-nersc-$branch:latest .
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ basemap
beautiful-soup
biopython
netcdf4
notebook=5.7.8
r-car
r-essentials
rpy2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ blaze
jupyter
jupyterlab
netcdf4
notebook=5.7.8
r-essentials
rpy2
scipy
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ARG branch=unknown

FROM registry.spin.nersc.gov/das/jupyter-base.${branch}:latest
FROM registry.spin.nersc.gov/das/jupyter-base-${branch}:latest
LABEL maintainer="Rollin Thomas <[email protected]>"
WORKDIR /srv

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ branch=$(git symbolic-ref --short HEAD)
docker build \
--build-arg branch=$branch \
"$@" \
--tag registry.spin.nersc.gov/das/jupyter-nersc-web.$branch:latest .
--tag registry.spin.nersc.gov/das/web-jupyterhub.jupyter-nersc-$branch:latest .
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

# Test user's ability to ssh

hostname=app
username=$1
hostname=$1
username=$2
cert=/certs/$username.key
echo $username $cert
if [ ! -f $cert ]; then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
import os
import sys

import asyncssh
import requests
from tornado import web
from jupyterhub.utils import url_path_join


def comma_split(string):
"""Handle env variables that may be None, empty string, or have spaces"""
Expand Down Expand Up @@ -183,7 +187,7 @@ def comma_split(string):

## url for the database. e.g. `sqlite:///jupyterhub.sqlite`
#c.JupyterHub.db_url = 'sqlite:///jupyterhub.sqlite'
c.JupyterHub.db_url = 'postgresql://jupyterhub:{}@db:5432/jupyterhub'.format(
c.JupyterHub.db_url = 'postgresql://jupyterhub:{}@db-jupyterhub:5432/jupyterhub'.format(
os.getenv('POSTGRES_PASSWORD')
)

Expand Down Expand Up @@ -388,7 +392,7 @@ def comma_split(string):
{
'name': 'cull-idle',
'admin': True,
'command': 'cull_idle_servers.py --timeout=43200'.split(),
'command': 'cull_idle_servers.py --timeout=86400'.split(),
},
{
'name': 'announcement',
Expand Down Expand Up @@ -1022,7 +1026,7 @@ def comma_split(string):
"sshspawner.sshspawner.SSHSpawner", {
"cmd": ["/global/common/cori/das/jupyterhub/jupyter-launcher.sh",
"/opt/anaconda3/bin/jupyter-labhub"],
"remote_hosts": ["app"],
"remote_hosts": ["app-notebooks"],
"remote_port_command": "/opt/anaconda3/bin/python /global/common/cori/das/jupyterhub/new-get-port.py --ip",
"hub_api_url": "http://{}:8081/hub/api".format(ip),
"path": "/opt/anaconda3/bin:/usr/bin:/usr/local/bin:/bin",
Expand All @@ -1031,6 +1035,40 @@ def comma_split(string):
)
}

# Pre-spawn myquota check

def space_error(home):
"""Extra message pointing users to try spawning again from /hub/home. """
home = url_path_join(home, 'home')
return ("There is insufficient space in your home directory; please clear up some files and then " +
"<a href='{home}'>navigate to the hub home</a> and start your server.".format(home=home))

async def setup(spawner):
username = spawner.user.name
remote_host = "corijupyter.nersc.gov"
# keyfile = spawner.ssh_keyfile.format(username=username)
keyfile = "/certs/{username}.key".format(username=username) # NEED to have in NERSCSpawner now
certfile = keyfile + "-cert.pub"
k = asyncssh.read_private_key(keyfile)
c = asyncssh.read_certificate(certfile)
# print(username, remote_host, keyfile, certfile)
async with asyncssh.connect(remote_host, username=username,
client_keys=[(k,c)], known_hosts=None) as conn:
home = "/global/homes/{}/{}".format(username[0], username)
result = await conn.run("myquota -c {}".format(home))
retcode = result.exit_status
# result = await conn.run(spawner.remote_port_command)
# remote_port = int(result.stdout)
if retcode:
e = web.HTTPError(507,reason="Insufficient Storage")
em = space_error(spawner.hub.base_url)
e.my_message = em
raise e
# spawner.remote_host = remote_host
# spawner.port = remote_port

# c.Spawner.pre_spawn_hook = setup

## c.NERSCSpawner.spawners = [
## ("spin", "sshspawner.sshspawner.SSHSpawner", {
## "remote_hosts" : ["jupyter"],
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ branch=$(git symbolic-ref --short HEAD)
docker build \
--build-arg branch=$branch \
"$@" \
--tag registry.spin.nersc.gov/das/jupyter-nersc-off.$branch:latest .
--tag registry.spin.nersc.gov/das/web-offline.jupyter-nersc-$branch:latest .

0 comments on commit 88d17cf

Please sign in to comment.