diff --git a/.drone.yml b/.drone.yml index 28af895..328c560 100644 --- a/.drone.yml +++ b/.drone.yml @@ -131,19 +131,27 @@ steps: PODS_API="https://kubernetes:6443/api/v1/namespaces/realestate-crawler/pods?labelSelector=app%3Drealestate-crawler-ui" for i in $(seq 1 60); do - RESULT=$(curl -sfk "$PODS_API" \ + RAW=$(curl -sfk "$PODS_API" \ -H "Authorization: Bearer $TOKEN" \ - -H "Accept: application/json" | \ + -H "Accept: application/json") + + # Debug: show all pod images and status on first attempt + if [ "$i" -eq 1 ]; then + echo "DEBUG: All pods for realestate-crawler-ui:" + 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)" + fi + + RESULT=$(echo "$RAW" | \ jq --arg img "$EXPECTED_IMAGE" '[.items[] | select( (.status.containerStatuses[]? | .ready == true) and - (.spec.containers[]? | .image == $img) - ) | {name: .metadata.name, age: (now - (.status.startTime | fromdateiso8601) | floor), image: .spec.containers[0].image, started: .status.startTime}]') + (.spec.containers[]? | .image | endswith($img)) + ) | {name: .metadata.name, image: .spec.containers[0].image, started: .status.startTime}]') COUNT=$(echo "$RESULT" | jq 'length') - echo "Attempt $i/60: $COUNT pod(s) ready, running $EXPECTED_IMAGE" + echo "Attempt $i/60: $COUNT pod(s) ready with image matching $EXPECTED_IMAGE" if [ "$COUNT" -gt 0 ]; then - echo "$RESULT" | jq -r '.[] | " \(.name) age=\(.age)s image=\(.image) started=\(.started)"' + echo "$RESULT" | jq -r '.[] | " \(.name) image=\(.image) started=\(.started)"' echo "New pod is live!" exit 0 fi @@ -283,19 +291,27 @@ steps: FOUND=0 for i in $(seq 1 60); do - RESULT=$(curl -sfk "$PODS_API" \ + RAW=$(curl -sfk "$PODS_API" \ -H "Authorization: Bearer $TOKEN" \ - -H "Accept: application/json" | \ + -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)" + fi + + RESULT=$(echo "$RAW" | \ jq --arg img "$EXPECTED_IMAGE" '[.items[] | select( (.status.containerStatuses[]? | .ready == true) and - (.spec.containers[]? | .image == $img) - ) | {name: .metadata.name, age: (now - (.status.startTime | fromdateiso8601) | floor), image: .spec.containers[0].image, started: .status.startTime}]') + (.spec.containers[]? | .image | endswith($img)) + ) | {name: .metadata.name, image: .spec.containers[0].image, started: .status.startTime}]') COUNT=$(echo "$RESULT" | jq 'length' 2>/dev/null || echo 0) - echo " Attempt $i/60: $COUNT pod(s) ready, running $EXPECTED_IMAGE" + echo " Attempt $i/60: $COUNT pod(s) ready with image matching $EXPECTED_IMAGE" if [ "$COUNT" -gt 0 ] 2>/dev/null; then - echo "$RESULT" | jq -r '.[] | " \(.name) age=\(.age)s image=\(.image) started=\(.started)"' + echo "$RESULT" | jq -r '.[] | " \(.name) image=\(.image) started=\(.started)"' echo "$DEPLOY is live!" FOUND=1 break