From 8dbc0c694a1defdcf4b069eb166315360e8591ef Mon Sep 17 00:00:00 2001 From: Balaji Alwar Date: Tue, 27 Aug 2024 16:06:56 -0700 Subject: [PATCH 01/21] Add admins for workshop hub --- deployments/workshop/config/common.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/deployments/workshop/config/common.yaml b/deployments/workshop/config/common.yaml index 1efc418de..02710f096 100644 --- a/deployments/workshop/config/common.yaml +++ b/deployments/workshop/config/common.yaml @@ -27,6 +27,14 @@ jupyterhub: JupyterHub: admin_access: false authenticator_class: dummy + Authenticator: + admin_users: + # infrastructure + - rylo + - sknapp + - felder + - balajialwar + - gmerritt proxy: chp: nodeSelector: From 6fd9cb1d8f34c64eae350cf610ee9a85d351e135 Mon Sep 17 00:00:00 2001 From: shane knapp Date: Tue, 27 Aug 2024 16:29:40 -0700 Subject: [PATCH 02/21] script and workflow to get deployments from deployments/ subdir --- .github/scripts/get-deployments.py | 29 ++++++++++++++++++++++++++ .github/workflows/deploy-all-hubs.yaml | 8 +------ 2 files changed, 30 insertions(+), 7 deletions(-) create mode 100755 .github/scripts/get-deployments.py diff --git a/.github/scripts/get-deployments.py b/.github/scripts/get-deployments.py new file mode 100755 index 000000000..b96ad2767 --- /dev/null +++ b/.github/scripts/get-deployments.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python + +import argparse +import os + +def main(args): + + for deployment in next(os.walk(args.deployments))[1]: + if deployment not in args.ignore: + print(deployment) + +if __name__ == '__main__': + parser = argparse.ArgumentParser(description='Generate a list of deployments from the deployments/ directory.') + parser.add_argument( + '--deployments', + '-d', + default='deployments', + help='The directory to search for deployments.' + ) + parser.add_argument( + '--ignore', + '-i', + nargs='*', + default=(), + help='Ignore one or more directories in the deployments/ subdir.' + ) + args = parser.parse_args() + + main(args) \ No newline at end of file diff --git a/.github/workflows/deploy-all-hubs.yaml b/.github/workflows/deploy-all-hubs.yaml index cd032018c..1eacf59c8 100644 --- a/.github/workflows/deploy-all-hubs.yaml +++ b/.github/workflows/deploy-all-hubs.yaml @@ -177,13 +177,7 @@ jobs: - name: Deploy base hub images to prod if: ${{ env.DEPLOY }} run: | - ignored_directories=("template") # these are directories that we never want to deploy while read deployment; do - for ignored in "${ignored_directories[@]}"; do - if [[ "${deployment}" == "${ignored}" ]]; then - continue 2 # skip to the next iteration of "while read deployment" - fi - done echo "Pretending to deploy base hub image to ${deployment} :P" echo "hubploy deploy --verbose ${deployment} hub prod" - done < <(ls deployments/ | sed -e 's,/,,g') + done < <(.github/scripts/get-deployments.py --ignore template) From d931fa14ae522a05e5df4ceeb2a95441ebbed5bd Mon Sep 17 00:00:00 2001 From: shane knapp Date: Tue, 27 Aug 2024 16:30:22 -0700 Subject: [PATCH 03/21] forgot about staging --- .github/workflows/deploy-all-hubs.yaml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.github/workflows/deploy-all-hubs.yaml b/.github/workflows/deploy-all-hubs.yaml index 1eacf59c8..475d19655 100644 --- a/.github/workflows/deploy-all-hubs.yaml +++ b/.github/workflows/deploy-all-hubs.yaml @@ -89,16 +89,10 @@ jobs: - name: Deploy base hub images to staging if: ${{ env.DEPLOY }} run: | - ignored_directories=("template") # these are directories that we never want to deploy while read deployment; do - for ignored in "${ignored_directories[@]}"; do - if [[ "${deployment}" == "${ignored}" ]]; then - continue 2 # skip to the next iteration of "while read deployment" - fi - done echo "Pretending to deploy base hub image to ${deployment} :P" echo "hubploy deploy --verbose ${deployment} hub staging" - done < <(ls deployments/ | sed -e 's,/,,g') + done < <(.github/scripts/get-deployments.py --ignore template) deploy-hub-images-prod: if: github.event_name == 'push' && github.ref == 'refs/heads/prod' From ac0f289a1d42697e475801b29d7c59ba07cf72be Mon Sep 17 00:00:00 2001 From: shane knapp Date: Tue, 27 Aug 2024 16:38:06 -0700 Subject: [PATCH 04/21] newline at EOF --- .github/scripts/get-deployments.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/scripts/get-deployments.py b/.github/scripts/get-deployments.py index b96ad2767..81cc0161f 100755 --- a/.github/scripts/get-deployments.py +++ b/.github/scripts/get-deployments.py @@ -1,5 +1,4 @@ #!/usr/bin/env python - import argparse import os @@ -26,4 +25,4 @@ def main(args): ) args = parser.parse_args() - main(args) \ No newline at end of file + main(args) From 84f6b64d2db59e3443df9eeee7bbdeae2335cbaa Mon Sep 17 00:00:00 2001 From: shane knapp Date: Tue, 27 Aug 2024 16:39:05 -0700 Subject: [PATCH 05/21] docstring ftw --- .github/scripts/get-deployments.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/scripts/get-deployments.py b/.github/scripts/get-deployments.py index 81cc0161f..7dbf8cb6c 100755 --- a/.github/scripts/get-deployments.py +++ b/.github/scripts/get-deployments.py @@ -1,9 +1,12 @@ #!/usr/bin/env python +''' +Get a list of deployments from the deployments/ directory, excluding any +directories specified with the --ignore flag. +''' import argparse import os def main(args): - for deployment in next(os.walk(args.deployments))[1]: if deployment not in args.ignore: print(deployment) From c888a45b2730808b89f40e61e60520befe248854 Mon Sep 17 00:00:00 2001 From: shane knapp Date: Tue, 27 Aug 2024 16:45:55 -0700 Subject: [PATCH 06/21] must remember: double quotes, not single. double quotes, not single. match the style of the rest of the python i write. match the style of the rest of the python i write --- .github/scripts/get-deployments.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/scripts/get-deployments.py b/.github/scripts/get-deployments.py index 7dbf8cb6c..1ffa5bf53 100755 --- a/.github/scripts/get-deployments.py +++ b/.github/scripts/get-deployments.py @@ -1,8 +1,8 @@ #!/usr/bin/env python -''' +""" Get a list of deployments from the deployments/ directory, excluding any directories specified with the --ignore flag. -''' +""" import argparse import os @@ -11,20 +11,20 @@ def main(args): if deployment not in args.ignore: print(deployment) -if __name__ == '__main__': - parser = argparse.ArgumentParser(description='Generate a list of deployments from the deployments/ directory.') +if __name__ == "__main__": + parser = argparse.ArgumentParser(description="Generate a list of deployments from the deployments/ directory.") parser.add_argument( - '--deployments', - '-d', - default='deployments', - help='The directory to search for deployments.' + "--deployments", + "-d", + default="deployments", + help="The directory to search for deployments." ) parser.add_argument( - '--ignore', - '-i', - nargs='*', - default=(), - help='Ignore one or more directories in the deployments/ subdir.' + "--ignore", + "-i", + nargs="*", + default=[], + help="Ignore one or more directories in the deployments/ subdir." ) args = parser.parse_args() From d462e9a1009e495f0fde1cb07b7efa7326e27f36 Mon Sep 17 00:00:00 2001 From: shane knapp Date: Tue, 27 Aug 2024 16:46:43 -0700 Subject: [PATCH 07/21] formatting --- .github/scripts/get-deployments.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/scripts/get-deployments.py b/.github/scripts/get-deployments.py index 1ffa5bf53..56a6ec56b 100755 --- a/.github/scripts/get-deployments.py +++ b/.github/scripts/get-deployments.py @@ -12,7 +12,9 @@ def main(args): print(deployment) if __name__ == "__main__": - parser = argparse.ArgumentParser(description="Generate a list of deployments from the deployments/ directory.") + parser = argparse.ArgumentParser( + description="Generate a list of deployments from the deployments/ directory." + ) parser.add_argument( "--deployments", "-d", From 88fbf92d8454cb6c0e405258d25601376287e0f4 Mon Sep 17 00:00:00 2001 From: shane knapp Date: Wed, 28 Aug 2024 10:51:03 -0700 Subject: [PATCH 08/21] python really helps clean things up --- .github/scripts/determine-hub-deployments.py | 61 +++++++ .github/scripts/get-deployments.py | 33 ---- .github/workflows/deploy-all-hubs.yaml | 177 ------------------- .github/workflows/deploy-hubs.yaml | 60 +++---- 4 files changed, 87 insertions(+), 244 deletions(-) create mode 100755 .github/scripts/determine-hub-deployments.py delete mode 100755 .github/scripts/get-deployments.py delete mode 100644 .github/workflows/deploy-all-hubs.yaml diff --git a/.github/scripts/determine-hub-deployments.py b/.github/scripts/determine-hub-deployments.py new file mode 100755 index 000000000..f45328517 --- /dev/null +++ b/.github/scripts/determine-hub-deployments.py @@ -0,0 +1,61 @@ +#! /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_ 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 + 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 specific hubs + 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: + 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." + ) + args = parser.parse_args() + + main(args) diff --git a/.github/scripts/get-deployments.py b/.github/scripts/get-deployments.py deleted file mode 100755 index 56a6ec56b..000000000 --- a/.github/scripts/get-deployments.py +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env python -""" -Get a list of deployments from the deployments/ directory, excluding any -directories specified with the --ignore flag. -""" -import argparse -import os - -def main(args): - for deployment in next(os.walk(args.deployments))[1]: - if deployment not in args.ignore: - print(deployment) - -if __name__ == "__main__": - parser = argparse.ArgumentParser( - description="Generate a list of deployments from the deployments/ directory." - ) - parser.add_argument( - "--deployments", - "-d", - default="deployments", - help="The directory to search for deployments." - ) - parser.add_argument( - "--ignore", - "-i", - nargs="*", - default=[], - help="Ignore one or more directories in the deployments/ subdir." - ) - args = parser.parse_args() - - main(args) diff --git a/.github/workflows/deploy-all-hubs.yaml b/.github/workflows/deploy-all-hubs.yaml deleted file mode 100644 index 475d19655..000000000 --- a/.github/workflows/deploy-all-hubs.yaml +++ /dev/null @@ -1,177 +0,0 @@ -# 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. -# -name: Deploy base hub images to all hubs in staging and prod -on: - workflow_dispatch: - push: - branches: - - staging - - prod - -jobs: - deploy-hub-images-staging: - if: github.event_name == 'push' && github.ref == 'refs/heads/staging' - runs-on: ubuntu-latest - steps: - - name: Get PR labels - id: pr-labels - uses: irby/get-labels-on-push@v1.0.1 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - - - name: Check to see if the base jupyterhub image has changed, and deploy all hubs to prod if it has - run: | - echo "PR labels: ${{ steps.pr-labels.outputs.labels }}" - for label in $(echo -e "${{ steps.pr-labels.outputs.labels }}"); do - if [[ "$label" == jupyterhub-deployment || "$label" == hub-images ]]; then - echo "DEPLOY=1" >> $GITHUB_ENV - fi - done - - - name: Check out the image repo - if: ${{ env.DEPLOY }} - uses: actions/checkout@v4 - with: - fetch-depth: 0 # OR "2" -> To retrieve the preceding commit. - - - name: Setup python - if: ${{ env.DEPLOY }} - uses: actions/setup-python@v5 - with: - python-version: '3.11' - - - name: Install dependencies - if: ${{ env.DEPLOY }} - run: | - python -m pip install --upgrade pip - pip install -r requirements.txt - pip install --force-reinstall git+https://github.com/shaneknapp/hubploy.git@major-refactor - - - name: Auth to gcloud - if: ${{ env.DEPLOY }} - uses: google-github-actions/auth@v2 - with: - credentials_json: ${{ secrets.GKE_KEY }} - project_id: ${{ secrets.GCP_PROJECT_ID }} - - - name: Install Google Cloud SDK - if: ${{ env.DEPLOY }} - uses: google-github-actions/setup-gcloud@v2 - with: - install_components: 'gke-gcloud-auth-plugin' - - - name: Install SOPS - if: ${{ env.DEPLOY }} - run: | - mkdir -p ${HOME}/bin - curl -sSL https://github.com/getsops/sops/releases/download/v3.9.0/sops-v3.9.0.linux.amd64 -o ${HOME}/bin/sops - chmod 755 ${HOME}/bin/sops - echo "${HOME}/bin" >> $GITHUB_PATH - - - name: Store SOPS secret in a file - if: ${{ env.DEPLOY }} - run: | - cat << EOF > ${HOME}/sops.key - ${{ secrets.SOPS_KEY }} - EOF - echo "GOOGLE_APPLICATION_CREDENTIALS=${HOME}/sops.key" >> $GITHUB_ENV - - - name: Install Helm - if: ${{ env.DEPLOY }} - run: | - curl -L https://get.helm.sh/helm-v3.13.3-linux-amd64.tar.gz | tar -xzf - - mv linux-amd64/helm /usr/local/bin - helm repo add jupyterhub https://jupyterhub.github.io/helm-chart/ - helm repo update - - - name: Deploy base hub images to staging - if: ${{ env.DEPLOY }} - run: | - while read deployment; do - echo "Pretending to deploy base hub image to ${deployment} :P" - echo "hubploy deploy --verbose ${deployment} hub staging" - done < <(.github/scripts/get-deployments.py --ignore template) - - deploy-hub-images-prod: - if: github.event_name == 'push' && github.ref == 'refs/heads/prod' - runs-on: ubuntu-latest - steps: - - name: Get PR labels - id: pr-labels - uses: irby/get-labels-on-push@v1.0.1 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - - - name: Check to see if the base jupyterhub image has changed, and deploy all hubs to prod if it has - run: | - echo "PR labels: ${{ steps.pr-labels.outputs.labels }}" - for label in $(echo -e "${{ steps.pr-labels.outputs.labels }}"); do - if [[ "$label" == jupyterhub-deployment || "$label" == hub-images ]]; then - echo "DEPLOY=1" >> $GITHUB_ENV - fi - done - - - name: Check out the image repo - uses: actions/checkout@v4 - with: - fetch-depth: 0 # OR "2" -> To retrieve the preceding commit. - - - name: Setup python - if: ${{ env.DEPLOY }} - uses: actions/setup-python@v5 - with: - python-version: '3.11' - - - name: Install dependencies - if: ${{ env.DEPLOY }} - run: | - python -m pip install --upgrade pip - pip install -r requirements.txt - pip install --force-reinstall git+https://github.com/shaneknapp/hubploy.git@major-refactor - - - name: Auth to gcloud - if: ${{ env.DEPLOY }} - uses: google-github-actions/auth@v2 - with: - credentials_json: ${{ secrets.GKE_KEY }} - project_id: ${{ secrets.GCP_PROJECT_ID }} - - - name: Install Google Cloud SDK - if: ${{ env.DEPLOY }} - uses: google-github-actions/setup-gcloud@v2 - with: - install_components: 'gke-gcloud-auth-plugin' - - - name: Install SOPS - if: ${{ env.DEPLOY }} - run: | - mkdir -p ${HOME}/bin - curl -sSL https://github.com/getsops/sops/releases/download/v3.9.0/sops-v3.9.0.linux.amd64 -o ${HOME}/bin/sops - chmod 755 ${HOME}/bin/sops - echo "${HOME}/bin" >> $GITHUB_PATH - - - name: Store SOPS secret in a file - if: ${{ env.DEPLOY }} - run: | - cat << EOF > ${HOME}/sops.key - ${{ secrets.SOPS_KEY }} - EOF - echo "GOOGLE_APPLICATION_CREDENTIALS=${HOME}/sops.key" >> $GITHUB_ENV - - - name: Install Helm - if: ${{ env.DEPLOY }} - run: | - curl -L https://get.helm.sh/helm-v3.13.3-linux-amd64.tar.gz | tar -xzf - - mv linux-amd64/helm /usr/local/bin - helm repo add jupyterhub https://jupyterhub.github.io/helm-chart/ - helm repo update - - - name: Deploy base hub images to prod - if: ${{ env.DEPLOY }} - run: | - while read deployment; do - echo "Pretending to deploy base hub image to ${deployment} :P" - echo "hubploy deploy --verbose ${deployment} hub prod" - done < <(.github/scripts/get-deployments.py --ignore template) diff --git a/.github/workflows/deploy-hubs.yaml b/.github/workflows/deploy-hubs.yaml index 807240013..317269a09 100644 --- a/.github/workflows/deploy-hubs.yaml +++ b/.github/workflows/deploy-hubs.yaml @@ -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: ". -# -# 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: @@ -24,25 +20,23 @@ 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 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. + # + # Otherwise, just check to see if the PR labels contain any hubs, + # and if so, deploy just those hubs to staging. 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" + echo "DEPLOY=1" >> $GITHUB_ENV 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 @@ -104,10 +98,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" + echo "hubploy deploy --verbose ${deployment} hub staging" + done < <(.github/scripts/determine-hub-deployments.py) deploy-hubs-to-prod: if: github.event_name == 'push' && github.ref == 'refs/heads/prod' @@ -119,25 +113,23 @@ 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 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. + # + # Otherwise, just check to see if the PR labels contain any hubs, + # and if so, deploy just those hubs to prod. 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" + echo "DEPLOY=1" >> $GITHUB_ENV 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 @@ -199,7 +191,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" + echo "hubploy deploy --verbose ${deployment} hub prod" + done < <(.github/scripts/determine-hub-deployments.py) From f9ad125a17da338d89475ad277979369fa5109b9 Mon Sep 17 00:00:00 2001 From: shane knapp Date: Wed, 28 Aug 2024 11:19:46 -0700 Subject: [PATCH 09/21] add arg to allow us to limit hub deployments to only specific ones --- .github/scripts/determine-hub-deployments.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/scripts/determine-hub-deployments.py b/.github/scripts/determine-hub-deployments.py index f45328517..4598f370a 100755 --- a/.github/scripts/determine-hub-deployments.py +++ b/.github/scripts/determine-hub-deployments.py @@ -37,6 +37,8 @@ def main(args): hubs.sort() for h in hubs: + if args.only_deploy and h not in args.only_deploy: + continue print(h) if __name__ == "__main__": @@ -56,6 +58,12 @@ def main(args): 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) From ddacff134625698918fd808a80ec058e02e18b2b Mon Sep 17 00:00:00 2001 From: shane knapp Date: Wed, 28 Aug 2024 12:42:14 -0700 Subject: [PATCH 10/21] seriously hating bash --- .github/workflows/deploy-hubs.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-hubs.yaml b/.github/workflows/deploy-hubs.yaml index 317269a09..6c621b8bf 100644 --- a/.github/workflows/deploy-hubs.yaml +++ b/.github/workflows/deploy-hubs.yaml @@ -29,7 +29,7 @@ jobs: # # Otherwise, just check to see if the PR labels contain any hubs, # and if so, deploy just those hubs to staging. - if [ -c "${GITHUB_PR_LABEL_HUB_IMAGES}" ] || [ -c "${GITHUB_PR_LABEL_JUPYTERHUB_DEPLOYMENT}" ]; then + if [[ -n ${GITHUB_PR_LABEL_HUB_IMAGES} || -n ${GITHUB_PR_LABEL_JUPYTERHUB_DEPLOYMENT} ]]; then echo "DEPLOY=1" >> $GITHUB_ENV else for label in $(echo -e "${{ steps.pr-labels.outputs.labels }}"); do @@ -122,7 +122,7 @@ jobs: # # Otherwise, just check to see if the PR labels contain any hubs, # and if so, deploy just those hubs to prod. - if [ -c "${GITHUB_PR_LABEL_HUB_IMAGES}" ] || [ -c "${GITHUB_PR_LABEL_JUPYTERHUB_DEPLOYMENT}" ]; then + if [[ -n ${GITHUB_PR_LABEL_HUB_IMAGES} || -n ${GITHUB_PR_LABEL_JUPYTERHUB_DEPLOYMENT} ]]; then echo "DEPLOY=1" >> $GITHUB_ENV else for label in $(echo -e "${{ steps.pr-labels.outputs.labels }}"); do From 739c19ae8afab4eeb5bcbded0ae3ea76bb13e118 Mon Sep 17 00:00:00 2001 From: shane knapp Date: Wed, 28 Aug 2024 12:56:47 -0700 Subject: [PATCH 11/21] reformat comments to be a bit more clear --- .github/workflows/deploy-hubs.yaml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/deploy-hubs.yaml b/.github/workflows/deploy-hubs.yaml index 6c621b8bf..e68848288 100644 --- a/.github/workflows/deploy-hubs.yaml +++ b/.github/workflows/deploy-hubs.yaml @@ -27,10 +27,11 @@ jobs: # present, this means the base hub image has changed, and all hubs # (staging or prod) need to be redeployed. # - # Otherwise, just check to see if the PR labels contain any hubs, - # and if so, deploy just those hubs to staging. if [[ -n ${GITHUB_PR_LABEL_HUB_IMAGES} || -n ${GITHUB_PR_LABEL_JUPYTERHUB_DEPLOYMENT} ]]; then echo "DEPLOY=1" >> $GITHUB_ENV + # Otherwise, just check to see if the PR labels contain any hubs, + # and if so, deploy just those hubs to staging. + # else for label in $(echo -e "${{ steps.pr-labels.outputs.labels }}"); do if [[ "$label" == hub-* ]]; then @@ -120,10 +121,11 @@ jobs: # present, this means the base hub image has changed, and all hubs # (staging or prod) need to be redeployed. # - # Otherwise, just check to see if the PR labels contain any hubs, - # and if so, deploy just those hubs to prod. if [[ -n ${GITHUB_PR_LABEL_HUB_IMAGES} || -n ${GITHUB_PR_LABEL_JUPYTERHUB_DEPLOYMENT} ]]; then echo "DEPLOY=1" >> $GITHUB_ENV + # Otherwise, just check to see if the PR labels contain any hubs, + # and if so, deploy just those hubs to prod. + # else for label in $(echo -e "${{ steps.pr-labels.outputs.labels }}"); do if [[ "$label" == hub-* ]]; then From 8d31b03b1e0c66aca714d3093a93f757696467d8 Mon Sep 17 00:00:00 2001 From: shane knapp Date: Wed, 28 Aug 2024 13:15:27 -0700 Subject: [PATCH 12/21] more explainy comments --- .github/scripts/determine-hub-deployments.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/scripts/determine-hub-deployments.py b/.github/scripts/determine-hub-deployments.py index 4598f370a..cc4010bb7 100755 --- a/.github/scripts/determine-hub-deployments.py +++ b/.github/scripts/determine-hub-deployments.py @@ -17,7 +17,7 @@ def main(args): hubs = [] - # Deploy all 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" @@ -26,7 +26,7 @@ def main(args): if deployment not in args.ignore: hubs.append(deployment) - # Deploy specific hubs + # Deploy only the modified/flagged hubs by PR labels else: hub_labels = [ k.lower() for k in os.environ.keys() From 132acfab0540bd78fb99b31df7d401189d24f31c Mon Sep 17 00:00:00 2001 From: shane knapp Date: Wed, 28 Aug 2024 13:18:43 -0700 Subject: [PATCH 13/21] grammarizing the crap out of comments --- .github/workflows/deploy-hubs.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/deploy-hubs.yaml b/.github/workflows/deploy-hubs.yaml index e68848288..a9a9f98db 100644 --- a/.github/workflows/deploy-hubs.yaml +++ b/.github/workflows/deploy-hubs.yaml @@ -29,8 +29,8 @@ jobs: # if [[ -n ${GITHUB_PR_LABEL_HUB_IMAGES} || -n ${GITHUB_PR_LABEL_JUPYTERHUB_DEPLOYMENT} ]]; then echo "DEPLOY=1" >> $GITHUB_ENV - # Otherwise, just check to see if the PR labels contain any hubs, - # and if so, deploy just those hubs to staging. + # Otherwise, check to see if the PR labels contain any hubs, and + # deploy just those hubs to staging. # else for label in $(echo -e "${{ steps.pr-labels.outputs.labels }}"); do @@ -123,8 +123,8 @@ jobs: # if [[ -n ${GITHUB_PR_LABEL_HUB_IMAGES} || -n ${GITHUB_PR_LABEL_JUPYTERHUB_DEPLOYMENT} ]]; then echo "DEPLOY=1" >> $GITHUB_ENV - # Otherwise, just check to see if the PR labels contain any hubs, - # and if so, deploy just those hubs to prod. + # Otherwise, check to see if the PR labels contain any hubs, and + # deploy just those hubs to prod. # else for label in $(echo -e "${{ steps.pr-labels.outputs.labels }}"); do From 9f6491456751442bae6993ff58e248db3ead7744 Mon Sep 17 00:00:00 2001 From: shane knapp Date: Wed, 28 Aug 2024 14:30:06 -0700 Subject: [PATCH 14/21] might as well explicitly call python to execute these scripts... cant hurt --- .github/workflows/deploy-hubs.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-hubs.yaml b/.github/workflows/deploy-hubs.yaml index a9a9f98db..144f72728 100644 --- a/.github/workflows/deploy-hubs.yaml +++ b/.github/workflows/deploy-hubs.yaml @@ -102,7 +102,7 @@ jobs: while read deployment; do echo "Pretending to deploy base hub image to ${deployment} :P" echo "hubploy deploy --verbose ${deployment} hub staging" - done < <(.github/scripts/determine-hub-deployments.py) + done < <(python .github/scripts/determine-hub-deployments.py) deploy-hubs-to-prod: if: github.event_name == 'push' && github.ref == 'refs/heads/prod' @@ -196,4 +196,4 @@ jobs: while read deployment; do echo "Pretending to deploy base hub image to ${deployment} :P" echo "hubploy deploy --verbose ${deployment} hub prod" - done < <(.github/scripts/determine-hub-deployments.py) + done < <(python .github/scripts/determine-hub-deployments.py) From a7b591ae7fc6a2afe00fbb9fb54dcf64fdcfcc94 Mon Sep 17 00:00:00 2001 From: shane knapp Date: Wed, 28 Aug 2024 15:22:32 -0700 Subject: [PATCH 15/21] bashenannigans --- .github/workflows/deploy-hubs.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-hubs.yaml b/.github/workflows/deploy-hubs.yaml index 144f72728..25d8c75ca 100644 --- a/.github/workflows/deploy-hubs.yaml +++ b/.github/workflows/deploy-hubs.yaml @@ -27,7 +27,7 @@ jobs: # 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 + 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. @@ -121,7 +121,7 @@ jobs: # 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 + if [[ -v GITHUB_PR_LABEL_HUB_IMAGES || -v 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. From 42be9afaf6755e48006808f492b23c57f6fe451d Mon Sep 17 00:00:00 2001 From: shane knapp Date: Wed, 28 Aug 2024 15:56:45 -0700 Subject: [PATCH 16/21] fixing bash conditionals... again --- .github/workflows/deploy-hubs.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-hubs.yaml b/.github/workflows/deploy-hubs.yaml index 25d8c75ca..144f72728 100644 --- a/.github/workflows/deploy-hubs.yaml +++ b/.github/workflows/deploy-hubs.yaml @@ -27,7 +27,7 @@ jobs: # 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 + 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. @@ -121,7 +121,7 @@ jobs: # present, this means the base hub image has changed, and all hubs # (staging or prod) need to be redeployed. # - if [[ -v GITHUB_PR_LABEL_HUB_IMAGES || -v GITHUB_PR_LABEL_JUPYTERHUB_DEPLOYMENT ]]; then + 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. From 9451616f11c82a4eff7d3225474bdf914104e282 Mon Sep 17 00:00:00 2001 From: shane knapp Date: Wed, 28 Aug 2024 16:51:46 -0700 Subject: [PATCH 17/21] bumping datahub placeholders to 2 --- node-placeholder/values.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node-placeholder/values.yaml b/node-placeholder/values.yaml index 2c3932b5b..fb8d0ed88 100644 --- a/node-placeholder/values.yaml +++ b/node-placeholder/values.yaml @@ -135,7 +135,7 @@ nodePools: requests: # Some value slightly lower than allocatable RAM on the nodepool memory: 60929654784 - replicas: 1 + replicas: 2 dev: nodeSelector: hub.jupyter.org/pool-name: dev-pool From 28de8e1a7d1df71662913688d78bfca551c3337b Mon Sep 17 00:00:00 2001 From: shane knapp Date: Thu, 29 Aug 2024 09:17:30 -0700 Subject: [PATCH 18/21] testing for logodev --- .github/workflows/deploy-hubs.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/deploy-hubs.yaml b/.github/workflows/deploy-hubs.yaml index 144f72728..402e90dc8 100644 --- a/.github/workflows/deploy-hubs.yaml +++ b/.github/workflows/deploy-hubs.yaml @@ -101,8 +101,8 @@ jobs: run: | while read deployment; do echo "Pretending to deploy base hub image to ${deployment} :P" - echo "hubploy deploy --verbose ${deployment} hub staging" - done < <(python .github/scripts/determine-hub-deployments.py) + hubploy deploy --verbose ${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' @@ -195,5 +195,5 @@ jobs: run: | while read deployment; do echo "Pretending to deploy base hub image to ${deployment} :P" - echo "hubploy deploy --verbose ${deployment} hub prod" - done < <(python .github/scripts/determine-hub-deployments.py) + hubploy deploy --verbose ${deployment} hub prod + done < <(python .github/scripts/determine-hub-deployments.py --only-deploy logodev) From d3c6164e876795609232de9385277623a07392af Mon Sep 17 00:00:00 2001 From: "Image Builder Bot[tm]" Date: Thu, 29 Aug 2024 16:53:58 +0000 Subject: [PATCH 19/21] update logodev image tag to cb7832b0a131: deployments/logodev/hubploy.yaml --- deployments/logodev/hubploy.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployments/logodev/hubploy.yaml b/deployments/logodev/hubploy.yaml index d532f0a5b..893cc72ba 100644 --- a/deployments/logodev/hubploy.yaml +++ b/deployments/logodev/hubploy.yaml @@ -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 From 5dea919e94c932f284232b90233657e293e070a5 Mon Sep 17 00:00:00 2001 From: shane knapp Date: Thu, 29 Aug 2024 10:07:53 -0700 Subject: [PATCH 20/21] fix positional args for hubploy --- .github/workflows/deploy-hubs.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-hubs.yaml b/.github/workflows/deploy-hubs.yaml index 402e90dc8..9b8637bb2 100644 --- a/.github/workflows/deploy-hubs.yaml +++ b/.github/workflows/deploy-hubs.yaml @@ -101,7 +101,7 @@ jobs: run: | while read deployment; do echo "Pretending to deploy base hub image to ${deployment} :P" - hubploy deploy --verbose ${deployment} hub staging + hubploy --verbose deploy ${deployment} hub staging done < <(python .github/scripts/determine-hub-deployments.py --only-deploy logodev) deploy-hubs-to-prod: @@ -195,5 +195,5 @@ jobs: run: | while read deployment; do echo "Pretending to deploy base hub image to ${deployment} :P" - hubploy deploy --verbose ${deployment} hub prod + hubploy --verbose deploy ${deployment} hub prod done < <(python .github/scripts/determine-hub-deployments.py --only-deploy logodev) From 123963d398096105eab0450b66fa72236d18810f Mon Sep 17 00:00:00 2001 From: shane knapp Date: Thu, 29 Aug 2024 10:25:13 -0700 Subject: [PATCH 21/21] adding timeout to hubploy --- .github/workflows/deploy-hubs.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-hubs.yaml b/.github/workflows/deploy-hubs.yaml index 9b8637bb2..a072ba509 100644 --- a/.github/workflows/deploy-hubs.yaml +++ b/.github/workflows/deploy-hubs.yaml @@ -101,7 +101,7 @@ jobs: run: | while read deployment; do echo "Pretending to deploy base hub image to ${deployment} :P" - hubploy --verbose deploy ${deployment} hub staging + hubploy --verbose deploy --timeout 30m ${deployment} hub staging done < <(python .github/scripts/determine-hub-deployments.py --only-deploy logodev) deploy-hubs-to-prod: @@ -195,5 +195,5 @@ jobs: run: | while read deployment; do echo "Pretending to deploy base hub image to ${deployment} :P" - hubploy --verbose deploy ${deployment} hub prod + hubploy --verbose deploy --timeout 30m ${deployment} hub prod done < <(python .github/scripts/determine-hub-deployments.py --only-deploy logodev)