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.

Port v5 NAS vendor identity and RAID normalization

rcourtmand03056f656af
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
index 4cb1fae307..653ace6b0f 100644
--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
@@ -1404,6 +1404,12 @@ The updater/runtime surfaces must preserve the one-shot `updated_from`
continuity handoff and the non-TLS continuity path for supported self-hosted
installs, so upgrade-safe agent behavior does not drift between install,
restart, and reconnect paths.
+That same unified-agent runtime boundary also owns vendor-aware host identity.
+When gopsutil reports generic Linux platform fields on NAS appliances,
+`internal/hostagent/` must prefer canonical platform files such as Synology DSM
+or QNAP QTS/QuTS version manifests before the first report is built, so
+downstream monitoring and alerting do not depend on hostname or display-name
+heuristics to infer the real vendor OS.
That same runtime continuity must stay on direct lifecycle proof routes too:
changes under `internal/hostagent/` must continue to carry the explicit
`unified-agent-runtime` proof, and changes under `internal/agentupdate/` must
diff --git a/docs/release-control/v6/internal/subsystems/alerts.md b/docs/release-control/v6/internal/subsystems/alerts.md
index 0a124fe74b..423a2c8512 100644
--- a/docs/release-control/v6/internal/subsystems/alerts.md
+++ b/docs/release-control/v6/internal/subsystems/alerts.md
@@ -94,6 +94,12 @@ infrastructure instances, so cached node display names must key on instance +
node identity whenever the alert carries instance context. Alert updates,
incident rebuilds, and guest-metric migrations may fall back to the legacy
name-only cache only for instance-less resources like standalone host agents.
+That same host-alert boundary also owns vendor-managed NAS RAID suppression as
+an alert-lifecycle concern. Shared storagehealth rules decide which Synology
+or QNAP md arrays are vendor-managed system volumes rather than customer-facing
+storage, and alerts runtime must use those shared rules both to suppress new
+RAID incidents and to clear stale suppressed alert IDs even after monitoring
+has already normalized those arrays out of canonical host state.
Alert history persistence is also part of that canonical boundary. The history
manager may choose the owned runtime data directory, but it must normalize that
diff --git a/docs/release-control/v6/internal/subsystems/monitoring.md b/docs/release-control/v6/internal/subsystems/monitoring.md
index f5eda9ede1..39ecc751e3 100644
--- a/docs/release-control/v6/internal/subsystems/monitoring.md
+++ b/docs/release-control/v6/internal/subsystems/monitoring.md
@@ -80,7 +80,7 @@ truth for live infrastructure data.
1. Update this contract when monitoring truth ownership changes
2. Tighten guardrails when `GetState()`-centric paths are removed
-3. Keep discovery-provider, guest-memory trust, metrics-history, Docker/Podman container collection, Proxmox Ceph compatibility, Docker Swarm collection, and container bootstrap proof routes explicit in `registry.json`
+3. Keep discovery-provider, host-agent ingest, guest-memory trust, metrics-history, storage-risk, Docker/Podman container collection, Proxmox Ceph compatibility, Docker Swarm collection, and container bootstrap proof routes explicit in `registry.json`
4. Update related read-state or monitor tests when new collector paths land
5. Keep platform ingestion semantics aligned with
`docs/release-control/v6/internal/PLATFORM_SUPPORT_MODEL.md`: hybrid is a
@@ -767,6 +767,13 @@ emit structured storage topology such as Unraid per-disk state, the shared
assessment layer must derive canonical risk and alert severity from that
richer disk topology instead of letting coarser aggregate counters override it
and flap the operator-facing storage alert surface.
+That same monitoring-owned host-agent ingest boundary now also owns
+vendor-managed NAS RAID normalization. `internal/monitoring/monitor_agents.go`
+must filter vendor-managed system arrays through the shared
+`internal/storagehealth/` rules before host state sync so internal Synology
+`md0/md1` and QNAP `md9/md13` volumes do not leak into canonical APIs,
+resources, or alert inputs just because those hosts report Linux md arrays
+alongside customer-managed storage pools.
That same monitoring runtime boundary also owns logger-safe reload behavior.
`internal/monitoring/reload.go` may refresh runtime config, but it must do so
through the no-logging-init config loader so an in-process monitoring reload
diff --git a/docs/release-control/v6/internal/subsystems/registry.json b/docs/release-control/v6/internal/subsystems/registry.json
index 51219a6cdf..3a5fce5b3d 100644
--- a/docs/release-control/v6/internal/subsystems/registry.json
+++ b/docs/release-control/v6/internal/subsystems/registry.json
@@ -1345,6 +1345,7 @@
"internal/alerts/guest_snapshot_test.go",
"internal/alerts/history_concurrency_test.go",
"internal/alerts/history_test.go",
+ "internal/alerts/synology_test.go",
"internal/alerts/threshold_resolution_shared_test.go",
"internal/alerts/update_alerts_test.go"
]
@@ -3231,6 +3232,20 @@
"internal/monitoring/truenas_poller_test.go"
]
},
+ {
+ "id": "host-agent-ingest-runtime",
+ "label": "monitoring host-agent ingest proof",
+ "match_prefixes": [],
+ "match_files": [
+ "internal/monitoring/monitor_agents.go"
+ ],
+ "allow_same_subsystem_tests": false,
+ "test_prefixes": [],
+ "exact_files": [
+ "internal/monitoring/monitor_host_agents_test.go",
+ "internal/unifiedresources/code_standards_test.go"
+ ]
+ },
{
"id": "truenas-runtime",
"label": "monitoring truenas runtime proof",
diff --git a/internal/alerts/alerts.go b/internal/alerts/alerts.go
index 6f1b5359d7..a0a58d9642 100644
--- a/internal/alerts/alerts.go
+++ b/internal/alerts/alerts.go
@@ -3542,13 +3542,15 @@ func (m *Manager) CheckHost(host models.Host) {
m.clearHostUnraidAlerts(host.ID)
}
+ // Clear vendor-managed system-array alerts even when host state has already
+ // been normalized to exclude them.
+ m.clearVendorManagedHostRAIDAlerts(host)
+
// Check RAID arrays for degraded or failed state
if len(host.RAID) > 0 {
for _, array := range host.RAID {
- // Skip Synology internal system arrays (md0/md1) which often report false positives.
- // DSM handles these differently and they're not user-facing storage arrays.
- deviceLower := strings.ToLower(strings.TrimPrefix(array.Device, "/dev/"))
- if deviceLower == "md0" || deviceLower == "md1" {
+ // Skip vendor-managed system arrays that are not customer-facing storage pools.
+ if storagehealth.IsVendorManagedSystemRAIDArray(host, array) {
// Still clear any existing alerts for these devices
raidSpecResourceID := fmt.Sprintf("%s/raid:%s", hostResourceID(host.ID), sanitizeRAIDDevice(array.Device))
m.clearAlert(buildCanonicalStateID(raidSpecResourceID, raidSpecResourceID+"-health"))
@@ -3922,6 +3924,17 @@ func (m *Manager) cleanupGuestDiskAlerts(guestID string, seen map[string]struct{
return cleared
}
+func (m *Manager) clearVendorManagedHostRAIDAlerts(host models.Host) {
+ if host.ID == "" {
+ return
+ }
+
+ for _, device := range storagehealth.VendorManagedSystemRAIDDevices(host) {
+ raidSpecResourceID := fmt.Sprintf("%s/raid:%s", hostResourceID(host.ID), sanitizeRAIDDevice(device))
+ m.clearAlert(buildCanonicalStateID(raidSpecResourceID, raidSpecResourceID+"-health"))
+ }
+}
+
func (m *Manager) cleanupHostDiskAlerts(host models.Host, seen map[string]struct{}) {
if host.ID == "" {
return
diff --git a/internal/alerts/synology_test.go b/internal/alerts/synology_test.go
index 955e79c817..bd1e8bc859 100644
--- a/internal/alerts/synology_test.go
+++ b/internal/alerts/synology_test.go
@@ -116,6 +116,138 @@ func TestSynologyRAIDClearing(t *testing.T) {
}
}
+func TestQNAPRAIDSuppression(t *testing.T) {
+ m := newTestManager(t)
+ m.ClearActiveAlerts()
+ m.mu.Lock()
+ m.config.TimeThresholds = map[string]int{}
+ m.mu.Unlock()
+
+ host := models.Host{
+ ID: "qnap-1",
+ DisplayName: "QNAP NAS",
+ Hostname: "qnap",
+ OSName: "QNAP QTS",
+ Status: "online",
+ LastSeen: time.Now(),
+ RAID: []models.HostRAIDArray{
+ {
+ Device: "/dev/md9",
+ Level: "raid1",
+ State: "degraded",
+ FailedDevices: 1,
+ },
+ {
+ Device: "/dev/md13",
+ Level: "raid1",
+ State: "resyncing",
+ RebuildPercent: 50.0,
+ },
+ {
+ Device: "/dev/md2",
+ Level: "raid5",
+ State: "degraded",
+ FailedDevices: 1,
+ },
+ },
+ }
+
+ m.CheckHost(host)
+
+ alerts := m.GetActiveAlerts()
+ var md9Found, md13Found, md2Found bool
+
+ for _, a := range alerts {
+ if strings.Contains(a.ID, "md9") {
+ md9Found = true
+ }
+ if strings.Contains(a.ID, "md13") {
+ md13Found = true
+ }
+ if strings.Contains(a.ID, "md2") {
+ md2Found = true
+ }
+ }
+
+ if md9Found {
+ t.Error("expected md9 alert to be suppressed")
+ }
+ if md13Found {
+ t.Error("expected md13 alert to be suppressed")
+ }
+ if !md2Found {
+ t.Error("expected md2 alert to be created")
+ }
+}
+
+func TestVendorManagedFilteredRAIDStateStillClearsAlerts(t *testing.T) {
+ testCases := []struct {
+ name string
+ host models.Host
+ alertDevice string
+ }{
+ {
+ name: "synology clears stale md0",
+ host: models.Host{
+ ID: "syno-filtered",
+ DisplayName: "Synology NAS",
+ Hostname: "synology",
+ OSName: "Synology DSM",
+ Status: "online",
+ LastSeen: time.Now(),
+ RAID: []models.HostRAIDArray{
+ {Device: "/dev/md2", Level: "raid5", State: "clean"},
+ },
+ },
+ alertDevice: "md0",
+ },
+ {
+ name: "qnap clears stale md9",
+ host: models.Host{
+ ID: "qnap-filtered",
+ DisplayName: "QNAP NAS",
+ Hostname: "qnap",
+ OSName: "QNAP QTS",
+ Status: "online",
+ LastSeen: time.Now(),
+ RAID: []models.HostRAIDArray{
+ {Device: "/dev/md2", Level: "raid5", State: "clean"},
+ },
+ },
+ alertDevice: "md9",
+ },
+ }
+
+ for _, tc := range testCases {
+ t.Run(tc.name, func(t *testing.T) {
+ m := newTestManager(t)
+ m.ClearActiveAlerts()
+ m.mu.Lock()
+ m.config.TimeThresholds = map[string]int{}
+ alertID := buildCanonicalStateID(
+ "agent:"+tc.host.ID+"/raid:"+tc.alertDevice,
+ "agent:"+tc.host.ID+"/raid:"+tc.alertDevice+"-health",
+ )
+ m.activeAlerts[alertID] = &Alert{
+ ID: alertID,
+ ResourceID: "agent:" + tc.host.ID + "/raid:" + tc.alertDevice,
+ ResourceName: tc.host.DisplayName + " - /dev/" + tc.alertDevice + " (raid1)",
+ Message: "RAID array degraded",
+ }
+ m.mu.Unlock()
+
+ m.CheckHost(tc.host)
+
+ m.mu.RLock()
+ _, exists := testLookupActiveAlert(t, m, alertID)
+ m.mu.RUnlock()
+ if exists {
+ t.Fatalf("expected stale %s alert to be cleared", tc.alertDevice)
+ }
+ })
+ }
+}
+
func TestHostDisableClearsRAID(t *testing.T) {
m := newTestManager(t)
m.ClearActiveAlerts()
diff --git a/internal/hostagent/agent.go b/internal/hostagent/agent.go
index 27af3cd900..048f67753b 100644
--- a/internal/hostagent/agent.go
+++ b/internal/hostagent/agent.go
@@ -223,6 +223,7 @@ func New(cfg Config) (*Agent, error) {
osName = strings.TrimSpace(info.PlatformFamily)
}
osVersion := strings.TrimSpace(info.PlatformVersion)
+ osName, osVersion = resolveHostOSIdentity(collector, osName, osVersion)
kernelVersion := strings.TrimSpace(info.KernelVersion)
arch := strings.TrimSpace(info.KernelArch)
if arch == "" {
diff --git a/internal/hostagent/agent_metrics_test.go b/internal/hostagent/agent_metrics_test.go
index 91bb363f2e..917f68f222 100644
--- a/internal/hostagent/agent_metrics_test.go
+++ b/internal/hostagent/agent_metrics_test.go
@@ -3,6 +3,7 @@ package hostagent
import (
"context"
"errors"
+ "os"
"testing"
"time"
@@ -285,3 +286,73 @@ func TestBuildReport(t *testing.T) {
mc.smartLocalFn = nil
})
}
+
+func TestBuildReportUsesResolvedNASOSIdentity(t *testing.T) {
+ fixedTime := time.Date(2026, time.April, 15, 12, 0, 0, 0, time.UTC)
+
+ mc := &mockCollector{
+ nowFn: func() time.Time { return fixedTime },
+ goos: "linux",
+ hostInfoFn: func(ctx context.Context) (*gohost.InfoStat, error) {
+ return &gohost.InfoStat{
+ Hostname: "nas",
+ HostID: "machine-id-1",
+ Platform: "linux",
+ PlatformFamily: "linux",
+ PlatformVersion: "",
+ KernelVersion: "4.4.302+",
+ KernelArch: "x86_64",
+ }, nil
+ },
+ hostUptimeFn: func(context.Context) (uint64, error) {
+ return 3600, nil
+ },
+ readFileFn: func(name string) ([]byte, error) {
+ switch name {
+ case "/etc.defaults/VERSION":
+ return []byte(`majorversion="7"
+minorversion="2"
+productversion="7.2.2"
+buildnumber="72806"
+smallfixnumber="3"
+`), nil
+ case "/etc/machine-id":
+ return []byte("0123456789abcdef0123456789abcdef\n"), nil
+ default:
+ return nil, os.ErrNotExist
+ }
+ },
+ metricsFn: func(ctx context.Context, diskExclude []string) (hostmetrics.Snapshot, error) {
+ return hostmetrics.Snapshot{
+ Memory: agentshost.MemoryMetric{
+ TotalBytes: 1024,
+ UsedBytes: 512,
+ FreeBytes: 512,
+ Usage: 50,
+ },
+ }, nil
+ },
+ }
+
+ agent, err := New(Config{
+ APIToken: "token",
+ AgentID: "agent-1",
+ LogLevel: -1,
+ Collector: mc,
+ })
+ if err != nil {
+ t.Fatalf("New() failed: %v", err)
+ }
+
+ report, err := agent.buildReport(context.Background())
+ if err != nil {
+ t.Fatalf("buildReport() failed: %v", err)
+ }
+
+ if report.Host.OSName != "Synology DSM" {
+ t.Fatalf("Host.OSName = %q, want %q", report.Host.OSName, "Synology DSM")
+ }
+ if report.Host.OSVersion != "7.2.2-72806 Update 3" {
+ t.Fatalf("Host.OSVersion = %q, want %q", report.Host.OSVersion, "7.2.2-72806 Update 3")
+ }
+}
diff --git a/internal/hostagent/agent_new_test.go b/internal/hostagent/agent_new_test.go
index 3f7363f426..b23f164a93 100644
--- a/internal/hostagent/agent_new_test.go
+++ b/internal/hostagent/agent_new_test.go
@@ -172,6 +172,86 @@ func TestNew_DefaultPulseURL(t *testing.T) {
}
}
+func TestNew_ResolvesVendorNASIdentityFromPlatformFiles(t *testing.T) {
+ t.Run("synology dsm from version file", func(t *testing.T) {
+ mc := &mockCollector{
+ goos: "linux",
+ hostInfoFn: func(context.Context) (*gohost.InfoStat, error) {
+ return &gohost.InfoStat{
+ Hostname: "nas",
+ HostID: "hid",
+ Platform: "linux",
+ PlatformFamily: "linux",
+ PlatformVersion: "",
+ KernelArch: runtime.GOARCH,
+ }, nil
+ },
+ readFileFn: func(name string) ([]byte, error) {
+ switch name {
+ case "/etc.defaults/VERSION":
+ return []byte(`majorversion="7"
+minorversion="2"
+productversion="7.2.2"
+buildnumber="72806"
+smallfixnumber="3"
+`), nil
+ default:
+ return nil, os.ErrNotExist
+ }
+ },
+ }
+
+ agent, err := New(Config{APIToken: "token", LogLevel: zerolog.InfoLevel, Collector: mc})
+ if err != nil {
+ t.Fatalf("New: %v", err)
+ }
+ if agent.osName != "Synology DSM" {
+ t.Fatalf("osName = %q, want %q", agent.osName, "Synology DSM")
+ }
+ if agent.osVersion != "7.2.2-72806 Update 3" {
+ t.Fatalf("osVersion = %q, want %q", agent.osVersion, "7.2.2-72806 Update 3")
+ }
+ })
+
+ t.Run("qnap quts from config file", func(t *testing.T) {
+ mc := &mockCollector{
+ goos: "linux",
+ hostInfoFn: func(context.Context) (*gohost.InfoStat, error) {
+ return &gohost.InfoStat{
+ Hostname: "qnap",
+ HostID: "hid",
+ Platform: "linux",
+ PlatformFamily: "linux",
+ PlatformVersion: "",
+ KernelArch: runtime.GOARCH,
+ }, nil
+ },
+ readFileFn: func(name string) ([]byte, error) {
+ switch name {
+ case "/etc/config/uLinux.conf":
+ return []byte(`Version = 5.2.0
+Display_Name = QuTS hero
+Platform = QNAP
+`), nil
+ default:
+ return nil, os.ErrNotExist
+ }
+ },
+ }
+
+ agent, err := New(Config{APIToken: "token", LogLevel: zerolog.InfoLevel, Collector: mc})
+ if err != nil {
+ t.Fatalf("New: %v", err)
+ }
+ if agent.osName != "QNAP QuTS" {
+ t.Fatalf("osName = %q, want %q", agent.osName, "QNAP QuTS")
+ }
+ if agent.osVersion != "5.2.0" {
+ t.Fatalf("osVersion = %q, want %q", agent.osVersion, "5.2.0")
+ }
+ })
+}
+
func TestNew_UsesCustomCABundleForHTTPTransport(t *testing.T) {
mc := &mockCollector{
hostInfoFn: func(context.Context) (*gohost.InfoStat, error) {
diff --git a/internal/hostagent/os_identity.go b/internal/hostagent/os_identity.go
new file mode 100644
index 0000000000..fad3f5afdb
--- /dev/null
+++ b/internal/hostagent/os_identity.go
@@ -0,0 +1,166 @@
+package hostagent
+
+import "strings"
+
+func resolveHostOSIdentity(collector SystemCollector, osName, osVersion string) (string, string) {
+ currentName := strings.TrimSpace(osName)
+ currentVersion := strings.TrimSpace(osVersion)
+
+ if collector == nil || collector.GOOS() != "linux" {
+ return currentName, currentVersion
+ }
+
+ if name, version, ok := detectSynologyOSIdentity(collector); ok {
+ if version == "" {
+ version = currentVersion
+ }
+ return name, strings.TrimSpace(version)
+ }
+
+ if name, version, ok := detectQNAPOSIdentity(collector); ok {
+ if version == "" {
+ version = currentVersion
+ }
+ return name, strings.TrimSpace(version)
+ }
+
+ return currentName, currentVersion
+}
+
+func detectSynologyOSIdentity(collector SystemCollector) (string, string, bool) {
+ hasSynologyDir := false
+ if _, err := collector.Stat("/usr/syno"); err == nil {
+ hasSynologyDir = true
+ }
+
+ for _, path := range []string{"/etc.defaults/VERSION", "/etc/VERSION"} {
+ data, err := collector.ReadFile(path)
+ if err != nil || len(data) == 0 {
+ continue
+ }
+
+ values := parseAssignmentConfig(string(data))
+ if len(values) == 0 {
+ continue
+ }
+ if !hasSynologyDir && !looksLikeSynologyVersionFile(values) {
+ continue
+ }
+
+ version := composeSynologyVersion(values)
+ return "Synology DSM", version, true
+ }
+
+ return "", "", false
+}
+
+func composeSynologyVersion(values map[string]string) string {
+ version := strings.TrimSpace(values["productversion"])
+ if version == "" {
+ major := strings.TrimSpace(values["majorversion"])
+ minor := strings.TrimSpace(values["minorversion"])
+ switch {
+ case major != "" && minor != "":
+ version = major + "." + minor
+ case major != "":
+ version = major
+ case minor != "":
+ version = minor
+ }
+ }
+
+ build := strings.TrimSpace(values["buildnumber"])
+ if build != "" && !strings.Contains(version, build) {
+ if version != "" {
+ version += "-" + build
+ } else {
+ version = build
+ }
+ }
+
+ smallfix := strings.TrimSpace(values["smallfixnumber"])
+ if smallfix != "" && smallfix != "0" {
+ if version != "" {
+ version += " Update " + smallfix
+ } else {
+ version = smallfix
+ }
+ }
+
+ return strings.TrimSpace(version)
+}
+
+func looksLikeSynologyVersionFile(values map[string]string) bool {
+ if values["majorversion"] != "" || values["minorversion"] != "" || values["buildnumber"] != "" || values["productversion"] != "" {
+ return true
+ }
+
+ hints := strings.ToLower(strings.Join([]string{
+ values["product"],
+ values["unique"],
+ values["buildphase"],
+ }, " "))
+ return strings.Contains(hints, "synology") || strings.Contains(hints, "dsm") || strings.Contains(hints, "diskstation")
+}
+
+func detectQNAPOSIdentity(collector SystemCollector) (string, string, bool) {
+ for _, path := range []string{"/etc/config/uLinux.conf", "/etc/default_config/uLinux.conf"} {
+ data, err := collector.ReadFile(path)
+ if err != nil || len(data) == 0 {
+ continue
+ }
+
+ values := parseAssignmentConfig(string(data))
+ if len(values) == 0 {
+ continue
+ }
+
+ name := "QNAP QTS"
+ hintFields := strings.ToLower(strings.Join([]string{
+ values["display_name"],
+ values["platform"],
+ values["system_name"],
+ values["version"],
+ }, " "))
+ if strings.Contains(hintFields, "quts") {
+ name = "QNAP QuTS"
+ }
+ return name, strings.TrimSpace(values["version"]), true
+ }
+
+ if _, err := collector.Stat("/etc/config/qpkg.conf"); err == nil {
+ return "QNAP QTS", "", true
+ }
+ if _, err := collector.Stat("/sbin/getcfg"); err == nil {
+ return "QNAP QTS", "", true
+ }
+
+ return "", "", false
+}
+
+func parseAssignmentConfig(content string) map[string]string {
+ parsed := make(map[string]string)
+
+ for _, line := range strings.Split(content, "\n") {
+ line = strings.TrimSpace(line)
+ if line == "" || strings.HasPrefix(line, "#") || strings.HasPrefix(line, ";") || strings.HasPrefix(line, "[") {
+ continue
+ }
+
+ idx := strings.IndexRune(line, '=')
+ if idx <= 0 {
+ continue
+ }
+
+ key := strings.ToLower(strings.TrimSpace(line[:idx]))
+ value := strings.TrimSpace(line[idx+1:])
+ value = strings.Trim(value, `"'`)
+ if key == "" || value == "" {
+ continue
+ }
+
+ parsed[key] = value
+ }
+
+ return parsed
+}
diff --git a/internal/monitoring/monitor_agents.go b/internal/monitoring/monitor_agents.go
index fa9dc9fa97..3b2f1cf8ac 100644
--- a/internal/monitoring/monitor_agents.go
+++ b/internal/monitoring/monitor_agents.go
@@ -10,6 +10,7 @@ import (
"github.com/rcourtman/pulse-go-rewrite/internal/config"
"github.com/rcourtman/pulse-go-rewrite/internal/logging"
"github.com/rcourtman/pulse-go-rewrite/internal/models"
+ "github.com/rcourtman/pulse-go-rewrite/internal/storagehealth"
"github.com/rcourtman/pulse-go-rewrite/internal/unifiedresources"
agentsdocker "github.com/rcourtman/pulse-go-rewrite/pkg/agents/docker"
agentshost "github.com/rcourtman/pulse-go-rewrite/pkg/agents/host"
@@ -1678,6 +1679,10 @@ func (m *Monitor) ApplyHostReport(report agentshost.Report, tokenRecord *config.
IsLegacy: isLegacyAgent(report.Agent.Type),
}
+ // Normalize vendor-managed internal RAID arrays out of host state so they do
+ // not surface as customer-facing degraded storage in APIs, resources, or alerts.
+ host.RAID = storagehealth.FilterVendorManagedSystemRAIDArrays(host, host.RAID)
+
// Apply any pending commands execution override from server config
// This ensures the UI remains stable when the user toggles this setting,
// even if the agent hasn't yet picked up the new config in this report cycle.
diff --git a/internal/monitoring/monitor_host_agents_test.go b/internal/monitoring/monitor_host_agents_test.go
index 9e1545ce55..083ead9940 100644
--- a/internal/monitoring/monitor_host_agents_test.go
+++ b/internal/monitoring/monitor_host_agents_test.go
@@ -527,6 +527,124 @@ func TestApplyHostReportStoresUnraidTopology(t *testing.T) {
}
}
+func TestApplyHostReportFiltersVendorManagedSystemRAIDArrays(t *testing.T) {
+ t.Helper()
+
+ monitor := &Monitor{
+ state: models.NewState(),
+ alertManager: alerts.NewManager(),
+ hostTokenBindings: make(map[string]string),
+ config: &config.Config{},
+ rateTracker: NewRateTracker(),
+ }
+ t.Cleanup(func() { monitor.alertManager.Stop() })
+
+ now := time.Now().UTC()
+ testCases := []struct {
+ name string
+ hostInfo agentshost.HostInfo
+ reportRAID []agentshost.RAIDArray
+ wantDevices []string
+ }{
+ {
+ name: "synology suppresses md0 and md1",
+ hostInfo: agentshost.HostInfo{
+ ID: "machine-synology",
+ Hostname: "synology.local",
+ Platform: "linux",
+ OSName: "Synology DSM",
+ },
+ reportRAID: []agentshost.RAIDArray{
+ {Device: "/dev/md0", Level: "raid1", State: "degraded", FailedDevices: 1},
+ {Device: "/dev/md1", Level: "raid1", State: "resyncing", RebuildPercent: 42},
+ {Device: "/dev/md2", Level: "raid5", State: "clean"},
+ },
+ wantDevices: []string{"/dev/md2"},
+ },
+ {
+ name: "qnap suppresses md9 and md13",
+ hostInfo: agentshost.HostInfo{
+ ID: "machine-qnap",
+ Hostname: "qnap.local",
+ Platform: "linux",
+ OSName: "QNAP QTS",
+ },
+ reportRAID: []agentshost.RAIDArray{
+ {Device: "/dev/md9", Level: "raid1", State: "degraded", FailedDevices: 1},
+ {Device: "/dev/md13", Level: "raid1", State: "clean"},
+ {Device: "/dev/md2", Level: "raid5", State: "clean"},
+ },
+ wantDevices: []string{"/dev/md2"},
+ },
+ {
+ name: "generic hosts keep md0",
+ hostInfo: agentshost.HostInfo{
+ ID: "machine-generic",
+ Hostname: "generic.local",
+ Platform: "linux",
+ OSName: "Ubuntu",
+ },
+ reportRAID: []agentshost.RAIDArray{
+ {Device: "/dev/md0", Level: "raid1", State: "clean"},
+ {Device: "/dev/md2", Level: "raid5", State: "clean"},
+ },
+ wantDevices: []string{"/dev/md0", "/dev/md2"},
+ },
+ }
+
+ for _, tc := range testCases {
+ t.Run(tc.name, func(t *testing.T) {
+ report := agentshost.Report{
+ Agent: agentshost.AgentInfo{
+ ID: "agent-" + tc.hostInfo.ID,
+ Version: "1.0.0",
+ IntervalSeconds: 30,
+ },
+ Host: tc.hostInfo,
+ Timestamp: now,
+ Metrics: agentshost.Metrics{
+ CPUUsagePercent: 5.5,
+ },
+ RAID: tc.reportRAID,
+ }
+
+ host, err := monitor.ApplyHostReport(report, nil)
+ if err != nil {
+ t.Fatalf("ApplyHostReport: %v", err)
+ }
+
+ if len(host.RAID) != len(tc.wantDevices) {
+ t.Fatalf("host RAID count = %d, want %d", len(host.RAID), len(tc.wantDevices))
+ }
+ for i, device := range tc.wantDevices {
+ if host.RAID[i].Device != device {
+ t.Fatalf("host RAID[%d] = %q, want %q", i, host.RAID[i].Device, device)
+ }
+ }
+
+ snapshot := monitor.state.GetSnapshot()
+ var stored *models.Host
+ for i := range snapshot.Hosts {
+ if snapshot.Hosts[i].ID == host.ID {
+ stored = &snapshot.Hosts[i]
+ break
+ }
+ }
+ if stored == nil {
+ t.Fatalf("stored host %q not found", host.ID)
+ }
+ if len(stored.RAID) != len(tc.wantDevices) {
+ t.Fatalf("stored RAID count = %d, want %d", len(stored.RAID), len(tc.wantDevices))
+ }
+ for i, device := range tc.wantDevices {
+ if stored.RAID[i].Device != device {
+ t.Fatalf("stored RAID[%d] = %q, want %q", i, stored.RAID[i].Device, device)
+ }
+ }
+ })
+ }
+}
+
func TestApplyHostReportPersistsSMARTMetricsForAgentDisks(t *testing.T) {
t.Helper()
diff --git a/internal/storagehealth/topology.go b/internal/storagehealth/topology.go
index f67eaba2b6..135006a9d7 100644
--- a/internal/storagehealth/topology.go
+++ b/internal/storagehealth/topology.go
@@ -52,6 +52,83 @@ func AssessHostRAIDArray(array models.HostRAIDArray) Assessment {
return assessment
}
+// VendorManagedSystemRAIDDevices returns internal md arrays that should stay
+// out of customer-facing storage state for known NAS vendors.
+func VendorManagedSystemRAIDDevices(host models.Host) []string {
+ switch {
+ case hostMatchesVendorHint(host, "synology", "dsm"):
+ return []string{"md0", "md1"}
+ case hostMatchesVendorHint(host, "qnap", "qts", "quts"):
+ return []string{"md9", "md13"}
+ default:
+ return nil
+ }
+}
+
+// IsVendorManagedSystemRAIDArray reports whether the array is a vendor-managed
+// internal system volume that should be suppressed for this host.
+func IsVendorManagedSystemRAIDArray(host models.Host, array models.HostRAIDArray) bool {
+ device := normalizeHostRAIDDevice(array.Device)
+ if device == "" {
+ return false
+ }
+
+ for _, suppressed := range VendorManagedSystemRAIDDevices(host) {
+ if device == suppressed {
+ return true
+ }
+ }
+
+ return false
+}
+
+// FilterVendorManagedSystemRAIDArrays removes vendor-managed system arrays from
+// host state so every downstream consumer sees the same canonical storage view.
+func FilterVendorManagedSystemRAIDArrays(host models.Host, arrays []models.HostRAIDArray) []models.HostRAIDArray {
+ if len(arrays) == 0 {
+ return arrays
+ }
+
+ filtered := make([]models.HostRAIDArray, 0, len(arrays))
+ for _, array := range arrays {
+ if IsVendorManagedSystemRAIDArray(host, array) {
+ continue
+ }
+ filtered = append(filtered, array)
+ }
+
+ return filtered
+}
+
+func hostMatchesVendorHint(host models.Host, hints ...string) bool {
+ fields := []string{
+ host.Platform,
+ host.OSName,
+ host.OSVersion,
+ host.DisplayName,
+ host.Hostname,
+ }
+
+ for _, field := range fields {
+ value := strings.ToLower(strings.TrimSpace(field))
+ if value == "" {
+ continue
+ }
+ for _, hint := range hints {
+ if strings.Contains(value, hint) {
+ return true
+ }
+ }
+ }
+
+ return false
+}
+
+func normalizeHostRAIDDevice(device string) string {
+ device = strings.ToLower(strings.TrimSpace(device))
+ return strings.TrimPrefix(device, "/dev/")
+}
+
func AssessZFSPool(pool models.ZFSPool) Assessment {
assessment := Assessment{Level: RiskHealthy}
addReason := func(code string, severity RiskLevel, summary string) {
diff --git a/internal/storagehealth/topology_test.go b/internal/storagehealth/topology_test.go
index c64ea92115..f7b4dae487 100644
--- a/internal/storagehealth/topology_test.go
+++ b/internal/storagehealth/topology_test.go
@@ -35,6 +35,68 @@ func TestAssessHostRAIDArrayRebuilding(t *testing.T) {
}
}
+func TestFilterVendorManagedSystemRAIDArrays(t *testing.T) {
+ testCases := []struct {
+ name string
+ host models.Host
+ arrays []models.HostRAIDArray
+ wantDevices []string
+ }{
+ {
+ name: "synology filters md0 and md1",
+ host: models.Host{
+ Hostname: "synology",
+ OSName: "Synology DSM",
+ },
+ arrays: []models.HostRAIDArray{
+ {Device: "/dev/md0"},
+ {Device: "/dev/md1"},
+ {Device: "/dev/md2"},
+ },
+ wantDevices: []string{"/dev/md2"},
+ },
+ {
+ name: "qnap filters md9 and md13",
+ host: models.Host{
+ Hostname: "qnap",
+ OSName: "QNAP QTS",
+ },
+ arrays: []models.HostRAIDArray{
+ {Device: "/dev/md9"},
+ {Device: "/dev/md13"},
+ {Device: "/dev/md2"},
+ },
+ wantDevices: []string{"/dev/md2"},
+ },
+ {
+ name: "generic host keeps md arrays",
+ host: models.Host{
+ Hostname: "ubuntu",
+ OSName: "Ubuntu",
+ },
+ arrays: []models.HostRAIDArray{
+ {Device: "/dev/md0"},
+ {Device: "/dev/md2"},
+ },
+ wantDevices: []string{"/dev/md0", "/dev/md2"},
+ },
+ }
+
+ for _, tc := range testCases {
+ t.Run(tc.name, func(t *testing.T) {
+ filtered := FilterVendorManagedSystemRAIDArrays(tc.host, tc.arrays)
+ if len(filtered) != len(tc.wantDevices) {
+ t.Fatalf("filtered count = %d, want %d", len(filtered), len(tc.wantDevices))
+ }
+ for i, want := range tc.wantDevices {
+ if filtered[i].Device != want {
+ t.Fatalf("filtered[%d].Device = %q, want %q", i, filtered[i].Device, want)
+ }
+ }
+ })
+ }
+}
+
func TestAssessZFSPoolCriticalState(t *testing.T) {
assessment := AssessZFSPool(models.ZFSPool{
Name: "tank",
diff --git a/scripts/release_control/canonical_completion_guard_test.py b/scripts/release_control/canonical_completion_guard_test.py
index 0c05ef5efd..b064c2ce59 100644
--- a/scripts/release_control/canonical_completion_guard_test.py
+++ b/scripts/release_control/canonical_completion_guard_test.py
@@ -208,6 +208,7 @@ class CanonicalCompletionGuardTest(unittest.TestCase):
policy_ids,
[
"discovery-provider-runtime",
+ "host-agent-ingest-runtime",
"truenas-runtime",
"metrics-hot-path",
"metrics-history-runtime",
@@ -298,6 +299,36 @@ class CanonicalCompletionGuardTest(unittest.TestCase):
],
)
+ def test_host_agent_ingest_runtime_change_requires_monitoring_contract(self):
+ required = infer_impacted_subsystems(["internal/monitoring/monitor_agents.go"])
+ self.assertEqual(set(required), {"monitoring"})
+
+ monitoring = required["monitoring"]
+ self.assertEqual(
+ monitoring["contract"],
+ "docs/release-control/v6/internal/subsystems/monitoring.md",
+ )
+ self.assertEqual(
+ monitoring["touched_runtime_files"],
+ ["internal/monitoring/monitor_agents.go"],
+ )
+ self.assertEqual(
+ monitoring["verification_requirements"],
+ [
+ {
+ "id": "host-agent-ingest-runtime",
+ "label": "monitoring host-agent ingest proof",
+ "touched_runtime_files": ["internal/monitoring/monitor_agents.go"],
+ "allow_same_subsystem_tests": False,
+ "test_prefixes": [],
+ "exact_files": [
+ "internal/monitoring/monitor_host_agents_test.go",
+ "internal/unifiedresources/code_standards_test.go",
+ ],
+ }
+ ],
+ )
+
def test_storage_risk_runtime_change_requires_monitoring_contract(self):
required = infer_impacted_subsystems(["internal/storagehealth/topology.go"])
self.assertEqual(set(required), {"monitoring"})
diff --git a/scripts/release_control/subsystem_lookup_test.py b/scripts/release_control/subsystem_lookup_test.py
index 35d711a7cf..4f011d66ba 100644
--- a/scripts/release_control/subsystem_lookup_test.py
+++ b/scripts/release_control/subsystem_lookup_test.py
@@ -4534,6 +4534,27 @@ class SubsystemLookupTest(unittest.TestCase):
],
)
+ def test_lookup_paths_assigns_host_agent_ingest_runtime_to_monitoring(self) -> None:
+ result = lookup_paths(["internal/monitoring/monitor_agents.go"])
+ self.assertEqual(result["unowned_runtime_files"], [])
+
+ file_entry = result["files"][0]
+ self.assertEqual(file_entry["classification"], "runtime")
+ self.assertEqual(len(file_entry["matches"]), 1)
+
+ match = file_entry["matches"][0]
+ self.assertEqual(match["subsystem"], "monitoring")
+ self.assertEqual(match["contract"], "docs/release-control/v6/internal/subsystems/monitoring.md")
+ self.assertEqual(match["lane_context"]["lane_id"], "L13")
+ self.assertEqual(match["verification_requirement"]["id"], "host-agent-ingest-runtime")
+ self.assertEqual(
+ match["verification_requirement"]["exact_files"],
+ [
+ "internal/monitoring/monitor_host_agents_test.go",
+ "internal/unifiedresources/code_standards_test.go",
+ ],
+ )
+
def test_lookup_paths_assigns_docker_swarm_runtime_to_monitoring(self) -> None:
result = lookup_paths(["internal/dockeragent/swarm.go"])
self.assertEqual(result["unowned_runtime_files"], [])