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.

Preserve current disk metadata without inventing history

pulse-triage[bot]26ae5b1aa234
diff --git a/internal/monitoring/monitor_metrics.go b/internal/monitoring/monitor_metrics.go
index b4290380dd..ec208ddf4f 100644
--- a/internal/monitoring/monitor_metrics.go
+++ b/internal/monitoring/monitor_metrics.go
@@ -8,6 +8,7 @@ import (
"github.com/rcourtman/pulse-go-rewrite/internal/mock"
"github.com/rcourtman/pulse-go-rewrite/internal/unifiedresources"
+ "github.com/rcourtman/pulse-go-rewrite/pkg/diskinventory"
"github.com/rcourtman/pulse-go-rewrite/pkg/metrics"
)
@@ -275,10 +276,11 @@ func (m *Monitor) GetPhysicalDiskTemperatureCharts(duration time.Duration) map[s
// Phase 1: Collect disk metadata and resource IDs.
type diskMeta struct {
- resourceID string
- name string
- node string
- instance string
+ resourceID string
+ name string
+ node string
+ instance string
+ temperatureCollected bool
}
var disks []diskMeta
for _, disk := range readState.PhysicalDisks() {
@@ -302,10 +304,11 @@ func (m *Monitor) GetPhysicalDiskTemperatureCharts(duration time.Duration) map[s
name = strings.TrimSpace(disk.DevPath())
}
disks = append(disks, diskMeta{
- resourceID: resourceID,
- name: name,
- node: strings.TrimSpace(disk.Node()),
- instance: strings.TrimSpace(disk.Instance()),
+ resourceID: resourceID,
+ name: name,
+ node: strings.TrimSpace(disk.Node()),
+ instance: strings.TrimSpace(disk.Instance()),
+ temperatureCollected: diskinventory.TemperatureCollected(disk.Temperature(), disk.Collection()),
})
}
@@ -354,9 +357,10 @@ func (m *Monitor) GetPhysicalDiskTemperatureCharts(duration time.Duration) map[s
}
// Neither a current nor a retained temperature is two historical
- // observations. Keep single-point histories intact, and omit disks
- // without stored samples instead of inventing a flat line.
- if len(tempPoints) == 0 {
+ // observations. Keep empty and single-point histories intact instead
+ // of inventing a flat line. A collected reading still supplies current
+ // disk metadata; a retained-only reading with no history supplies none.
+ if len(tempPoints) == 0 && !d.temperatureCollected {
continue
}
diff --git a/internal/monitoring/monitor_metrics_slo_test.go b/internal/monitoring/monitor_metrics_slo_test.go
index 5a5065e945..c5f36c89bd 100644
--- a/internal/monitoring/monitor_metrics_slo_test.go
+++ b/internal/monitoring/monitor_metrics_slo_test.go
@@ -673,9 +673,9 @@ func TestSLO_GetPhysicalDiskTemperatureCharts_WithNativeHistoryFallback(t *testi
}
// A temperature, current or retained, cannot supply historical timestamps.
-// Keep only observed samples, including single-point histories, and omit disks
-// with none. This composes upstream retained-value protection with the reviewed
-// sparse-history contract rather than restoring synthetic two-point padding.
+// Keep only observed samples, including single-point histories. Collected
+// readings retain disk metadata even without history; retained-only readings do
+// not add empty entries. Neither may restore synthetic two-point padding.
func TestDiskTemperatureChartsRetainOnlyObservedSamples(t *testing.T) {
now := time.Now().UTC()
standby := &diskinventory.CollectionStatus{Temperature: diskinventory.Unavailable("smartctl", "disk is in standby")}
@@ -705,8 +705,8 @@ func TestDiskTemperatureChartsRetainOnlyObservedSamples(t *testing.T) {
t.Fatalf("silent agent disk series = %+v (found %v), want only its stored 44C sample at %s", silentEntry.Temperature, ok, sampledAt)
}
live, ok := charts["LIVE-NO-HISTORY"]
- if ok {
- t.Fatalf("a live disk with no stored samples got fabricated history: %+v", live.Temperature)
+ if !ok || len(live.Temperature) != 0 || live.Name != "WDC WD80EFAX" || live.Node != "node-a" {
+ t.Fatalf("live disk = %+v (found %v), want its metadata with no fabricated history", live, ok)
}
m.metricsHistory.AddDiskMetric("LIVE-NO-HISTORY", "smart_temp", 37, sampledAt)
live, ok = m.GetPhysicalDiskTemperatureCharts(time.Hour)["LIVE-NO-HISTORY"]