From 05b63738572146bd374deb4db66e53edf4031c4f Mon Sep 17 00:00:00 2001 From: Alexj9837 Date: Wed, 1 Apr 2026 13:29:50 +0000 Subject: [PATCH 01/28] adding time-stamp cronjob to blueapi and a corasponding test --- helm/blueapi/templates/cronjob.yaml | 78 +++++++++++++++++++ .../blueapi/templates/tests/test-cronjob.yaml | 19 +++++ 2 files changed, 97 insertions(+) create mode 100644 helm/blueapi/templates/cronjob.yaml create mode 100644 helm/blueapi/templates/tests/test-cronjob.yaml diff --git a/helm/blueapi/templates/cronjob.yaml b/helm/blueapi/templates/cronjob.yaml new file mode 100644 index 0000000000..d1ff9bf325 --- /dev/null +++ b/helm/blueapi/templates/cronjob.yaml @@ -0,0 +1,78 @@ +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "blueapi.fullname" . }}-last-used-stamper + namespace: {{ .Release.Namespace }} +automountServiceAccountToken: true +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + name: {{ include "blueapi.fullname" . }}-last-used-stamper + namespace: {{ .Release.Namespace }} +rules: +- apiGroups: [""] + resources: ["pods", "persistentvolumeclaims"] + verbs: ["get", "list", "patch"] +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: {{ include "blueapi.fullname" . }}-last-used-stamper + namespace: {{ .Release.Namespace }} +subjects: +- kind: ServiceAccount + name: {{ include "blueapi.fullname" . }}-last-used-stamper + namespace: {{ .Release.Namespace }} +roleRef: + kind: Role + name: {{ include "blueapi.fullname" . }}-last-used-stamper + apiGroup: rbac.authorization.k8s.io +--- +apiVersion: batch/v1 +kind: CronJob +metadata: + name: {{ include "blueapi.fullname" . }}-last-used-stamper + namespace: {{ .Release.Namespace }} +spec: + concurrencyPolicy: Forbid + successfulJobsHistoryLimit: 3 + failedJobsHistoryLimit: 1 + schedule: "*/5 * * * *" + jobTemplate: + spec: + # amount of attempts of labeling a pvc + backoffLimit: 2 + # job stops after 60 secounds + activeDeadlineSeconds: 60 + template: + spec: + serviceAccountName: {{ include "blueapi.fullname" . }}-last-used-stamper + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 12 }} + {{- end }} + containers: + - name: last-used-stamper + image: bitnami/kubectl:1.34.5 + imagePullPolicy: IfNotPresent + command: + - /bin/sh + - -c + - | + # Get PVCs belonging to this blueapi release + ALL_PVC=$(kubectl get pvc -l "argocd.argoproj.io/instance={{ .Release.Name }}" \ + -o jsonpath='{.items[*].metadata.name}' -n {{ .Release.Namespace }} | tr ' ' '\n') + # 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) + 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 + restartPolicy: OnFailure diff --git a/helm/blueapi/templates/tests/test-cronjob.yaml b/helm/blueapi/templates/tests/test-cronjob.yaml new file mode 100644 index 0000000000..52df70cba5 --- /dev/null +++ b/helm/blueapi/templates/tests/test-cronjob.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Pod +metadata: + name: {{ include "blueapi.fullname" . }}-last-used-stamper + annotations: + "helm.sh/hook": test +spec: + serviceAccountName: {{ include "blueapi.fullname" . }}-last-used-stamper + containers: + - name: test + image: bitnami/kubectl:1.34.5 + command: ["/bin/sh", "-c"] + args: + - | + # Get a pod belonging to this release and annotate it, then verify + kubectl annotate --overwrite pod "$HOSTNAME" -n "{{ .Release.Namespace }}" last-used="$(date +%s)" + kubectl get pod "$HOSTNAME" -n "{{ .Release.Namespace }}" \ + -o jsonpath='{.metadata.annotations.last-used}' | grep -q . + restartPolicy: Never From 887543b34031b713733ab497b38e37b063e8a2c7 Mon Sep 17 00:00:00 2001 From: alexj9837 Date: Wed, 1 Apr 2026 14:30:51 +0000 Subject: [PATCH 02/28] changing version so it publishes a chart --- 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 08097921fb..a82222806c 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: 0.1.0 +version: 1.12.3 # 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 e014ae2c520944f58a9ea96d01b7213db36de81e Mon Sep 17 00:00:00 2001 From: alexj9837 Date: Wed, 1 Apr 2026 14:47:49 +0000 Subject: [PATCH 03/28] updating 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 a82222806c..958bc197b7 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.3 +version: 1.12.4 # 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 eef07a9d2e3821db3acaf47a890c5d748e21038d Mon Sep 17 00:00:00 2001 From: alexj9837 Date: Wed, 1 Apr 2026 15:33:19 +0000 Subject: [PATCH 04/28] updating appversion --- 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 958bc197b7..e557932b26 100644 --- a/helm/blueapi/Chart.yaml +++ b/helm/blueapi/Chart.yaml @@ -20,4 +20,4 @@ version: 1.12.4 # 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. # It is recommended to use it with quotes. -appVersion: "0.1.0" +appVersion: "1.12.4" From 3484be19206d10952b0c793ac95a65231f367579 Mon Sep 17 00:00:00 2001 From: alexj9837 Date: Wed, 1 Apr 2026 15:34:52 +0000 Subject: [PATCH 05/28] update chart --- 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 e557932b26..5600bbc353 100644 --- a/helm/blueapi/Chart.yaml +++ b/helm/blueapi/Chart.yaml @@ -20,4 +20,4 @@ version: 1.12.4 # 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. # It is recommended to use it with quotes. -appVersion: "1.12.4" +appVersion: "1.12.2" From c1703597f5d7c877c083f4dce23acce79ef96d14 Mon Sep 17 00:00:00 2001 From: alexj9837 Date: Wed, 1 Apr 2026 16:06:15 +0000 Subject: [PATCH 06/28] reverting app version for tests --- 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 5600bbc353..958bc197b7 100644 --- a/helm/blueapi/Chart.yaml +++ b/helm/blueapi/Chart.yaml @@ -20,4 +20,4 @@ version: 1.12.4 # 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. # It is recommended to use it with quotes. -appVersion: "1.12.2" +appVersion: "0.1.0" From c4f9f1a4c0777568dadababd9d134a18d03207ae Mon Sep 17 00:00:00 2001 From: alexj9837 Date: Thu, 2 Apr 2026 07:58:51 +0000 Subject: [PATCH 07/28] updating cronjob version --- helm/blueapi/templates/cronjob.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helm/blueapi/templates/cronjob.yaml b/helm/blueapi/templates/cronjob.yaml index d1ff9bf325..438eb83a5a 100644 --- a/helm/blueapi/templates/cronjob.yaml +++ b/helm/blueapi/templates/cronjob.yaml @@ -54,7 +54,7 @@ spec: {{- end }} containers: - name: last-used-stamper - image: bitnami/kubectl:1.34.5 + image: bitnami/kubectl:1.31.1 imagePullPolicy: IfNotPresent command: - /bin/sh From 13d6101204d9694dd9a88fc9a9909a5f234542c6 Mon Sep 17 00:00:00 2001 From: alexj9837 Date: Thu, 2 Apr 2026 08:06:50 +0000 Subject: [PATCH 08/28] updating chart --- 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 958bc197b7..5262df2133 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.4 +version: 1.12.2 # 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 74cd4d3ff4761a8c78997fea24d49a6e7decf130 Mon Sep 17 00:00:00 2001 From: alexj9837 Date: Thu, 2 Apr 2026 09:16:00 +0000 Subject: [PATCH 09/28] setting to latest --- helm/blueapi/templates/cronjob.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helm/blueapi/templates/cronjob.yaml b/helm/blueapi/templates/cronjob.yaml index 438eb83a5a..228ae2e1a0 100644 --- a/helm/blueapi/templates/cronjob.yaml +++ b/helm/blueapi/templates/cronjob.yaml @@ -54,7 +54,7 @@ spec: {{- end }} containers: - name: last-used-stamper - image: bitnami/kubectl:1.31.1 + image: bitnami/kubectl:latest imagePullPolicy: IfNotPresent command: - /bin/sh From 078caee91480344f6a3112bbd185a2a0d40f4434 Mon Sep 17 00:00:00 2001 From: alexj9837 Date: Thu, 2 Apr 2026 10:23:43 +0000 Subject: [PATCH 10/28] updating the script --- helm/blueapi/templates/cronjob.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/helm/blueapi/templates/cronjob.yaml b/helm/blueapi/templates/cronjob.yaml index 228ae2e1a0..de25f7c549 100644 --- a/helm/blueapi/templates/cronjob.yaml +++ b/helm/blueapi/templates/cronjob.yaml @@ -61,8 +61,9 @@ spec: - -c - | # Get PVCs belonging to this blueapi release - ALL_PVC=$(kubectl get pvc -l "argocd.argoproj.io/instance={{ .Release.Name }}" \ - -o jsonpath='{.items[*].metadata.name}' -n {{ .Release.Namespace }} | tr ' ' '\n') + 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) From f60c11b6f8652d5c7ac4708a345de41a1ce3fc47 Mon Sep 17 00:00:00 2001 From: alexj9837 Date: Thu, 2 Apr 2026 10:51:34 +0000 Subject: [PATCH 11/28] updating the chart --- 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 5262df2133..ac21970cff 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.2 +version: 1.12.7 # 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 fb418aad37643278451bf14f25dae349b691f529 Mon Sep 17 00:00:00 2001 From: Alex J Date: Tue, 7 Apr 2026 14:44:01 +0100 Subject: [PATCH 12/28] fix: Last used stamper (#5) * extra comment * adding the bash script to config map, and pointing to it via the cronjob * updating release tag * was calling bin/bash not bin/sh and bitnami/kubectl doesn't have full bash * updating version --- helm/blueapi/Chart.yaml | 2 +- helm/blueapi/templates/configmap.yaml | 27 +++++++++++++++++++++- helm/blueapi/templates/cronjob.yaml | 33 +++++++++++---------------- 3 files changed, 40 insertions(+), 22 deletions(-) diff --git a/helm/blueapi/Chart.yaml b/helm/blueapi/Chart.yaml index ac21970cff..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.7 +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. diff --git a/helm/blueapi/templates/configmap.yaml b/helm/blueapi/templates/configmap.yaml index aa813e6485..15cfbc4d67 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/sh + # 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 de25f7c549..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,28 +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) - 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 e80b4afe10cf54f6fb06d9b7b646d49ea912062b Mon Sep 17 00:00:00 2001 From: Alex J Date: Tue, 7 Apr 2026 15:40:34 +0100 Subject: [PATCH 13/28] fix: Last used stamper (#6) * extra comment * adding the bash script to config map, and pointing to it via the cronjob * updating release tag * was calling bin/bash not bin/sh and bitnami/kubectl doesn't have full bash * updating version * changing default mode as hitting perm errors * update chart version --- helm/blueapi/Chart.yaml | 2 +- helm/blueapi/templates/cronjob.yaml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/helm/blueapi/Chart.yaml b/helm/blueapi/Chart.yaml index 039e2d0d31..385f69f9d1 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.9 +version: 1.13.0 # 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. diff --git a/helm/blueapi/templates/cronjob.yaml b/helm/blueapi/templates/cronjob.yaml index ab4b7a225c..0860467d73 100644 --- a/helm/blueapi/templates/cronjob.yaml +++ b/helm/blueapi/templates/cronjob.yaml @@ -43,7 +43,7 @@ spec: jobTemplate: spec: # amount of attempts of labeling a pvc - backoffLimit: 2 + backoffLimit: 0 # job stops after 60 secounds activeDeadlineSeconds: 60 template: @@ -58,7 +58,7 @@ spec: - name : {{include "blueapi.fullname" . }}-pvc-stamper-script configMap: name: {{include "blueapi.fullname" . }}-pvc-stamper-script - defaultMode: 0500 + defaultMode: 0555 containers: From 2d41034060b525968b3a2bc38c1710fe0e10e8ab Mon Sep 17 00:00:00 2001 From: Alexj9837 Date: Wed, 1 Apr 2026 13:29:50 +0000 Subject: [PATCH 14/28] adding time-stamp cronjob to blueapi and a corasponding test --- helm/blueapi/templates/cronjob.yaml | 78 +++++++++++++++++++ .../blueapi/templates/tests/test-cronjob.yaml | 19 +++++ 2 files changed, 97 insertions(+) create mode 100644 helm/blueapi/templates/cronjob.yaml create mode 100644 helm/blueapi/templates/tests/test-cronjob.yaml diff --git a/helm/blueapi/templates/cronjob.yaml b/helm/blueapi/templates/cronjob.yaml new file mode 100644 index 0000000000..d1ff9bf325 --- /dev/null +++ b/helm/blueapi/templates/cronjob.yaml @@ -0,0 +1,78 @@ +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "blueapi.fullname" . }}-last-used-stamper + namespace: {{ .Release.Namespace }} +automountServiceAccountToken: true +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + name: {{ include "blueapi.fullname" . }}-last-used-stamper + namespace: {{ .Release.Namespace }} +rules: +- apiGroups: [""] + resources: ["pods", "persistentvolumeclaims"] + verbs: ["get", "list", "patch"] +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: {{ include "blueapi.fullname" . }}-last-used-stamper + namespace: {{ .Release.Namespace }} +subjects: +- kind: ServiceAccount + name: {{ include "blueapi.fullname" . }}-last-used-stamper + namespace: {{ .Release.Namespace }} +roleRef: + kind: Role + name: {{ include "blueapi.fullname" . }}-last-used-stamper + apiGroup: rbac.authorization.k8s.io +--- +apiVersion: batch/v1 +kind: CronJob +metadata: + name: {{ include "blueapi.fullname" . }}-last-used-stamper + namespace: {{ .Release.Namespace }} +spec: + concurrencyPolicy: Forbid + successfulJobsHistoryLimit: 3 + failedJobsHistoryLimit: 1 + schedule: "*/5 * * * *" + jobTemplate: + spec: + # amount of attempts of labeling a pvc + backoffLimit: 2 + # job stops after 60 secounds + activeDeadlineSeconds: 60 + template: + spec: + serviceAccountName: {{ include "blueapi.fullname" . }}-last-used-stamper + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 12 }} + {{- end }} + containers: + - name: last-used-stamper + image: bitnami/kubectl:1.34.5 + imagePullPolicy: IfNotPresent + command: + - /bin/sh + - -c + - | + # Get PVCs belonging to this blueapi release + ALL_PVC=$(kubectl get pvc -l "argocd.argoproj.io/instance={{ .Release.Name }}" \ + -o jsonpath='{.items[*].metadata.name}' -n {{ .Release.Namespace }} | tr ' ' '\n') + # 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) + 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 + restartPolicy: OnFailure diff --git a/helm/blueapi/templates/tests/test-cronjob.yaml b/helm/blueapi/templates/tests/test-cronjob.yaml new file mode 100644 index 0000000000..52df70cba5 --- /dev/null +++ b/helm/blueapi/templates/tests/test-cronjob.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Pod +metadata: + name: {{ include "blueapi.fullname" . }}-last-used-stamper + annotations: + "helm.sh/hook": test +spec: + serviceAccountName: {{ include "blueapi.fullname" . }}-last-used-stamper + containers: + - name: test + image: bitnami/kubectl:1.34.5 + command: ["/bin/sh", "-c"] + args: + - | + # Get a pod belonging to this release and annotate it, then verify + kubectl annotate --overwrite pod "$HOSTNAME" -n "{{ .Release.Namespace }}" last-used="$(date +%s)" + kubectl get pod "$HOSTNAME" -n "{{ .Release.Namespace }}" \ + -o jsonpath='{.metadata.annotations.last-used}' | grep -q . + restartPolicy: Never From aa9a062407433fb1cf2a783768bb6e89e34b79a5 Mon Sep 17 00:00:00 2001 From: alexj9837 Date: Wed, 1 Apr 2026 14:30:51 +0000 Subject: [PATCH 15/28] changing version so it publishes a chart --- 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 08097921fb..a82222806c 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: 0.1.0 +version: 1.12.3 # 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 58fdd1e045a95f73bd581c85f696b9ada9602822 Mon Sep 17 00:00:00 2001 From: alexj9837 Date: Wed, 1 Apr 2026 14:47:49 +0000 Subject: [PATCH 16/28] updating 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 a82222806c..958bc197b7 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.3 +version: 1.12.4 # 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 f3c30ec79915f2b69e237249a5de3df8c2c877f4 Mon Sep 17 00:00:00 2001 From: alexj9837 Date: Wed, 1 Apr 2026 15:33:19 +0000 Subject: [PATCH 17/28] updating appversion --- 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 958bc197b7..e557932b26 100644 --- a/helm/blueapi/Chart.yaml +++ b/helm/blueapi/Chart.yaml @@ -20,4 +20,4 @@ version: 1.12.4 # 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. # It is recommended to use it with quotes. -appVersion: "0.1.0" +appVersion: "1.12.4" From 9c8fe93014f2df83d2650b86dd70cd809c579d85 Mon Sep 17 00:00:00 2001 From: alexj9837 Date: Wed, 1 Apr 2026 15:34:52 +0000 Subject: [PATCH 18/28] update chart --- 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 e557932b26..5600bbc353 100644 --- a/helm/blueapi/Chart.yaml +++ b/helm/blueapi/Chart.yaml @@ -20,4 +20,4 @@ version: 1.12.4 # 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. # It is recommended to use it with quotes. -appVersion: "1.12.4" +appVersion: "1.12.2" From 67497facdf85b3c4147b093e10adae04b3e53b79 Mon Sep 17 00:00:00 2001 From: alexj9837 Date: Wed, 1 Apr 2026 16:06:15 +0000 Subject: [PATCH 19/28] reverting app version for tests --- 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 5600bbc353..958bc197b7 100644 --- a/helm/blueapi/Chart.yaml +++ b/helm/blueapi/Chart.yaml @@ -20,4 +20,4 @@ version: 1.12.4 # 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. # It is recommended to use it with quotes. -appVersion: "1.12.2" +appVersion: "0.1.0" From 0242e4248a35d0d8de7297bb9b3c85b150a73853 Mon Sep 17 00:00:00 2001 From: alexj9837 Date: Thu, 2 Apr 2026 07:58:51 +0000 Subject: [PATCH 20/28] updating cronjob version --- helm/blueapi/templates/cronjob.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helm/blueapi/templates/cronjob.yaml b/helm/blueapi/templates/cronjob.yaml index d1ff9bf325..438eb83a5a 100644 --- a/helm/blueapi/templates/cronjob.yaml +++ b/helm/blueapi/templates/cronjob.yaml @@ -54,7 +54,7 @@ spec: {{- end }} containers: - name: last-used-stamper - image: bitnami/kubectl:1.34.5 + image: bitnami/kubectl:1.31.1 imagePullPolicy: IfNotPresent command: - /bin/sh From 3304484a09587340fc1b03f2a8f99ff65036688b Mon Sep 17 00:00:00 2001 From: alexj9837 Date: Thu, 2 Apr 2026 08:06:50 +0000 Subject: [PATCH 21/28] updating chart --- 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 958bc197b7..5262df2133 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.4 +version: 1.12.2 # 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 7d506f758fd51ca3e40d192a2b4a609241d0fa27 Mon Sep 17 00:00:00 2001 From: alexj9837 Date: Thu, 2 Apr 2026 09:16:00 +0000 Subject: [PATCH 22/28] setting to latest --- helm/blueapi/templates/cronjob.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helm/blueapi/templates/cronjob.yaml b/helm/blueapi/templates/cronjob.yaml index 438eb83a5a..228ae2e1a0 100644 --- a/helm/blueapi/templates/cronjob.yaml +++ b/helm/blueapi/templates/cronjob.yaml @@ -54,7 +54,7 @@ spec: {{- end }} containers: - name: last-used-stamper - image: bitnami/kubectl:1.31.1 + image: bitnami/kubectl:latest imagePullPolicy: IfNotPresent command: - /bin/sh From 223eed5c968af8070b9a3dfb0b2a6c4927b22ff0 Mon Sep 17 00:00:00 2001 From: alexj9837 Date: Thu, 2 Apr 2026 10:23:43 +0000 Subject: [PATCH 23/28] updating the script --- helm/blueapi/templates/cronjob.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/helm/blueapi/templates/cronjob.yaml b/helm/blueapi/templates/cronjob.yaml index 228ae2e1a0..de25f7c549 100644 --- a/helm/blueapi/templates/cronjob.yaml +++ b/helm/blueapi/templates/cronjob.yaml @@ -61,8 +61,9 @@ spec: - -c - | # Get PVCs belonging to this blueapi release - ALL_PVC=$(kubectl get pvc -l "argocd.argoproj.io/instance={{ .Release.Name }}" \ - -o jsonpath='{.items[*].metadata.name}' -n {{ .Release.Namespace }} | tr ' ' '\n') + 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) From c657106ac3b3af8e3f28518c0795b27b1b52f5db Mon Sep 17 00:00:00 2001 From: alexj9837 Date: Thu, 2 Apr 2026 10:51:34 +0000 Subject: [PATCH 24/28] updating the chart --- 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 5262df2133..ac21970cff 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.2 +version: 1.12.7 # 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 04903ef7cfb8e8f37a9c3a98d6aa301449f1d0a5 Mon Sep 17 00:00:00 2001 From: Alex J Date: Tue, 7 Apr 2026 14:44:01 +0100 Subject: [PATCH 25/28] fix: Last used stamper (#5) * extra comment * adding the bash script to config map, and pointing to it via the cronjob * updating release tag * was calling bin/bash not bin/sh and bitnami/kubectl doesn't have full bash * updating version --- helm/blueapi/Chart.yaml | 2 +- helm/blueapi/templates/configmap.yaml | 27 +++++++++++++++++++++- helm/blueapi/templates/cronjob.yaml | 33 +++++++++++---------------- 3 files changed, 40 insertions(+), 22 deletions(-) diff --git a/helm/blueapi/Chart.yaml b/helm/blueapi/Chart.yaml index ac21970cff..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.7 +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. diff --git a/helm/blueapi/templates/configmap.yaml b/helm/blueapi/templates/configmap.yaml index aa813e6485..15cfbc4d67 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/sh + # 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 de25f7c549..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,28 +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) - 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 5e302917864a71c429b606c991064e4c4e7c1004 Mon Sep 17 00:00:00 2001 From: Alex J Date: Tue, 7 Apr 2026 15:40:34 +0100 Subject: [PATCH 26/28] fix: Last used stamper (#6) * extra comment * adding the bash script to config map, and pointing to it via the cronjob * updating release tag * was calling bin/bash not bin/sh and bitnami/kubectl doesn't have full bash * updating version * changing default mode as hitting perm errors * update chart version --- helm/blueapi/Chart.yaml | 2 +- helm/blueapi/templates/cronjob.yaml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/helm/blueapi/Chart.yaml b/helm/blueapi/Chart.yaml index 039e2d0d31..385f69f9d1 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.9 +version: 1.13.0 # 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. diff --git a/helm/blueapi/templates/cronjob.yaml b/helm/blueapi/templates/cronjob.yaml index ab4b7a225c..0860467d73 100644 --- a/helm/blueapi/templates/cronjob.yaml +++ b/helm/blueapi/templates/cronjob.yaml @@ -43,7 +43,7 @@ spec: jobTemplate: spec: # amount of attempts of labeling a pvc - backoffLimit: 2 + backoffLimit: 0 # job stops after 60 secounds activeDeadlineSeconds: 60 template: @@ -58,7 +58,7 @@ spec: - name : {{include "blueapi.fullname" . }}-pvc-stamper-script configMap: name: {{include "blueapi.fullname" . }}-pvc-stamper-script - defaultMode: 0500 + defaultMode: 0555 containers: From 582845fc8f33931705dcbb504931784c65c7d9f9 Mon Sep 17 00:00:00 2001 From: alexj9837 Date: Tue, 7 Apr 2026 15:19:15 +0000 Subject: [PATCH 27/28] feat: add last-used-stamper cronjob --- helm/blueapi/README.md | 1 + helm/blueapi/files/scripts/time-stamper.sh | 20 +++++++++++++++ helm/blueapi/templates/configmap.yaml | 25 +++++-------------- helm/blueapi/templates/cronjob.yaml | 7 +++++- .../blueapi/templates/tests/test-cronjob.yaml | 19 -------------- helm/blueapi/values.schema.json | 8 ++++++ helm/blueapi/values.yaml | 3 +++ 7 files changed, 44 insertions(+), 39 deletions(-) create mode 100644 helm/blueapi/files/scripts/time-stamper.sh delete mode 100644 helm/blueapi/templates/tests/test-cronjob.yaml diff --git a/helm/blueapi/README.md b/helm/blueapi/README.md index 3862290fb8..41ccb8827b 100644 --- a/helm/blueapi/README.md +++ b/helm/blueapi/README.md @@ -44,6 +44,7 @@ A Helm chart deploying a worker pod that runs Bluesky plans | serviceAccount.create | bool | `false` | | | serviceAccount.name | string | `""` | | | startupProbe | object | `{"failureThreshold":5,"httpGet":{"path":"/healthz","port":"http"},"periodSeconds":10}` | A more lenient livenessProbe to allow the service to start fully. This is automatically disabled when in debug mode. | +| timeStampCron.enabled | bool | `true` | | | tolerations | list | `[]` | May be required to run on specific nodes (e.g. the control machine) | | tracing | object | `{"fastapi":{"excludedURLs":"/healthz"},"otlp":{"enabled":false,"protocol":"http/protobuf","server":{"host":"http://opentelemetry-collector.tracing","port":4318}}}` | Exclude health probe requests from tracing by default to prevent spamming | | volumeMounts | list | `[{"mountPath":"/config","name":"worker-config","readOnly":true}]` | Additional volumeMounts on the output StatefulSet definition. Define how volumes are mounted to the container referenced by using the same name. | diff --git a/helm/blueapi/files/scripts/time-stamper.sh b/helm/blueapi/files/scripts/time-stamper.sh new file mode 100644 index 0000000000..027e879fd2 --- /dev/null +++ b/helm/blueapi/files/scripts/time-stamper.sh @@ -0,0 +1,20 @@ +#!/bin/sh +# 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 + # Checks if Annotation for last-used is empty + ANNOTATION=$(kubectl get pvc "$pvc" -n $RELEASE_NAMESPACE -o=jsonpath='{.metadata.annotations.last-used}') + # -z checks if ANNOTATION is empty, if its empty or mounted to updates last-used else it ignores it + 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/configmap.yaml b/helm/blueapi/templates/configmap.yaml index 15cfbc4d67..2c834bb31a 100644 --- a/helm/blueapi/templates/configmap.yaml +++ b/helm/blueapi/templates/configmap.yaml @@ -35,27 +35,14 @@ data: --- {{- end }} +--- +{{- if .Values.timeStampCron.enabled }} apiVersion: v1 kind: ConfigMap metadata: name : {{include "blueapi.fullname" . }}-pvc-stamper-script data: - time-stamper.sh: | - #!/bin/sh - # 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 + {{- $files := .Files }} + time-stamper.sh: |- +{{ $files.Get "files/scripts/time-stamper.sh" | indent 4 }} +{{- end }} diff --git a/helm/blueapi/templates/cronjob.yaml b/helm/blueapi/templates/cronjob.yaml index 0860467d73..407936b610 100644 --- a/helm/blueapi/templates/cronjob.yaml +++ b/helm/blueapi/templates/cronjob.yaml @@ -43,7 +43,7 @@ spec: jobTemplate: spec: # amount of attempts of labeling a pvc - backoffLimit: 0 + backoffLimit: 3 # job stops after 60 secounds activeDeadlineSeconds: 60 template: @@ -63,6 +63,11 @@ spec: containers: - name: last-used-stamper + env: + - name: RELEASE_NAME + value: {{ .Release.Name }} + - name: RELEASE_NAMESPACE + value: {{ .Release.Namespace }} volumeMounts: - name: {{include "blueapi.fullname" . }}-pvc-stamper-script mountPath: /scripts diff --git a/helm/blueapi/templates/tests/test-cronjob.yaml b/helm/blueapi/templates/tests/test-cronjob.yaml deleted file mode 100644 index 52df70cba5..0000000000 --- a/helm/blueapi/templates/tests/test-cronjob.yaml +++ /dev/null @@ -1,19 +0,0 @@ -apiVersion: v1 -kind: Pod -metadata: - name: {{ include "blueapi.fullname" . }}-last-used-stamper - annotations: - "helm.sh/hook": test -spec: - serviceAccountName: {{ include "blueapi.fullname" . }}-last-used-stamper - containers: - - name: test - image: bitnami/kubectl:1.34.5 - command: ["/bin/sh", "-c"] - args: - - | - # Get a pod belonging to this release and annotate it, then verify - kubectl annotate --overwrite pod "$HOSTNAME" -n "{{ .Release.Namespace }}" last-used="$(date +%s)" - kubectl get pod "$HOSTNAME" -n "{{ .Release.Namespace }}" \ - -o jsonpath='{.metadata.annotations.last-used}' | grep -q . - restartPolicy: Never diff --git a/helm/blueapi/values.schema.json b/helm/blueapi/values.schema.json index 3159f6713e..5bd7d0735d 100644 --- a/helm/blueapi/values.schema.json +++ b/helm/blueapi/values.schema.json @@ -292,6 +292,14 @@ } } }, + "timeStampCron": { + "type": "object", + "properties": { + "enabled": { + "type": "boolean" + } + } + }, "tolerations": { "description": "May be required to run on specific nodes (e.g. the control machine)", "type": "array" diff --git a/helm/blueapi/values.yaml b/helm/blueapi/values.yaml index 876b37a989..9634d08596 100644 --- a/helm/blueapi/values.yaml +++ b/helm/blueapi/values.yaml @@ -224,6 +224,9 @@ initContainer: # -- Size of persistent volume size: "1Gi" +timeStampCron: + enabled: true + debug: # -- If enabled, runs debugpy, allowing port-forwarding to expose port 5678 or attached vscode instance enabled: false From 1c22291850df132ac5155819c400aacbca009556 Mon Sep 17 00:00:00 2001 From: alexj9837 Date: Wed, 8 Apr 2026 15:22:01 +0000 Subject: [PATCH 28/28] wrapped the job, incase it's disabled --- helm/blueapi/templates/cronjob.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/helm/blueapi/templates/cronjob.yaml b/helm/blueapi/templates/cronjob.yaml index 407936b610..52f5849414 100644 --- a/helm/blueapi/templates/cronjob.yaml +++ b/helm/blueapi/templates/cronjob.yaml @@ -1,3 +1,4 @@ +{{- if .Values.timeStampCron.enabled }} apiVersion: v1 kind: ServiceAccount metadata: @@ -75,3 +76,4 @@ spec: imagePullPolicy: IfNotPresent command: ["/scripts/time-stamper.sh"] restartPolicy: OnFailure +{{- end }}