Skip to content

Commit c9c6917

Browse files
authored
Update time-stamper.sh
removing the logic for if the pvc wasn't mounted. now only annotates mounted pvcs.
1 parent 09cc9c2 commit c9c6917

1 file changed

Lines changed: 2 additions & 13 deletions

File tree

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,9 @@
11
#!/bin/sh
2-
# Get PVCs belonging to this blueapi release
3-
ALL_PVC=$(kubectl get pvc -n $RELEASE_NAMESPACE \
4-
-o jsonpath='{.items[*].metadata.name}' | tr ' ' '\n' | \
5-
grep "^$RELEASE_NAME-scratch-")
62
# Get all PVCs currently mounted by running pods
73
MOUNTED_PVCS=$(kubectl get pods -n $RELEASE_NAMESPACE \
84
-o=jsonpath='{.items[*].spec.volumes[*].persistentVolumeClaim.claimName}' | tr ' ' '\n' | sort -u)
95
NOW=$(date +%s)
10-
#loop through all the pvcs annotating ones thare are mounted or lack a last-used stamp
11-
for pvc in $ALL_PVC; do
12-
# Checks if Annotation for last-used is empty
13-
ANNOTATION=$(kubectl get pvc "$pvc" -n $RELEASE_NAMESPACE -o=jsonpath='{.metadata.annotations.last-used}')
14-
# -z checks if ANNOTATION is empty, if its empty or mounted to updates last-used else it ignores it
15-
if [ -z "$ANNOTATION" ]; then
6+
#loop through all the pvcs annotating ones thare are mounted
7+
for pvc in $MOUNTED_PVCS; do
168
kubectl annotate --overwrite pvc "$pvc" -n $RELEASE_NAMESPACE last-used="$NOW"
17-
elif echo "$MOUNTED_PVCS" | grep -qx "$pvc"; then
18-
kubectl annotate --overwrite pvc "$pvc" -n $RELEASE_NAMESPACE last-used="$NOW"
19-
fi
209
done

0 commit comments

Comments
 (0)