Add detailed debug output to API verify-deploy
Show deployment spec image to confirm patch worked, dump all pod details (image, ready, phase, restarts, reason) on attempts 1/10/30 and on failure. This will reveal whether pods are crashlooping, stuck in Pending, or if the deployment patch didn't take effect.
This commit is contained in:
parent
67d4ab3821
commit
268f4fd272
1 changed files with 28 additions and 4 deletions
32
.drone.yml
32
.drone.yml
|
|
@ -284,21 +284,36 @@ steps:
|
||||||
TOKEN=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token)
|
TOKEN=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token)
|
||||||
EXPECTED_IMAGE="viktorbarzin/realestatecrawler:${DRONE_BUILD_NUMBER}"
|
EXPECTED_IMAGE="viktorbarzin/realestatecrawler:${DRONE_BUILD_NUMBER}"
|
||||||
BASE_API="https://kubernetes:6443/api/v1/namespaces/realestate-crawler/pods"
|
BASE_API="https://kubernetes:6443/api/v1/namespaces/realestate-crawler/pods"
|
||||||
|
DEPLOY_API="https://kubernetes:6443/apis/apps/v1/namespaces/realestate-crawler/deployments"
|
||||||
|
|
||||||
for DEPLOY in realestate-crawler-api realestate-crawler-celery realestate-crawler-celery-beat; do
|
for DEPLOY in realestate-crawler-api realestate-crawler-celery realestate-crawler-celery-beat; do
|
||||||
echo "Verifying $DEPLOY..."
|
echo "Verifying $DEPLOY..."
|
||||||
PODS_API="$BASE_API?labelSelector=app%3D$DEPLOY"
|
PODS_API="$BASE_API?labelSelector=app%3D$DEPLOY"
|
||||||
|
|
||||||
|
# Check deployment spec to confirm patch took effect
|
||||||
|
DEPLOY_IMAGE=$(curl -sfk "$DEPLOY_API/$DEPLOY" \
|
||||||
|
-H "Authorization: Bearer $TOKEN" \
|
||||||
|
-H "Accept: application/json" | \
|
||||||
|
jq -r '.spec.template.spec.containers[0].image' 2>/dev/null)
|
||||||
|
echo " Deployment spec image: $DEPLOY_IMAGE"
|
||||||
|
|
||||||
FOUND=0
|
FOUND=0
|
||||||
for i in $(seq 1 60); do
|
for i in $(seq 1 60); do
|
||||||
RAW=$(curl -sfk "$PODS_API" \
|
RAW=$(curl -sfk "$PODS_API" \
|
||||||
-H "Authorization: Bearer $TOKEN" \
|
-H "Authorization: Bearer $TOKEN" \
|
||||||
-H "Accept: application/json")
|
-H "Accept: application/json")
|
||||||
|
|
||||||
# Debug: show all pod images and status on first attempt
|
# Debug: show all pod images and status periodically
|
||||||
if [ "$i" -eq 1 ]; then
|
if [ "$i" -eq 1 ] || [ "$i" -eq 10 ] || [ "$i" -eq 30 ]; then
|
||||||
echo " DEBUG: All pods for $DEPLOY:"
|
echo " DEBUG (attempt $i): All pods for $DEPLOY:"
|
||||||
echo "$RAW" | jq -r '[.items[] | {name: .metadata.name, image: .spec.containers[0].image, ready: (.status.containerStatuses[]? | .ready), phase: .status.phase}] | .[] | " \(.name) image=\(.image) ready=\(.ready) phase=\(.phase)"' 2>/dev/null || echo " (no pods found)"
|
echo "$RAW" | jq -r '[.items[] | {
|
||||||
|
name: .metadata.name,
|
||||||
|
image: .spec.containers[0].image,
|
||||||
|
ready: ([.status.containerStatuses[]? | .ready] | first // "unknown"),
|
||||||
|
phase: .status.phase,
|
||||||
|
restarts: ([.status.containerStatuses[]? | .restartCount] | first // 0),
|
||||||
|
reason: ([.status.containerStatuses[]? | .state | to_entries[] | .value.reason // empty] | first // "running")
|
||||||
|
}] | .[] | " \(.name) image=\(.image) ready=\(.ready) phase=\(.phase) restarts=\(.restarts) reason=\(.reason)"' 2>/dev/null || echo " (no pods or parse error)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
RESULT=$(echo "$RAW" | \
|
RESULT=$(echo "$RAW" | \
|
||||||
|
|
@ -321,6 +336,15 @@ steps:
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ "$FOUND" -ne 1 ]; then
|
if [ "$FOUND" -ne 1 ]; then
|
||||||
|
echo " FINAL DEBUG: All pods for $DEPLOY:"
|
||||||
|
echo "$RAW" | jq -r '[.items[] | {
|
||||||
|
name: .metadata.name,
|
||||||
|
image: .spec.containers[0].image,
|
||||||
|
ready: ([.status.containerStatuses[]? | .ready] | first // "unknown"),
|
||||||
|
phase: .status.phase,
|
||||||
|
restarts: ([.status.containerStatuses[]? | .restartCount] | first // 0),
|
||||||
|
reason: ([.status.containerStatuses[]? | .state | to_entries[] | .value.reason // empty] | first // "running")
|
||||||
|
}] | .[] | " \(.name) image=\(.image) ready=\(.ready) phase=\(.phase) restarts=\(.restarts) reason=\(.reason)"' 2>/dev/null || echo " (no pods or parse error)"
|
||||||
echo "ERROR: No new ready pod for $DEPLOY with image $EXPECTED_IMAGE appeared within 5 minutes"
|
echo "ERROR: No new ready pod for $DEPLOY with image $EXPECTED_IMAGE appeared within 5 minutes"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue