Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merging 6034/6035/6040/6041/6043/6044/6045/6046 to prod #6042

Merged
merged 29 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
8dbc0c6
Add admins for workshop hub
balajialg Aug 27, 2024
6fd9cb1
script and workflow to get deployments from deployments/ subdir
shaneknapp Aug 27, 2024
d931fa1
forgot about staging
shaneknapp Aug 27, 2024
ac0f289
newline at EOF
shaneknapp Aug 27, 2024
84f6b64
docstring ftw
shaneknapp Aug 27, 2024
c888a45
must remember: double quotes, not single. double quotes, not single…
shaneknapp Aug 27, 2024
d462e9a
formatting
shaneknapp Aug 27, 2024
88fbf92
python really helps clean things up
shaneknapp Aug 28, 2024
f9ad125
add arg to allow us to limit hub deployments to only specific ones
shaneknapp Aug 28, 2024
ddacff1
seriously hating bash
shaneknapp Aug 28, 2024
739c19a
reformat comments to be a bit more clear
shaneknapp Aug 28, 2024
8d31b03
more explainy comments
shaneknapp Aug 28, 2024
132acfa
grammarizing the crap out of comments
shaneknapp Aug 28, 2024
9f64914
might as well explicitly call python to execute these scripts... can…
shaneknapp Aug 28, 2024
375e804
Merge pull request #6034 from balajialg/wshop_hub
balajialg Aug 28, 2024
a7b591a
bashenannigans
shaneknapp Aug 28, 2024
84d5248
Merge pull request #6035 from shaneknapp/python-scripts-replace-bash
shaneknapp Aug 28, 2024
42be9af
fixing bash conditionals... again
shaneknapp Aug 28, 2024
37fada0
Merge pull request #6040 from shaneknapp/fixing-stupid-bash-redux-red…
felder Aug 28, 2024
9451616
bumping datahub placeholders to 2
shaneknapp Aug 28, 2024
293f365
Merge pull request #6041 from shaneknapp/bump-datahub-placeholders
shaneknapp Aug 28, 2024
28de8e1
testing for logodev
shaneknapp Aug 29, 2024
35c3143
Merge pull request #6043 from shaneknapp/testing-cicd-logodev
shaneknapp Aug 29, 2024
d3c6164
update logodev image tag to cb7832b0a131: deployments/logodev/hubploy…
Aug 29, 2024
d77c68d
Merge pull request #6044 from berkeley-dsep-infra/update-logodev-imag…
shaneknapp Aug 29, 2024
5dea919
fix positional args for hubploy
shaneknapp Aug 29, 2024
0490202
Merge pull request #6045 from shaneknapp/fix-positional-args-hubploy
shaneknapp Aug 29, 2024
123963d
adding timeout to hubploy
shaneknapp Aug 29, 2024
c44a8b5
Merge pull request #6046 from shaneknapp/add-timeout-to-hubploy
shaneknapp Aug 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions .github/scripts/determine-hub-deployments.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#! /usr/bin/env python
"""
Check the Github environment variables for hub deployments and determine if we
will deploy all hubs or just a subset.

All hubs will be deployed if the environment variable
GITHUB_PR_LABEL_JUPYTERHUB_DEPLOYMENT or GITHUB_PR_LABEL_HUB_IMAGES is set.

Otherwise, the environment variables GITHUB_PR_LABEL_HUB_<HUB_NAME> will be
checked to determine which hubs to deploy.

If no hubs need deploying, nothing will be emitted.
"""
import argparse
import os

def main(args):
hubs = []

# Deploy all hubs by getting deployment names from the dirs in deployments/
if (
"GITHUB_PR_LABEL_JUPYTERHUB_DEPLOYMENT" or
"GITHUB_PR_LABEL_HUB_IMAGES"
) in os.environ.keys():
for deployment in next(os.walk(args.deployments))[1]:
if deployment not in args.ignore:
hubs.append(deployment)

# Deploy only the modified/flagged hubs by PR labels
else:
hub_labels = [
k.lower() for k in os.environ.keys()
if k.startswith("GITHUB_PR_LABEL_HUB_")
]
hubs = [x.split("_")[-1] for x in hub_labels]
hubs = [x for x in hubs if x not in args.ignore]

hubs.sort()
for h in hubs:
if args.only_deploy and h not in args.only_deploy:
continue
print(h)

if __name__ == "__main__":
parser = argparse.ArgumentParser(
description="Get hubs that need to be deployed from environment variables."
)
parser.add_argument(
"--deployments",
"-d",
default="deployments",
help="The directory to search for deployments."
)
parser.add_argument(
"--ignore",
"-i",
nargs="*",
default=["template"],
help="Ignore one or more deployment targets."
)
parser.add_argument(
"--only-deploy",
"-o",
nargs="*",
help="Only deploy the specified hubs."
)
args = parser.parse_args()

main(args)
189 changes: 0 additions & 189 deletions .github/workflows/deploy-all-hubs.yaml

This file was deleted.

