Skip to content

Commit 60f84a1

Browse files
committed
reduced the history of successful jobs, updated deletion script
1 parent 2e8363a commit 60f84a1

2 files changed

Lines changed: 8 additions & 11 deletions

File tree

helm/blueapi/files/scripts/pvc-deletion.sh

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,21 @@ NOW=$(date +%s)
66
#loop through all pvcs.
77
for pvc in $BLUEAPI_PVCS; do
88
#check if pvc has last-used annotation
9-
if kubectl get pvc $pvc -n $RELEASE_NAMESPACE -o=jsonpath='{.metadata.annotations.last-used}'
10-
then
119
#get last used annotation
12-
LAST_USED=$(kubectl get pvc $pvc -n $RELEASE_NAMESPACE -o=jsonpath='{.metadata.annotations.last-used}')
10+
LAST_USED=$(kubectl get pvc "$pvc" -n $RELEASE_NAMESPACE -o=jsonpath='{.metadata.annotations.last-used}')
1311
#checking if its not null
1412
if [ -n "$LAST_USED" ]; then
1513
#check if last_used is older than 3 months
1614
if [ $(($NOW - LAST_USED)) -gt 7884000 ]; then
1715
#checking if the pvc is protected, if it is protected skip deletion
18-
if [ "$(kubectl get pvc $pvc -n $RELEASE_NAMESPACE -o=jsonpath='{.metadata.annotations.protected}')" = "true" ]; then
19-
echo "PVC $pvc is protected, skipping deletion"
16+
if [ "$(kubectl get pvc "$pvc" -n $RELEASE_NAMESPACE -o=jsonpath='{.metadata.annotations.protected}')" = "true" ]; then
17+
echo " PVC $pvc is protected, skipping deletion"
2018
continue
2119
fi
2220
#PVC has not been used for more than three months, delete it
2321
kubectl delete pvc "$pvc" -n $RELEASE_NAMESPACE
2422
fi
25-
fi
26-
else
27-
echo "PVC $pvc does not have last-used annotation, skipping deletion"
23+
else
24+
echo " $pvc has no last-used annotation"
2825
fi
2926
done

helm/blueapi/templates/cronjob.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ metadata:
3737
namespace: {{ .Release.Namespace }}
3838
spec:
3939
concurrencyPolicy: Forbid
40-
successfulJobsHistoryLimit: 3
40+
successfulJobsHistoryLimit: 1
4141
failedJobsHistoryLimit: 1
4242
schedule: "*/5 * * * *"
4343

@@ -122,13 +122,13 @@ metadata:
122122
namespace: {{ .Release.Namespace }}
123123
spec:
124124
concurrencyPolicy: Forbid
125-
successfulJobsHistoryLimit: 3
125+
successfulJobsHistoryLimit: 1
126126
failedJobsHistoryLimit: 1
127127
schedule: "@weekly"
128128

129129
jobTemplate:
130130
spec:
131-
# amount of attempts of labeling a pvc
131+
# amount of attempts for pvc deletion
132132
backoffLimit: 3
133133
# job stops after 300 seconds
134134
activeDeadlineSeconds: 300

0 commit comments

Comments
 (0)