Skip to content

armgit / Pulse

Public Imported from GitHub
0

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.

Drop pending temperature context with explicit clears and removal

pulse-triage[bot]4a8a5104d873
diff --git a/internal/alerts/active_cleanup.go b/internal/alerts/active_cleanup.go
index ea78202cf7..106ade74f5 100644
--- a/internal/alerts/active_cleanup.go
+++ b/internal/alerts/active_cleanup.go
@@ -336,7 +336,7 @@ func (m *Manager) CleanupAlertsForNodes(existingNodes map[string]bool) {
// ClearActiveAlerts removes all active and pending alerts, resetting the manager state.
func (m *Manager) ClearActiveAlerts() {
m.mu.Lock()
- if len(m.activeAlerts) == 0 && len(m.intentPending) == 0 && len(m.smartCounterSnapshots) == 0 {
+ if len(m.activeAlerts) == 0 && len(m.intentPending) == 0 && len(m.smartCounterSnapshots) == 0 && len(m.hostDiskTempPendingContexts) == 0 {
m.mu.Unlock()
return
}
@@ -344,6 +344,7 @@ func (m *Manager) ClearActiveAlerts() {
m.restoredBackupNotifications = nil
m.activeAlertAlias = make(map[string]string)
m.core.Reset()
+ m.hostDiskTempPendingContexts = nil
m.intentPending = make(map[string]IntentPendingState)
m.intentRuntimeTicks = make(map[string]time.Duration)
m.recentAlerts = make(map[string]*Alert)
diff --git a/internal/alerts/host_disk_temperature.go b/internal/alerts/host_disk_temperature.go
index 80d9a397ff..4f7dec14ab 100644
--- a/internal/alerts/host_disk_temperature.go
+++ b/internal/alerts/host_disk_temperature.go
@@ -48,6 +48,9 @@ func (m *Manager) rememberHostDiskTemperaturePending(host models.Host, disk mode
func (m *Manager) hostDiskTemperatureTrackedResourcesNoLock() map[string]struct{} {
resources := make(map[string]struct{})
+ for resourceID := range m.hostDiskTempPendingContexts {
+ resources[resourceID] = struct{}{}
+ }
for _, state := range m.mirrorStatesNoLock() {
for _, resourceID := range state.PendingResourceIDs() {
resources[resourceID] = struct{}{}
diff --git a/internal/alerts/host_unraid_lifecycle_test.go b/internal/alerts/host_unraid_lifecycle_test.go
index 2fccbd0662..c2a5d962b3 100644
--- a/internal/alerts/host_unraid_lifecycle_test.go
+++ b/internal/alerts/host_unraid_lifecycle_test.go
@@ -1038,3 +1038,32 @@ func TestDiskTemperatureCurrentCollectionAndOverrideControls(t *testing.T) {
}
})
}
+
+func TestDiskTemperaturePendingContextCleanup(t *testing.T) {
+ for _, removal := range []bool{false, true} {
+ t.Run(fmt.Sprintf("removed=%v", removal), func(t *testing.T) {
+ m, _ := continuityManager(t, false)
+ m.mu.Lock()
+ m.shadow = nil
+ m.mu.Unlock()
+ host := hostWithSMARTDiskTemp("pending-cleanup", "custom", 85)
+ m.CheckHost(host)
+ m.mu.RLock()
+ tracked := len(m.hostDiskTempPendingContexts)
+ m.mu.RUnlock()
+ if tracked != 1 || len(m.GetActiveAlerts()) != 0 {
+ t.Fatal("control must have pending context and no active alert")
+ }
+ if removal {
+ m.HandleHostRemoved(host)
+ } else {
+ m.ClearActiveAlerts()
+ }
+ m.mu.RLock()
+ defer m.mu.RUnlock()
+ if len(m.hostDiskTempPendingContexts) != 0 || m.hostDiskTemperaturePendingNoLock(hostDiskTemperatureResourceID(host.ID, host.Sensors.SMART[0].Device)) {
+ t.Fatal("pending context/state outlived its host or explicit clear")
+ }
+ })
+ }
+}