From 268f4fd2720ec5f9239e4733b7c2b81d169aeb61 Mon Sep 17 00:00:00 2001 From: Viktor Barzin Date: Sun, 22 Feb 2026 18:35:20 +0000 Subject: [PATCH] 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. --- .drone.yml | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/.drone.yml b/.drone.yml index 328c560..97b07c6 100644 --- a/.drone.yml +++ b/.drone.yml @@ -284,21 +284,36 @@ steps: TOKEN=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token) EXPECTED_IMAGE="viktorbarzin/realestatecrawler:${DRONE_BUILD_NUMBER}" 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 echo "Verifying $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 for i in $(seq 1 60); do RAW=$(curl -sfk "$PODS_API" \ -H "Authorization: Bearer $TOKEN" \ -H "Accept: application/json") - # Debug: show all pod images and status on first attempt - if [ "$i" -eq 1 ]; then - echo " DEBUG: 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)" + # Debug: show all pod images and status periodically + if [ "$i" -eq 1 ] || [ "$i" -eq 10 ] || [ "$i" -eq 30 ]; then + 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] | 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 RESULT=$(echo "$RAW" | \ @@ -321,6 +336,15 @@ steps: done 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" exit 1 fi