Provide better error message when running on unsupported distro

This commit is contained in:
yuvipanda
2018-10-30 20:08:47 -07:00
parent 1d23c3fa2e
commit 5374f5eaf5
4 changed files with 61 additions and 4 deletions

View File

@@ -57,7 +57,7 @@ jobs:
- run: - run:
name: setup python3 name: setup python3
command: | command: |
apk add --no-cache python3 apk add --no-cache python3 pytest
- checkout - checkout
- setup_remote_docker - setup_remote_docker
@@ -79,6 +79,12 @@ jobs:
--installer-args "--plugin /srv/src/integration-tests/plugins/simplest" \ --installer-args "--plugin /srv/src/integration-tests/plugins/simplest" \
plugins test_simplest_plugin.py plugins test_simplest_plugin.py
- run:
name: Run distro check test
command: |
py.test integration-tests/test_distro.py
documentation: documentation:
docker: docker:

View File

@@ -8,15 +8,24 @@ This script is run as:
curl <script-url> | sudo python3 - curl <script-url> | sudo python3 -
Constraints: Constraints:
- Be compatible with Python 3.4 (since we support Ubuntu 16.04) - Entire script should be compatible with Python 3.6 (We run on Ubuntu 18.04+)
- Script should parse in Python 3.4 (since we exit with useful error message on Ubuntu 14.04+)
- Use stdlib modules only - Use stdlib modules only
""" """
import os import os
import subprocess import subprocess
import sys import sys
import logging import logging
import platform
# Support only Ubuntu 18.04+
distro, version, _ = platform.linux_distribution()
if distro != 'Ubuntu':
print('The Littlest JupyterHub currently supports Ubuntu Linux only')
sys.exit(1)
elif float(version) < 18.04:
print('The Littlest JupyterHub requires Ubuntu 18.04 or higher')
sys.exit(1)
def main(): def main():
install_prefix = os.environ.get('TLJH_INSTALL_PREFIX', '/opt/tljh') install_prefix = os.environ.get('TLJH_INSTALL_PREFIX', '/opt/tljh')

View File

@@ -6,6 +6,7 @@ A simple `JupyterHub <https://github.com/jupyterhub/jupyterhub>`_ distribution f
a small (0-100) number of users on a single server. We recommend reading a small (0-100) number of users on a single server. We recommend reading
:ref:`topic/whentouse` to determine if this is the right tool for you. :ref:`topic/whentouse` to determine if this is the right tool for you.
Development Status Development Status
================== ==================
@@ -18,7 +19,8 @@ Installation
============ ============
The Littlest JupyterHub (TLJH) can run on any server that is running at least The Littlest JupyterHub (TLJH) can run on any server that is running at least
Ubuntu 18.04. We have a bunch of tutorials to get you started. **Ubuntu 18.04**. Earlier versions of Ubuntu are not supported.
We have a bunch of tutorials to get you started.
- Tutorials to create a new server from scratch on a cloud provider & run TLJH - Tutorials to create a new server from scratch on a cloud provider & run TLJH
on it. These are **recommended** if you do not have much experience setting up on it. These are **recommended** if you do not have much experience setting up

View File

@@ -0,0 +1,40 @@
"""
Test running on non-supported distros
"""
import subprocess
def test_ubuntu_too_old():
container_name = 'old-distro-test'
# stop container if it is already running
subprocess.run([
'docker', 'rm', '-f', container_name
])
# Start a detached Ubuntu 16.04 container
subprocess.check_call([
'docker', 'run', '--detach', '--name', container_name, 'ubuntu:16.04',
'/bin/bash', '-c', 'sleep 1000s'
])
# Install python3 inside the ubuntu container
# There is no trusted Ubuntu+Python3 container we can use
subprocess.check_output([
'docker', 'exec', container_name, 'apt-get', 'update'
])
subprocess.check_output([
'docker', 'exec', container_name, 'apt-get', 'install', '--yes', 'python3'
])
# Copy only the bootstrap script to container, so this is faster
subprocess.check_call([
'docker',
'cp',
'bootstrap/', f'{container_name}:/srv'
])
# Run bootstrap script, validate that it fails appropriately
output = subprocess.run([
'docker', 'exec', '-i', container_name,
'python3', '/srv/bootstrap/bootstrap.py'
], check=False, stdout=subprocess.PIPE, encoding='utf-8')
assert output.stdout == 'The Littlest JupyterHub requires Ubuntu 18.04 or higher\n'
assert output.returncode == 1