Health Checks That Lied
Our pods report healthy but can't serve traffic. How?
The health check:
livenessProbe:
httpGet:
path: /health
port: 8080
The handler:
@GetMapping("/health")
public String health() {
return "OK"; // Always returns OK
}
The problem:
- App starts, returns "OK"
- Database connection fails
- Cache unreachable
- External API timeout
- But health check: "OK" ✅
The better approach:
@GetMapping("/health/ready")
public ResponseEntity<HealthStatus> readiness() {
boolean dbOk = checkDatabase();
boolean cacheOk = checkCache();
if (dbOk && cacheOk) {
return ResponseEntity.ok(status);
}
return ResponseEntity.status(503).body(status);
}
Lesson: A health check that doesn't check health is worse than no health check.