fix(rollback): Fix bash loop syntax for health check retries
This commit is contained in:
@@ -242,7 +242,9 @@ pipeline {
|
|||||||
script {
|
script {
|
||||||
echo "🏥 Running health checks..."
|
echo "🏥 Running health checks..."
|
||||||
|
|
||||||
sh """
|
sh """#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
# Check all pods are ready
|
# Check all pods are ready
|
||||||
READY_PODS=\$(kubectl get deployment ${APP_NAME} -n ${NAMESPACE} -o jsonpath='{.status.readyReplicas}')
|
READY_PODS=\$(kubectl get deployment ${APP_NAME} -n ${NAMESPACE} -o jsonpath='{.status.readyReplicas}')
|
||||||
DESIRED_PODS=\$(kubectl get deployment ${APP_NAME} -n ${NAMESPACE} -o jsonpath='{.spec.replicas}')
|
DESIRED_PODS=\$(kubectl get deployment ${APP_NAME} -n ${NAMESPACE} -o jsonpath='{.spec.replicas}')
|
||||||
@@ -263,14 +265,16 @@ pipeline {
|
|||||||
echo "Testing pod: \${POD_NAME}"
|
echo "Testing pod: \${POD_NAME}"
|
||||||
|
|
||||||
# Test health endpoint with retry
|
# Test health endpoint with retry
|
||||||
for i in {1..5}; do
|
for i in 1 2 3 4 5; do
|
||||||
echo "Health check attempt \$i/5..."
|
echo "Health check attempt \$i/5..."
|
||||||
if kubectl exec \${POD_NAME} -n ${NAMESPACE} -- wget -q -O- http://localhost/health 2>/dev/null; then
|
if kubectl exec \${POD_NAME} -n ${NAMESPACE} -- wget -q -O- http://localhost/health 2>/dev/null; then
|
||||||
echo "✅ Health check passed!"
|
echo "✅ Health check passed!"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
echo "Retrying in 5 seconds..."
|
if [ \$i -lt 5 ]; then
|
||||||
sleep 5
|
echo "Retrying in 5 seconds..."
|
||||||
|
sleep 5
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "❌ Health check failed after 5 attempts"
|
echo "❌ Health check failed after 5 attempts"
|
||||||
|
|||||||
Reference in New Issue
Block a user