Skip to content

Commit cd930b9

Browse files
jeremyederclaude
andauthored
Fix frontend health check timing issue in smoke tests (#454)
## Summary Fixes the intermittent frontend health check failures in smoke tests by addressing a race condition between pod readiness and NodePort service routing. ## Problem PR #453 and potentially other PRs were failing with: ``` ✗ Frontend not responding ``` Even though: - Pods showed as `Running` and `Ready` - All readiness probes passed - The frontend was actually working This was a timing issue: the smoke test ran immediately after pods became Ready, but NodePort service endpoint propagation can lag slightly behind pod readiness state. ## Solution 1. **Added explicit pod readiness wait** using `kubectl wait --for=condition=ready` 2. **Implemented retry logic** for health checks (5 attempts with 2s delays) 3. **Fixed deployment timeout handling** in GitHub Actions to properly fail the job ## Testing The fix has been tested on branch `fix-frontend-smoke-test-timing` and successfully addresses the timing issue. ## Related Issues - Fixes failures from: https://github.com/ambient-code/platform/actions/runs/20064017469/job/57547783304 - Will allow PR #453 and other PRs to pass smoke tests reliably 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent cd9577b commit cd930b9

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

.github/workflows/test-local-dev.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,19 @@ jobs:
4444
echo "⚠️ Backend deployment timeout - showing status"
4545
kubectl get pods -n ambient-code -o wide
4646
kubectl describe deployment backend-api -n ambient-code | tail -50
47+
exit 1
4748
}
4849
kubectl wait --for=condition=available --timeout=180s deployment/frontend -n ambient-code || {
4950
echo "⚠️ Frontend deployment timeout - showing status"
5051
kubectl get pods -n ambient-code -o wide
5152
kubectl describe deployment frontend -n ambient-code | tail -50
53+
exit 1
5254
}
5355
kubectl wait --for=condition=available --timeout=180s deployment/agentic-operator -n ambient-code || {
5456
echo "⚠️ Operator deployment timeout - showing status"
5557
kubectl get pods -n ambient-code -o wide
5658
kubectl describe deployment agentic-operator -n ambient-code | tail -50
59+
exit 1
5760
}
5861
5962
- name: Run Makefile smoke tests

Makefile

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -355,12 +355,28 @@ local-test-quick: check-kubectl check-minikube ## Quick smoke test of local envi
355355
@minikube status >/dev/null 2>&1 && echo "$(COLOR_GREEN)$(COLOR_RESET) Minikube running" || (echo "$(COLOR_RED)$(COLOR_RESET) Minikube not running" && exit 1)
356356
@echo "$(COLOR_BLUE)$(COLOR_RESET) Testing namespace..."
357357
@kubectl get namespace $(NAMESPACE) >/dev/null 2>&1 && echo "$(COLOR_GREEN)$(COLOR_RESET) Namespace exists" || (echo "$(COLOR_RED)$(COLOR_RESET) Namespace missing" && exit 1)
358-
@echo "$(COLOR_BLUE)$(COLOR_RESET) Testing pods..."
359-
@kubectl get pods -n $(NAMESPACE) 2>/dev/null | grep -q "Running" && echo "$(COLOR_GREEN)$(COLOR_RESET) Pods running" || (echo "$(COLOR_RED)$(COLOR_RESET) No pods running" && exit 1)
358+
@echo "$(COLOR_BLUE)$(COLOR_RESET) Waiting for pods to be ready..."
359+
@kubectl wait --for=condition=ready pod -l app=backend -n $(NAMESPACE) --timeout=60s >/dev/null 2>&1 && \
360+
kubectl wait --for=condition=ready pod -l app=frontend -n $(NAMESPACE) --timeout=60s >/dev/null 2>&1 && \
361+
echo "$(COLOR_GREEN)$(COLOR_RESET) Pods ready" || (echo "$(COLOR_RED)$(COLOR_RESET) Pods not ready" && exit 1)
360362
@echo "$(COLOR_BLUE)$(COLOR_RESET) Testing backend health..."
361-
@curl -sf http://$$(minikube ip):30080/health >/dev/null 2>&1 && echo "$(COLOR_GREEN)$(COLOR_RESET) Backend healthy" || (echo "$(COLOR_RED)$(COLOR_RESET) Backend not responding" && exit 1)
363+
@for i in 1 2 3 4 5; do \
364+
curl -sf http://$$(minikube ip):30080/health >/dev/null 2>&1 && { echo "$(COLOR_GREEN)$(COLOR_RESET) Backend healthy"; break; } || { \
365+
if [ $$i -eq 5 ]; then \
366+
echo "$(COLOR_RED)$(COLOR_RESET) Backend not responding after 5 attempts"; exit 1; \
367+
fi; \
368+
sleep 2; \
369+
}; \
370+
done
362371
@echo "$(COLOR_BLUE)$(COLOR_RESET) Testing frontend..."
363-
@curl -sf http://$$(minikube ip):30030 >/dev/null 2>&1 && echo "$(COLOR_GREEN)$(COLOR_RESET) Frontend accessible" || (echo "$(COLOR_RED)$(COLOR_RESET) Frontend not responding" && exit 1)
372+
@for i in 1 2 3 4 5; do \
373+
curl -sf http://$$(minikube ip):30030 >/dev/null 2>&1 && { echo "$(COLOR_GREEN)$(COLOR_RESET) Frontend accessible"; break; } || { \
374+
if [ $$i -eq 5 ]; then \
375+
echo "$(COLOR_RED)$(COLOR_RESET) Frontend not responding after 5 attempts"; exit 1; \
376+
fi; \
377+
sleep 2; \
378+
}; \
379+
done
364380
@echo ""
365381
@echo "$(COLOR_GREEN)✓ Quick smoke test passed!$(COLOR_RESET)"
366382

0 commit comments

Comments
 (0)