fix(ci): don't hang forever waiting for migration job to complete
This commit is contained in:
@@ -305,7 +305,30 @@ jobs:
|
|||||||
- name: Wait for migration to complete
|
- name: Wait for migration to complete
|
||||||
run: |
|
run: |
|
||||||
TAG=${{ github.event.release.tag_name }}
|
TAG=${{ github.event.release.tag_name }}
|
||||||
kubectl wait --for=condition=complete --timeout=120s -n optima job/prisma-migrate-${TAG}
|
JOB="job/prisma-migrate-${TAG}"
|
||||||
|
|
||||||
|
# Wait for either success or failure — whichever comes first.
|
||||||
|
kubectl wait --for=condition=complete --timeout=180s -n optima "$JOB" &
|
||||||
|
WAIT_COMPLETE=$!
|
||||||
|
kubectl wait --for=condition=failed --timeout=180s -n optima "$JOB" &
|
||||||
|
WAIT_FAILED=$!
|
||||||
|
|
||||||
|
# wait -n returns when the first background job exits
|
||||||
|
wait -n $WAIT_COMPLETE $WAIT_FAILED
|
||||||
|
FIRST_EXIT=$?
|
||||||
|
|
||||||
|
# Print logs regardless of outcome so failures are diagnosable
|
||||||
|
echo "--- Migration pod logs ---"
|
||||||
|
kubectl logs -n optima -l app=prisma-migrate --tail=200 || true
|
||||||
|
|
||||||
|
# Determine outcome by checking the job's actual conditions
|
||||||
|
if kubectl get -n optima "$JOB" -o jsonpath='{.status.conditions[?(@.type=="Complete")].status}' | grep -q "True"; then
|
||||||
|
echo "Migration completed successfully."
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
echo "Migration FAILED."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
deploy-api:
|
deploy-api:
|
||||||
name: Deploy - API
|
name: Deploy - API
|
||||||
|
|||||||
Reference in New Issue
Block a user