fix(health): don't degrade status when no nodes are connected
Zero connected nodes is valid for headless/standby deployments. The 5-minute grace period was causing an infinite crash loop: healthz returned 503 after 5min uptime → liveness probe failed → pod restarted. The "no nodes connected" reason is still reported but no longer sets status to degraded. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
ecad097c2b
commit
de272331b6
2 changed files with 6 additions and 5 deletions
|
|
@ -122,9 +122,9 @@ func (c *Checker) check(version string) Response {
|
|||
c.level3Since = time.Time{}
|
||||
}
|
||||
|
||||
// Condition 3: No nodes online after 5 minutes uptime
|
||||
// Condition 3: No nodes online after 5 minutes uptime (informational only,
|
||||
// does not degrade status — zero nodes is valid for headless deployments)
|
||||
if nodesOnline == 0 && uptime > 300 {
|
||||
status = "degraded"
|
||||
if reason == "" {
|
||||
reason = "no nodes connected"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,7 +72,8 @@ func TestHealthCheckDBFailing(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
// TestHealthCheckNoNodes tests that health check returns degraded after 5 min with no nodes.
|
||||
// TestHealthCheckNoNodes tests that health check stays OK after 5 min with no nodes
|
||||
// (zero nodes is valid for headless deployments).
|
||||
func TestHealthCheckNoNodes(t *testing.T) {
|
||||
checker := &Checker{
|
||||
startTime: time.Now().Add(-6 * time.Minute), // 6 minutes ago
|
||||
|
|
@ -88,8 +89,8 @@ func TestHealthCheckNoNodes(t *testing.T) {
|
|||
|
||||
resp := checker.check("1.0.0")
|
||||
|
||||
if resp.Status != "degraded" {
|
||||
t.Errorf("expected status=degraded, got %s", resp.Status)
|
||||
if resp.Status != "ok" {
|
||||
t.Errorf("expected status=ok, got %s", resp.Status)
|
||||
}
|
||||
if resp.Reason != "no nodes connected" {
|
||||
t.Errorf("expected reason='no nodes connected', got %s", resp.Reason)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue