Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Stop stale container health alerts after exit
rcourtmane70fd875cc46
diff --git a/docs/release-control/v6/internal/subsystems/alerts.md b/docs/release-control/v6/internal/subsystems/alerts.mdindex b6eeb68476..b31459c9a0 100644--- a/docs/release-control/v6/internal/subsystems/alerts.md+++ b/docs/release-control/v6/internal/subsystems/alerts.md@@ -37,6 +37,11 @@ Docker and Podman container CPU thresholds evaluate host-capacity-normalizedCPU percent, not Docker's runtime-native per-core percent. Alert metadata maycarry the raw per-core value and reporting host CPU count for evidence, but thethreshold value and canonical `cpuPercent` metadata remain normalized.+Docker and Podman container health is live evidence only while the container+state is `running`. Runtime APIs retain the last health-check result after exit+and suspend health checks in other non-running states, so those stale values+must clear rather than raise `docker-container-health`; the canonical runtime+state lifecycle owns the non-running condition.Proxmox VM and LXC CPU thresholds consume the same canonical guest CPU-percentnormalizer as unified live state and guest history. Proxmox guest CPU is theauthoritative observation for that guest; a Pulse host agent running inside thediff --git a/docs/releases/RELEASE_NOTES_v6.4.0-rc.1.md b/docs/releases/RELEASE_NOTES_v6.4.0-rc.1.mdindex 054907e507..28da8b3c92 100644--- a/docs/releases/RELEASE_NOTES_v6.4.0-rc.1.md+++ b/docs/releases/RELEASE_NOTES_v6.4.0-rc.1.md@@ -51,6 +51,8 @@ build path.- Re-enrollment clears host-removal blocks from every owning store so a validreturning agent is not held in a partially removed state.- Connection alerts can no longer bypass the configured offline-alert policy.+- Stopped Docker and Podman containers no longer re-fire health alerts from the+ stale health-check result retained by the container runtime.- Agent reinstall and hosted enrollment preserve command-policy intent insteadof silently dropping the command-execution posture.- Discovery resolves known equivalent forked host identities when matchingdiff --git a/internal/alerts/alerts_test.go b/internal/alerts/alerts_test.goindex cb1b1ed2c2..fe2c1925e8 100644--- a/internal/alerts/alerts_test.go+++ b/internal/alerts/alerts_test.go@@ -13021,6 +13021,45 @@ func TestDockerContainerHealthAlert(t *testing.T) {}})+ t.Run("stopped container clears persisted unhealthy health", func(t *testing.T) {+ m := newTestManager(t)++ host := models.DockerHost{+ ID: "host-health-stopped",+ DisplayName: "Docker Host",+ Hostname: "docker.local",+ Containers: []models.DockerContainer{+ {+ ID: "container-stopped",+ Name: "stopped-app",+ State: "running",+ Status: "Up 10 minutes (unhealthy)",+ Health: "unhealthy",+ },+ },+ }++ m.CheckDockerHost(host)++ resourceID := DockerResourceID(host.ID, host.Containers[0].ID)+ alertID := fmt.Sprintf("docker-container-health-%s", resourceID)+ if !testHasActiveAlert(t, m, alertID) {+ t.Fatal("expected running unhealthy container to raise a health alert")+ }++ // Docker keeps the final health value after exit. It is stale once the+ // health check is no longer running and must not keep or re-open a health+ // alert alongside the runtime-state lifecycle.+ host.Containers[0].State = "exited"+ host.Containers[0].Status = "Exited (0) 1 minute ago"+ m.CheckDockerHost(host)+ m.CheckDockerHost(host)++ if testHasActiveAlert(t, m, alertID) {+ t.Fatal("expected persisted unhealthy health to stay cleared after container exit")+ }+ })+t.Run("alert cleared when container becomes healthy", func(t *testing.T) {m := newTestManager(t)diff --git a/internal/alerts/docker.go b/internal/alerts/docker.goindex 8451f88798..ddc19d068f 100644--- a/internal/alerts/docker.go+++ b/internal/alerts/docker.go@@ -896,6 +896,16 @@ func dockerLabelTags(labels map[string]string) []string {}func (m *Manager) checkDockerContainerHealth(host models.DockerHost, container models.DockerContainer, resourceID, containerName, instanceName, nodeName string) {+ // Docker retains the last health-check result after a container stops (and+ // while health checks are suspended in other non-running states). That+ // persisted value is no longer live health evidence; the runtime-state alert+ // owns the non-running condition.+ state := strings.ToLower(strings.TrimSpace(container.State))+ if state != "" && state != "running" {+ m.clearDockerContainerHealthAlert(resourceID)+ return+ }+health := strings.ToLower(strings.TrimSpace(container.Health))if health == "" || health == "none" || health == "healthy" || health == "starting" {m.clearDockerContainerHealthAlert(resourceID)