Last active
December 20, 2017 14:57
-
-
Save minrk/ed7a0d81615e4f163e124e27e9b05c3d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
"""Script to check binder deployment status | |
checks: | |
- binderhub chart has latest hub chart | |
- mybinder has latest binderhub chart | |
- mybinder has latest repo2docker image | |
- mybinder prod is up-to-date with staging | |
""" | |
from operator import itemgetter | |
import requests | |
from ruamel.yaml import YAML | |
yaml = YAML(typ='safe') | |
# get helm-chart index (sorted by date) | |
r = requests.get('https://jupyterhub.github.io/helm-chart/index.yaml') | |
r.raise_for_status() | |
index = yaml.load(r.text) | |
# construct latest charts for each package, | |
# and key by version number for later lookup | |
latest = {} | |
all_charts = {} | |
for name, releases in index['entries'].items(): | |
all_charts[name] = charts = {} | |
for chart in releases: | |
charts[chart['version']] = chart | |
ordered = sorted(releases, key=itemgetter('created')) | |
latest[name] = ordered[-1] | |
def check_requirements(requirements, name, checking): | |
print(f"\nChecking version of {name} in {checking} requirements") | |
want = latest[name] | |
for req in requirements['dependencies']: | |
if req['name'] == name: | |
if req['version'] == want['version']: | |
print(f"{checking:10} has latest {name}-{req['version']} from {want['created']}") | |
else: | |
have = all_charts[name]['v' + req['version']] | |
print(f"{checking:10} has {name}-{have['version']:14} from {have['created']}") | |
print(f" latest is {name}-{want['version']:14} from {want['created']}") | |
return | |
print(f"Didn't find requirement {name} in {requirements}") | |
# check if binderhub has latest jupyterhub | |
r = requests.get('https://rawgithub.com/jupyterhub/binderhub/master/helm-chart/binderhub/requirements.yaml') | |
r.raise_for_status() | |
binder_requirements = yaml.load(r.text) | |
check_requirements(binder_requirements, name='jupyterhub', | |
checking='binderhub') | |
# check if mybinder has latest binderhub | |
r = requests.get('https://raw.githubusercontent.com/jupyterhub/mybinder.org-deploy/staging/mybinder/requirements.yaml') | |
r.raise_for_status() | |
mybinder_requirements = yaml.load(r.text) | |
check_requirements(mybinder_requirements, | |
name='binderhub', checking='mybinder') | |
# check that mybinder has latest repo2docker | |
print("\nChecking repo2docker tag in mybinder deployment") | |
r = requests.get('https://raw.githubusercontent.com/jupyterhub/mybinder.org-deploy/staging/mybinder/values.yaml') | |
r.raise_for_status() | |
values = yaml.load(r.text) | |
r2dimage, r2dtag = values['binderhub']['repo2dockerImage'].split(':') | |
r = requests.get(f'https://api.github.com/repos/jupyter/repo2docker/compare/{r2dtag}...master') | |
r.raise_for_status() | |
compare = r.json() | |
print(f"repo2docker master is {compare['ahead_by']} commits ahead of {r2dtag}") | |
# check that mybinder staging has deployed to prod | |
print("\nChecking mybinder staging and prod") | |
r = requests.get('https://api.github.com/repos/jupyterhub/mybinder.org-deploy/compare/prod...staging') | |
r.raise_for_status() | |
compare = r.json() | |
print(f"mybinder staging is {compare['ahead_by']} commits ahead of prod") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example output from right now, telling us that binderhub doesn't have the latest jupyterhub helm chart, but everything else is up to date