From 54f02d339609ef3d1200a65ee05e01ec1916ade1 Mon Sep 17 00:00:00 2001 From: alexj9837 Date: Tue, 7 Apr 2026 09:03:46 +0000 Subject: [PATCH 1/5] extra comment --- helm/blueapi/templates/cronjob.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/helm/blueapi/templates/cronjob.yaml b/helm/blueapi/templates/cronjob.yaml index de25f7c549..804c05753c 100644 --- a/helm/blueapi/templates/cronjob.yaml +++ b/helm/blueapi/templates/cronjob.yaml @@ -68,6 +68,7 @@ spec: MOUNTED_PVCS=$(kubectl get pods -n {{ .Release.Namespace }} \ -o=jsonpath='{.items[*].spec.volumes[*].persistentVolumeClaim.claimName}' | tr ' ' '\n' | sort -u) NOW=$(date +%s) + #loop through all the pvcs annotating ones thare are mounted or lack a last-used stamp for pvc in $ALL_PVC; do ANNOTATION=$(kubectl get pvc "$pvc" -n {{ .Release.Namespace }} -o=jsonpath='{.metadata.annotations.last-used}') if [ -z "$ANNOTATION" ]; then From 713481c710e4464a2730900942c7343ad900502b Mon Sep 17 00:00:00 2001 From: alexj9837 Date: Tue, 7 Apr 2026 12:07:46 +0000 Subject: [PATCH 2/5] adding the bash script to config map, and pointing to it via the cronjob --- helm/blueapi/templates/configmap.yaml | 27 ++++++++++++++++++++- helm/blueapi/templates/cronjob.yaml | 34 ++++++++++----------------- 2 files changed, 39 insertions(+), 22 deletions(-) diff --git a/helm/blueapi/templates/configmap.yaml b/helm/blueapi/templates/configmap.yaml index aa813e6485..ed32dbd5f0 100644 --- a/helm/blueapi/templates/configmap.yaml +++ b/helm/blueapi/templates/configmap.yaml @@ -31,6 +31,31 @@ data: init_config.yaml: |- scratch: {{- toYaml .Values.worker.scratch | nindent 6 }} + +--- {{- end }} ---- +apiVersion: v1 +kind: ConfigMap +metadata: + name : {{include "blueapi.fullname" . }}-pvc-stamper-script +data: + time-stamper.sh: | + #!/bin/bash + # Get PVCs belonging to this blueapi release + ALL_PVC=$(kubectl get pvc -n {{ .Release.Namespace }} \ + -o jsonpath='{.items[*].metadata.name}' | tr ' ' '\n' | \ + grep "^{{ .Release.Name }}-scratch-") + # Get all PVCs currently mounted by running pods + MOUNTED_PVCS=$(kubectl get pods -n {{ .Release.Namespace }} \ + -o=jsonpath='{.items[*].spec.volumes[*].persistentVolumeClaim.claimName}' | tr ' ' '\n' | sort -u) + NOW=$(date +%s) + #loop through all the pvcs annotating ones thare are mounted or lack a last-used stamp + for pvc in $ALL_PVC; do + ANNOTATION=$(kubectl get pvc "$pvc" -n {{ .Release.Namespace }} -o=jsonpath='{.metadata.annotations.last-used}') + if [ -z "$ANNOTATION" ]; then + kubectl annotate --overwrite pvc "$pvc" -n {{ .Release.Namespace }} last-used="$NOW" + elif echo "$MOUNTED_PVCS" | grep -qx "$pvc"; then + kubectl annotate --overwrite pvc "$pvc" -n {{ .Release.Namespace }} last-used="$NOW" + fi + done diff --git a/helm/blueapi/templates/cronjob.yaml b/helm/blueapi/templates/cronjob.yaml index 804c05753c..ab4b7a225c 100644 --- a/helm/blueapi/templates/cronjob.yaml +++ b/helm/blueapi/templates/cronjob.yaml @@ -39,6 +39,7 @@ spec: successfulJobsHistoryLimit: 3 failedJobsHistoryLimit: 1 schedule: "*/5 * * * *" + jobTemplate: spec: # amount of attempts of labeling a pvc @@ -52,29 +53,20 @@ spec: tolerations: {{- toYaml . | nindent 12 }} {{- end }} + + volumes: + - name : {{include "blueapi.fullname" . }}-pvc-stamper-script + configMap: + name: {{include "blueapi.fullname" . }}-pvc-stamper-script + defaultMode: 0500 + + containers: - name: last-used-stamper + volumeMounts: + - name: {{include "blueapi.fullname" . }}-pvc-stamper-script + mountPath: /scripts image: bitnami/kubectl:latest imagePullPolicy: IfNotPresent - command: - - /bin/sh - - -c - - | - # Get PVCs belonging to this blueapi release - ALL_PVC=$(kubectl get pvc -n {{ .Release.Namespace }} \ - -o jsonpath='{.items[*].metadata.name}' | tr ' ' '\n' | \ - grep "^{{ .Release.Name }}-scratch-") - # Get all PVCs currently mounted by running pods - MOUNTED_PVCS=$(kubectl get pods -n {{ .Release.Namespace }} \ - -o=jsonpath='{.items[*].spec.volumes[*].persistentVolumeClaim.claimName}' | tr ' ' '\n' | sort -u) - NOW=$(date +%s) - #loop through all the pvcs annotating ones thare are mounted or lack a last-used stamp - for pvc in $ALL_PVC; do - ANNOTATION=$(kubectl get pvc "$pvc" -n {{ .Release.Namespace }} -o=jsonpath='{.metadata.annotations.last-used}') - if [ -z "$ANNOTATION" ]; then - kubectl annotate --overwrite pvc "$pvc" -n {{ .Release.Namespace }} last-used="$NOW" - elif echo "$MOUNTED_PVCS" | grep -qx "$pvc"; then - kubectl annotate --overwrite pvc "$pvc" -n {{ .Release.Namespace }} last-used="$NOW" - fi - done + command: ["/scripts/time-stamper.sh"] restartPolicy: OnFailure From 79c435aab9aab3c7a16f37036a17732a7e1f34fe Mon Sep 17 00:00:00 2001 From: alexj9837 Date: Tue, 7 Apr 2026 12:35:39 +0000 Subject: [PATCH 3/5] updating release tag --- helm/blueapi/Chart.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helm/blueapi/Chart.yaml b/helm/blueapi/Chart.yaml index ac21970cff..2348e56c53 100644 --- a/helm/blueapi/Chart.yaml +++ b/helm/blueapi/Chart.yaml @@ -15,7 +15,7 @@ type: application # This is the chart version. This version number is incremented by the release process. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 1.12.7 +version: 1.12.8 # This is the version number of the application being deployed. This version number is incremented by the release process. # Versions are not expected to follow Semantic Versioning. They should reflect the version the application is using. From 8ea2b5235b82b834eee7e198bd40bf851f22aee6 Mon Sep 17 00:00:00 2001 From: alexj9837 Date: Tue, 7 Apr 2026 13:32:42 +0000 Subject: [PATCH 4/5] was calling bin/bash not bin/sh and bitnami/kubectl doesn't have full bash --- helm/blueapi/templates/configmap.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helm/blueapi/templates/configmap.yaml b/helm/blueapi/templates/configmap.yaml index ed32dbd5f0..15cfbc4d67 100644 --- a/helm/blueapi/templates/configmap.yaml +++ b/helm/blueapi/templates/configmap.yaml @@ -41,7 +41,7 @@ metadata: name : {{include "blueapi.fullname" . }}-pvc-stamper-script data: time-stamper.sh: | - #!/bin/bash + #!/bin/sh # Get PVCs belonging to this blueapi release ALL_PVC=$(kubectl get pvc -n {{ .Release.Namespace }} \ -o jsonpath='{.items[*].metadata.name}' | tr ' ' '\n' | \ From 63985f26cde0ba8d50e4d40dbd1b18a0264372bb Mon Sep 17 00:00:00 2001 From: alexj9837 Date: Tue, 7 Apr 2026 13:33:21 +0000 Subject: [PATCH 5/5] updating version --- helm/blueapi/Chart.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helm/blueapi/Chart.yaml b/helm/blueapi/Chart.yaml index 2348e56c53..039e2d0d31 100644 --- a/helm/blueapi/Chart.yaml +++ b/helm/blueapi/Chart.yaml @@ -15,7 +15,7 @@ type: application # This is the chart version. This version number is incremented by the release process. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 1.12.8 +version: 1.12.9 # This is the version number of the application being deployed. This version number is incremented by the release process. # Versions are not expected to follow Semantic Versioning. They should reflect the version the application is using.