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/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