mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-09-10 02:25:56 +00:00
Keep missing health telemetry non-green
Change-source: pulse-maintainer
This commit is contained in:
@@ -89,6 +89,13 @@ func EvaluateResourceHealth(resource Resource, alerts []ResourceHealthAlert, now
|
||||
|
||||
switch strings.ToLower(strings.TrimSpace(string(resource.Status))) {
|
||||
case "online", "running", "ready", "healthy", "available", "active", "up":
|
||||
// A positive provider status without an observation timestamp is not
|
||||
// enough to prove current health. Some compatibility and synthetic
|
||||
// producers do not populate SourceStatus, so keep this guard at the
|
||||
// canonical verdict boundary rather than relying on that map alone.
|
||||
if resource.LastSeen.IsZero() {
|
||||
return healthWithReason(HealthUnknown, "telemetry_missing", "")
|
||||
}
|
||||
return ResourceHealth{Verdict: HealthOK, Reasons: []ResourceHealthReason{}}
|
||||
case "warning", "degraded", "unhealthy", "pending":
|
||||
return healthWithReason(HealthAttention, "degraded", "")
|
||||
|
||||
@@ -59,6 +59,11 @@ func TestEvaluateResourceHealthPrecedenceAndVerdicts(t *testing.T) {
|
||||
resource: Resource{ID: "host-3", Type: ResourceTypeAgent, Status: StatusOnline, LastSeen: now},
|
||||
want: HealthOK,
|
||||
},
|
||||
{
|
||||
name: "positive status without telemetry cannot be healthy",
|
||||
resource: Resource{ID: "host-missing", Type: ResourceTypeAgent, Status: StatusOnline},
|
||||
want: HealthUnknown, code: "telemetry_missing",
|
||||
},
|
||||
{
|
||||
name: "informational alert does not invent attention",
|
||||
resource: Resource{ID: "host-info", Type: ResourceTypeAgent, Status: StatusOnline, LastSeen: now},
|
||||
|
||||
Reference in New Issue
Block a user