From 6ee89b2eeebb6732115abc2a0c47d5856f7930b2 Mon Sep 17 00:00:00 2001 From: Austin Macdonald Date: Fri, 8 Nov 2024 14:55:31 -0600 Subject: [PATCH] change from job to pod --- .github/manifests/disk-usage-report-job.yaml | 51 ++++++-------- .github/workflows/report.yaml | 73 ++++++++++---------- 2 files changed, 59 insertions(+), 65 deletions(-) diff --git a/.github/manifests/disk-usage-report-job.yaml b/.github/manifests/disk-usage-report-job.yaml index c7f60a4..36ded0f 100644 --- a/.github/manifests/disk-usage-report-job.yaml +++ b/.github/manifests/disk-usage-report-job.yaml @@ -1,32 +1,27 @@ -apiVersion: batch/v1 -kind: Job +apiVersion: v1 +kind: Pod metadata: name: disk-usage-report-job spec: - template: - metadata: - labels: - app: disk-usage-report - spec: - containers: - - name: disk-usage-report - image: IMAGE_PLACEHOLDER - args: - - "/home/asmacdo" - volumeMounts: - - name: persistent-storage - mountPath: "/home/" - restartPolicy: Never - nodeSelector: - NodeGroupType: default - NodePool: default - hub.jupyter.org/node-purpose: user - tolerations: - - key: "hub.jupyter.org/dedicated" - operator: "Equal" - value: "user" - effect: "NoSchedule" - volumes: + containers: + - name: disk-usage-report + image: IMAGE_PLACEHOLDER + args: + - "/home/asmacdo" + volumeMounts: - name: persistent-storage - persistentVolumeClaim: - claimName: efs-persist + mountPath: "/home/" + restartPolicy: Never + nodeSelector: + NodeGroupType: default + NodePool: default + hub.jupyter.org/node-purpose: user + tolerations: + - key: "hub.jupyter.org/dedicated" + operator: "Equal" + value: "user" + effect: "NoSchedule" + volumes: + - name: persistent-storage + persistentVolumeClaim: + claimName: efs-persist diff --git a/.github/workflows/report.yaml b/.github/workflows/report.yaml index 5889c90..50168ff 100644 --- a/.github/workflows/report.yaml +++ b/.github/workflows/report.yaml @@ -50,51 +50,50 @@ jobs: run: | kubectl get pods -n jupyterhub - - name: Deploy Hello World Pod - run: | - kubectl apply -f .github/manifests/hello-world-pod.yaml - - - name: Wait for Hello World Pod to complete - run: | - kubectl wait --for=condition=Ready pod/hello-world-pod --timeout=300s # 5 minutes - continue-on-error: true # Allow the workflow to continue even if this step fails - - - name: Get Hello World Pod logs - run: | - kubectl logs hello-world-pod - if: ${{ success() }} # Only run this step if the previous step was successful - - - name: Delete Hello World Pod - run: | - kubectl delete pod hello-world-pod - if: ${{ always() }} # Always run this step, even if other steps fail - # - # - name: Replace image placeholder in manifest - # run: | - # sed -i 's|IMAGE_PLACEHOLDER|'"${{ secrets.DOCKERHUB_USERNAME }}/disk_usage_report:latest"'|' .github/manifests/disk-usage-report-job.yaml - # - # - name: Deploy Disk Usage Report Job + # - name: Deploy Hello World Pod # run: | - # kubectl apply -f .github/manifests/disk-usage-report-job.yaml + # kubectl apply -f .github/manifests/hello-world-pod.yaml # - # # TODO should timeout be longer? - # - name: Wait for Disk Usage Report Job to complete + # - name: Wait for Hello World Pod to complete # run: | - # kubectl wait --for=condition=complete job/disk-usage-report-job --timeout=300s - # continue-on-error: true + # kubectl wait --for=condition=Ready pod/hello-world-pod --timeout=300s # 5 minutes + # continue-on-error: true # Allow the workflow to continue even if this step fails # - # - name: Retrieve generated report file + # - name: Get Hello World Pod logs # run: | - # POD_NAME=$(kubectl get pods --selector=job-name=disk-usage-report-job -o jsonpath='{.items[0].metadata.name}') - # kubectl cp $POD_NAME:/output/du_report.json du_report.json -n jupyterhub - # cat du_report.json - # continue-on-error: true + # kubectl logs hello-world-pod + # if: ${{ success() }} # Only run this step if the previous step was successful # - # # continue-on-error for previous steps so we delete the job - # - name: Delete Disk Usage Report Job + # - name: Delete Hello World Pod # run: | - # kubectl delete job disk-usage-report-job + # kubectl delete pod hello-world-pod + # if: ${{ always() }} # Always run this step, even if other steps fail # + - name: Replace image placeholder in manifest + run: | + sed -i 's|IMAGE_PLACEHOLDER|'"${{ secrets.DOCKERHUB_USERNAME }}/disk_usage_report:latest"'|' .github/manifests/disk-usage-report-job.yaml + + - name: Deploy Disk Usage Report Job Pod + run: | + kubectl apply -f .github/manifests/disk-usage-report-job.yaml + + # TODO should timeout be longer? + - name: Wait for Disk Usage Report Job to complete + run: | + kubectl wait --for=condition=complete pod/disk-usage-report-job --timeout=300s + continue-on-error: true + + - name: Retrieve generated report file + run: | + kubectl cp disk-usage-report-job:/output/du_report.json du_report.json + cat du_report.json + continue-on-error: true + + # continue-on-error for previous steps so we delete the job + - name: Delete Disk Usage Report Job + run: | + kubectl delete pod disk-usage-report-job + # - name: Clone dandi-hub-usage-reports repository # run: | # git clone https://github.com/dandi/dandi-hub-usage-reports.git