Skip to content

Commit 82f8189

Browse files
committed
add mediawiki update job verification script
1 parent 5e60f01 commit 82f8189

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

k8s/jobs/mediawikiUpdate.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,7 @@ kubectl create -f mediawikiUpdate.yaml -o=json --dry-run=client | \
3636
jq --arg wbs "$WBS_DOMAIN" --arg mwver "$MW_VERSION" '.[0].spec.template.spec.containers[0].env += [{"name": "WBS_DOMAIN", "value": $wbs}, {"name": "MW_VERSION", "value": $mwver}]' | \
3737
# return just the Job spec (dropping the existing Pod one)
3838
jq '.[0]' | \
39+
# add a k8s label to the job object with the wiki domain
40+
jq --arg wbs "$WBS_DOMAIN" '.metadata.labels += {"wikiDomain": $wbs}' | \
3941
# create the now fully formed Job from the spec
4042
kubectl create -f -

k8s/jobs/verifyMediawikiUpdates.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
3+
JOBS=$(kubectl get jobs -n adhoc-jobs -o json)
4+
5+
COMPLETED=$(echo $JOBS | jq -r '.items[] | select((.status.succeeded // 0) >= 1 and (.metadata.labels | has("wikiDomain"))) | "\(.metadata.name)\t\(.metadata.labels.wikiDomain)"')
6+
7+
INCOMPLETE=$(echo $JOBS | jq -r '.items[] | select((.status.succeeded // 0) < 1 and (.metadata.labels | has("wikiDomain"))) | "\(.metadata.name)\t\(.metadata.labels.wikiDomain)"')
8+
# alternative query for incomplete jobs without wikiDomain label
9+
#INCOMPLETE=$(echo $JOBS | jq -r '.items[] | select((.status.succeeded // 0) < 1) | "\(.metadata.name)"')
10+
11+
COMPLETED_COUNT=$(echo "$COMPLETED" | wc -l)
12+
INCOMPLETE_COUNT=$(echo "$INCOMPLETE" | wc -l)
13+
14+
15+
echo "Completed jobs:"
16+
echo "$COMPLETED"
17+
echo
18+
echo "Number of completed jobs: $COMPLETED_COUNT"
19+
echo
20+
echo '---'
21+
echo
22+
echo "Incomplete jobs:"
23+
echo "$INCOMPLETE"
24+
echo
25+
echo "Number of completed jobs (may say 1 if list is empty): $INCOMPLETE_COUNT"

0 commit comments

Comments
 (0)