Skip to content

Commit 2091626

Browse files
committed
4.1.1
1 parent 1a83bf0 commit 2091626

1 file changed

Lines changed: 60 additions & 2 deletions

File tree

deployer-image/scripts/deploy.sh

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,67 @@ terraform apply \
6969
EXIT_CODE=$?
7070
if [ $EXIT_CODE -eq 0 ]; then
7171
echo "[INFO] Terraform apply complete at $(date)!"
72+
echo "[INFO] Deployment completed successfully. Checking deployed resources..."
73+
74+
# Output pod statuses to stdout so they're captured in logs
75+
# This helps diagnose why wait_for_ready.py might timeout
76+
if command -v kubectl >/dev/null 2>&1; then
77+
# Get namespace from service account if available
78+
namespace=""
79+
if [ -f /var/run/secrets/kubernetes.io/serviceaccount/namespace ]; then
80+
namespace=$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace 2>/dev/null || echo "")
81+
fi
82+
83+
echo "[INFO] ========== POST-DEPLOYMENT STATUS CHECK =========="
84+
85+
# Check stackgen namespace pods
86+
if kubectl get namespace stackgen >/dev/null 2>&1; then
87+
echo "[INFO] --- Pods in stackgen namespace ---"
88+
kubectl get pods -n stackgen -o wide 2>&1 | tee /dev/stderr || true
89+
90+
echo "[INFO] --- Pod status details ---"
91+
for pod in $(kubectl get pods -n stackgen -o jsonpath='{.items[*].metadata.name}' 2>/dev/null || echo ""); do
92+
if [ -n "$pod" ]; then
93+
phase=$(kubectl get pod -n stackgen "$pod" -o jsonpath='{.status.phase}' 2>&1 || echo "Unknown")
94+
ready=$(kubectl get pod -n stackgen "$pod" -o jsonpath='{.status.conditions[?(@.type=="Ready")].status}' 2>&1 || echo "Unknown")
95+
echo "[INFO] Pod: $pod | Phase: $phase | Ready: $ready"
96+
97+
# If pod is not ready, show why
98+
if [ "$ready" != "True" ] && [ "$phase" != "Running" ]; then
99+
echo "[WARNING] Pod $pod is not ready. Showing details:"
100+
kubectl describe pod -n stackgen "$pod" 2>&1 | grep -A 10 "Status:\|Events:" | tee /dev/stderr || true
101+
echo "[WARNING] Last 30 lines of logs from $pod:"
102+
kubectl logs -n stackgen "$pod" --tail=30 2>&1 | tee /dev/stderr || true
103+
fi
104+
fi
105+
done
106+
107+
# Show events
108+
echo "[INFO] --- Recent events in stackgen namespace ---"
109+
kubectl get events -n stackgen --sort-by='.lastTimestamp' 2>&1 | tail -20 | tee /dev/stderr || true
110+
else
111+
echo "[WARNING] stackgen namespace does not exist - this may indicate a deployment issue"
112+
fi
113+
114+
# Show current namespace resources if available
115+
if [ -n "$namespace" ]; then
116+
echo "[INFO] --- Jobs in current namespace ($namespace) ---"
117+
kubectl get jobs -n "$namespace" -o wide 2>&1 | tee /dev/stderr || true
118+
fi
119+
120+
echo "[INFO] ========== END POST-DEPLOYMENT STATUS CHECK =========="
121+
else
122+
echo "[WARNING] kubectl not available - skipping pod status check"
123+
fi
124+
125+
echo "[INFO] Deployment script completed successfully at $(date)"
72126
else
127+
echo "[ERROR] ========== TERRAFORM APPLY FAILED =========="
73128
echo "[ERROR] Terraform apply failed with exit code $EXIT_CODE at $(date)!"
74-
echo "[DEBUG] Showing Terraform state for debugging:"
75-
terraform show -no-color || true
129+
echo "[ERROR] Showing Terraform state for debugging:"
130+
terraform show -no-color 2>&1 | tee /dev/stderr || true
131+
echo "[ERROR] Showing Terraform plan output:"
132+
terraform plan -detailed-exitcode -var "suffix=${SUFFIX}" -var "domain=${DOMAIN}" -var "STACKGEN_PAT=${STACKGEN_PAT}" -var "pre_shared_cert_name=${PRE_SHARED_CERT_NAME}" -var "global_static_ip_name=${GLOBAL_STATIC_IP_NAME}" 2>&1 | tee /dev/stderr || true
133+
echo "[ERROR] ========== END ERROR OUTPUT =========="
76134
exit $EXIT_CODE
77135
fi

0 commit comments

Comments
 (0)