66 changes: 30 additions & 36 deletions .github/workflows/deploy-hubs.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
# this workflow re-deploys SPECIFIC hubs to staging or prod if the single-user
# server image or config has changed based on the PR labels "hub: <hubname>".
#
# however, this workflow will be not run if the PR labels of "hub-images" or
# "jupyterhub-deployment" are present, as these labels will trigger the
# "deploy-jupyterhub-base-images.yaml" workflow which re-deploys every hub.
# This workflow will determine if the base hub image and/or single-user server
# image for any or all hubs has has changed, and if so, deploy accordingly.
#
name: Deploy staging and prod hubs
on:
Expand All @@ -24,25 +20,24 @@ jobs:
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Pull out any hubs that need deploying from the labels on the merge commit to staging
- name: Check for hubs that need deploying from the labels on the merge commit to staging
run: |
echo "PR labels: ${{ steps.pr-labels.outputs.labels }}"
HUBS=()
# If the PR labels "hub-images" or "jupyterhub-deployment" are present, this
# means the base hub image has changed, and all hubs (staging or prod) need to
# be redeployed. The rest of this job will not run in that case.
if [ -c "${GITHUB_PR_LABEL_HUB_IMAGES}" ] || [ -c "${GITHUB_PR_LABEL_JUPYTERHUB_DEPLOYMENT}" ]; then
echo "Base hub image has changed, not deploying individual hubs to staging"
# If the PR labels "hub-images" or "jupyterhub-deployment" are
# present, this means the base hub image has changed, and all hubs
# (staging or prod) need to be redeployed.
#
if [[ -n ${GITHUB_PR_LABEL_HUB_IMAGES} || -n ${GITHUB_PR_LABEL_JUPYTERHUB_DEPLOYMENT} ]]; then
echo "DEPLOY=1" >> $GITHUB_ENV
# Otherwise, check to see if the PR labels contain any hubs, and
# deploy just those hubs to staging.
#
else
# deploy any hubs that have been labeled for deployment
for label in $(echo -e "${{ steps.pr-labels.outputs.labels }}"); do
if [[ "$label" == hub-* ]]; then
hub_name=$(echo $label | awk -F'-' '{print $2}')
HUBS+="$hub_name "
echo "DEPLOY=1" >> $GITHUB_ENV
fi
done
echo "DEPLOY_HUBS=${HUBS[@]}" >> $GITHUB_ENV
fi

- name: Check out the image repo
Expand Down Expand Up @@ -104,10 +99,10 @@ jobs:
- name: Deploy hubs to staging
if: ${{ env.DEPLOY }}
run: |
for hub in $(echo -e "${{ env.DEPLOY_HUBS }}"); do
echo "Deploying $hub to staging"
echo "hubploy --verbose deploy $hub hub staging"
done
while read deployment; do
echo "Pretending to deploy base hub image to ${deployment} :P"
hubploy --verbose deploy --timeout 30m ${deployment} hub staging
done < <(python .github/scripts/determine-hub-deployments.py --only-deploy logodev)

deploy-hubs-to-prod:
if: github.event_name == 'push' && github.ref == 'refs/heads/prod'
Expand All @@ -119,25 +114,24 @@ jobs:
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Pull out any hubs that need deploying from the labels on the merge commit to prod
- name: Check for hubs that need deploying from the labels on the merge commit to prod
run: |
echo "PR labels: ${{ steps.pr-labels.outputs.labels }}"
HUBS=()
# If the PR labels "hub-images" or "jupyterhub-deployment" are present, this
# means the base hub image has changed, and all hubs (staging or prod) need to
# be redeployed. The rest of this job will not run in that case.
if [ -c "${GITHUB_PR_LABEL_HUB_IMAGES}" ] || [ -c "${GITHUB_PR_LABEL_JUPYTERHUB_DEPLOYMENT}" ]; then
echo "Base hub image has changed, not deploying individual hubs to prod"
# If the PR labels "hub-images" or "jupyterhub-deployment" are
# present, this means the base hub image has changed, and all hubs
# (staging or prod) need to be redeployed.
#
if [[ -n ${GITHUB_PR_LABEL_HUB_IMAGES} || -n ${GITHUB_PR_LABEL_JUPYTERHUB_DEPLOYMENT} ]]; then
echo "DEPLOY=1" >> $GITHUB_ENV
# Otherwise, check to see if the PR labels contain any hubs, and
# deploy just those hubs to prod.
#
else
# deploy any hubs that have been labeled for deployment
for label in $(echo -e "${{ steps.pr-labels.outputs.labels }}"); do
if [[ "$label" == hub-* ]]; then
hub_name=$(echo $label | awk -F'-' '{print $2}')
HUBS+="$hub_name "
echo "DEPLOY=1" >> $GITHUB_ENV
fi
done
echo "DEPLOY_HUBS=${HUBS[@]}" >> $GITHUB_ENV
fi

- name: Check out the image repo
Expand Down Expand Up @@ -199,7 +193,7 @@ jobs:
- name: Deploy hubs to prod
if: ${{ env.DEPLOY }}
run: |
for hub in $(echo -e "${{ env.DEPLOY_HUBS }}"); do
echo "Deploying $hub to prod"
echo "hubploy --verbose deploy $hub hub prod"
done
while read deployment; do
echo "Pretending to deploy base hub image to ${deployment} :P"
hubploy --verbose deploy --timeout 30m ${deployment} hub prod
done < <(python .github/scripts/determine-hub-deployments.py --only-deploy logodev)
2 changes: 1 addition & 1 deletion deployments/logodev/hubploy.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
images:
images:
# temporary update
- name: us-central1-docker.pkg.dev/ucb-datahub-2018/user-images/logodev-user-image:c44b36bfede9
- name: us-central1-docker.pkg.dev/ucb-datahub-2018/user-images/logodev-user-image:cb7832b0a131

cluster:
provider: gcloud
Expand Down
8 changes: 8 additions & 0 deletions deployments/workshop/config/common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ jupyterhub:
JupyterHub:
admin_access: false
authenticator_class: dummy
Authenticator:
admin_users:
# infrastructure
- rylo
- sknapp
- felder
- balajialwar
- gmerritt
proxy:
chp:
nodeSelector:
Expand Down
Loading
Loading