Skip to content

Commit

Permalink
update the storage-version-migration script to complete execution in …
Browse files Browse the repository at this point in the history
…finite time
  • Loading branch information
ayushsatyam146 committed Sep 16, 2024
1 parent 548678e commit 003851f
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions hack/storage-version-migration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,23 @@ spec:
ttlSecondsAfterFinished: 600
EOF

JOB_NAME=$(kubectl -n shipwright-build get job --selector app=storage-version-migration-shipwright -o jsonpath='{.items[0].metadata.name}')

while [ "$(kubectl -n shipwright-build get job "${JOB_NAME}" -o json | jq -r '.status.completionTime // ""')" == "" ]; do
echo "[INFO] Storage version migraton job is still running"
sleep 10
done
NAMESPACE="shipwright-build"
JOB_NAME=$(kubectl -n "${NAMESPACE}" get job --selector app=storage-version-migration-shipwright -o jsonpath='{.items[0].metadata.name}')

isFailed="$(kubectl -n shipwright-build get job "${JOB_NAME}" -o json | jq -r '.status.conditions[] | select(.type == "Failed") | .status')"
while true; do
jobStatus=$(kubectl get job "${JOB_NAME}" -n "${NAMESPACE}" -o=jsonpath='{.status.conditions[*].type}')

if [ "${isFailed}" == "True" ]; then
echo "[ERROR] Storage version migration failed"
kubectl -n shipwright-build logs "job/${JOB_NAME}"
exit 1
fi
if [[ "${jobStatus}" == *"Complete"* ]]; then
echo "Job ${JOB_NAME} has completed successfully!"
exit 0
elif [[ "${jobStatus}" == *"Failed"* ]]; then
echo "[ERROR] Storage version migration failed"
exit 1
fi

echo "[INFO] Storage version migration job is still running"
sleep 10
done

echo "[DONE]"

0 comments on commit 003851f

Please sign in to comment.