fix: anti-zombie polling — curl timeout + adaptive MAX_RETRY

This commit is contained in:
2026-04-23 14:30:13 +08:00
parent 4f870a5c16
commit d5a38eb0f5

View File

@@ -50,22 +50,24 @@ HTTP_STATUS=$(curl -s -o /tmp/portainer_response.json -w "%{http_code}" \
if [ "$HTTP_STATUS" = "524" ] || [ "$HTTP_STATUS" = "504" ] || [ "$HTTP_STATUS" = "408" ]; then
echo "⚠️ HTTP $HTTP_STATUS (gateway timeout) — Portainer tetap memproses redeploy, lanjut polling container..."
MAX_RETRY=60
elif [ "$HTTP_STATUS" != "200" ]; then
echo "❌ Redeploy gagal! HTTP Status: $HTTP_STATUS"
cat /tmp/portainer_response.json | jq . 2>/dev/null || true
exit 1
else
MAX_RETRY=30
fi
echo "⏳ Menunggu container running..."
echo "⏳ Menunggu container running (max $((MAX_RETRY * 10))s)..."
MAX_RETRY=15
COUNT=0
while [ $COUNT -lt $MAX_RETRY ]; do
sleep 5
sleep 10
COUNT=$((COUNT + 1))
CONTAINERS=$(curl -s -X GET \
CONTAINERS=$(curl -s --max-time 10 -X GET \
"https://${PORTAINER_URL}/api/endpoints/${ENDPOINT_ID}/docker/containers/json?all=true&filters=%7B%22label%22%3A%5B%22com.docker.compose.project%3D${STACK_NAME}%22%5D%7D" \
-H "Authorization: Bearer ${TOKEN}")
@@ -91,5 +93,5 @@ while [ $COUNT -lt $MAX_RETRY ]; do
done
echo ""
echo "❌ Timeout! Stack tidak kunjung running setelah $((MAX_RETRY * 5)) detik."
echo "❌ Timeout! Stack tidak kunjung running setelah $((MAX_RETRY * 10)) detik."
exit 1