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.

Normalize configured platform replacement selectors

rcourtmanf7a6a0f83ed1
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
index 1d2c0d5bf6..9fd4c31667 100644
--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
@@ -746,6 +746,12 @@ workloads, storage, and recovery handoffs must read the canonical connection
fixtures from `internal/mock/fixture_graph.go` instead of handler-local demo
lists, so operator-facing demos stay coherent across those adjacent product
surfaces without a restart.
+That same lifecycle-owned platform-connections boundary also owns configured
+Proxmox, PBS, and PMG replacement continuity. Node update handlers must pass
+the current platform surface into monitored-system admission through the shared
+structured replacement selector so host or name edits preserve the intended
+slot without reintroducing lifecycle-local matcher closures or empty-estate
+fallbacks.
That same lifecycle-owned VMware workspace must also keep the backend-runtime
shape hidden behind one operator-facing connection model. The settings surface
may show one VMware connection's poll health, last error classification, and
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index 470c7801cb..97cad98b34 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -1069,6 +1069,12 @@ closed when monitored-system usage is unavailable, and return the canonical
current/projected count delta, enforced limit verdict, effect label, and
current/projected ledger entries produced by the shared monitored-system
projection layer instead of by handler-local heuristics.
+Configured Proxmox, PBS, and PMG update handlers in
+internal/api/config_node_handlers.go must use that same structured
+replacement-selector contract when they enforce monitored-system admission:
+source-owned names, host URLs, hostnames, and resource identifiers may cross
+the API boundary, but handler-local matcher closures must not become the
+source of truth for replacement identity.
Provider-backed preview routes such as `/api/truenas/connections/preview`,
`/api/truenas/connections/{id}/preview`, `/api/vmware/connections/preview`,
and `/api/vmware/connections/{id}/preview` must serialize that same canonical
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index e6b9861a96..2bf43a976b 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -346,6 +346,11 @@ recovery-adjacent setup, deploy, and API-backed update helpers may reuse the
canonical monitored-system cap boundary, but they must preserve remaining
grouped sources on a counted host and must not reinterpret unavailable usage as
an empty estate.
+Configured Proxmox, PBS, and PMG node replacements on that adjacent API
+boundary must identify the replaced source-owned surface through the shared
+monitored-system replacement selector, not storage- or recovery-local matching
+rules, so a platform host edit preserves non-replaced grouped evidence before
+storage or recovery consumes the resulting runtime context.
That same adjacent `internal/api/` boundary now also governs public-demo
commercial redaction for storage and recovery viewers. Shared storage/recovery
surfaces may run beside a demo runtime that has real internal entitlements,
diff --git a/internal/api/config_node_handlers.go b/internal/api/config_node_handlers.go
index ec3dc85794..5ca51344bb 100644
--- a/internal/api/config_node_handlers.go
+++ b/internal/api/config_node_handlers.go
@@ -749,20 +749,10 @@ func proxmoxMonitoredSystemReplacement(instance config.PVEInstance) unifiedresou
hostname := pulseTokenHostCandidate(instance.Host)
return unifiedresources.MonitoredSystemReplacement{
Source: unifiedresources.SourceProxmox,
- Matches: func(resource unifiedresources.Resource) bool {
- if resource.Proxmox == nil {
- return false
- }
- if name != "" && strings.EqualFold(strings.TrimSpace(resource.Proxmox.Instance), name) {
- return true
- }
- if name != "" && strings.EqualFold(strings.TrimSpace(resource.Proxmox.NodeName), name) {
- return true
- }
- if host != "" && strings.EqualFold(strings.TrimSpace(resource.Proxmox.HostURL), host) {
- return true
- }
- return hostname != "" && strings.EqualFold(pulseTokenHostCandidate(resource.Proxmox.HostURL), hostname)
+ Selector: unifiedresources.MonitoredSystemReplacementSelector{
+ Name: name,
+ Hostname: hostname,
+ HostURL: host,
},
}
}
@@ -773,17 +763,10 @@ func pbsMonitoredSystemReplacement(instance config.PBSInstance) unifiedresources
hostname := pulseTokenHostCandidate(instance.Host)
return unifiedresources.MonitoredSystemReplacement{
Source: unifiedresources.SourcePBS,
- Matches: func(resource unifiedresources.Resource) bool {
- if resource.PBS == nil {
- return false
- }
- if name != "" && strings.EqualFold(strings.TrimSpace(resource.PBS.InstanceID), name) {
- return true
- }
- if host != "" && strings.EqualFold(strings.TrimSpace(resource.PBS.HostURL), host) {
- return true
- }
- return hostname != "" && strings.EqualFold(strings.TrimSpace(resource.PBS.Hostname), hostname)
+ Selector: unifiedresources.MonitoredSystemReplacementSelector{
+ ResourceID: name,
+ Hostname: hostname,
+ HostURL: host,
},
}
}
@@ -793,14 +776,9 @@ func pmgMonitoredSystemReplacement(instance config.PMGInstance) unifiedresources
hostname := pulseTokenHostCandidate(instance.Host)
return unifiedresources.MonitoredSystemReplacement{
Source: unifiedresources.SourcePMG,
- Matches: func(resource unifiedresources.Resource) bool {
- if resource.PMG == nil {
- return false
- }
- if name != "" && strings.EqualFold(strings.TrimSpace(resource.PMG.InstanceID), name) {
- return true
- }
- return hostname != "" && strings.EqualFold(strings.TrimSpace(resource.PMG.Hostname), hostname)
+ Selector: unifiedresources.MonitoredSystemReplacementSelector{
+ ResourceID: name,
+ Hostname: hostname,
},
}
}
diff --git a/internal/api/contract_test.go b/internal/api/contract_test.go
index e349af9f0b..3c3567c152 100644
--- a/internal/api/contract_test.go
+++ b/internal/api/contract_test.go
@@ -5431,6 +5431,143 @@ func TestContract_MonitoredSystemUsageUnavailableIncludesReason(t *testing.T) {
}
}
+func TestContract_ConfiguredNodeReplacementsUseCanonicalSelectors(t *testing.T) {
+ testCases := []struct {
+ name string
+ current any
+ updated any
+ source unifiedresources.DataSource
+ currentRoot unifiedresources.Resource
+ replacement func(any) unifiedresources.MonitoredSystemReplacement
+ candidate func(any) unifiedresources.MonitoredSystemCandidate
+ }{
+ {
+ name: "proxmox",
+ current: config.PVEInstance{
+ Name: " pve-a ",
+ Host: " https://pve-a.lab.local:8006 ",
+ },
+ updated: config.PVEInstance{
+ Name: "pve-b",
+ Host: "https://pve-b.lab.local:8006",
+ },
+ source: unifiedresources.SourceProxmox,
+ currentRoot: unifiedresources.Resource{
+ ID: "pve-a",
+ Type: unifiedresources.ResourceTypeAgent,
+ Name: "pve-a",
+ Status: unifiedresources.StatusOnline,
+ Proxmox: &unifiedresources.ProxmoxData{
+ Instance: "pve-a",
+ NodeName: "pve-a-node",
+ HostURL: "https://pve-a.lab.local:8006",
+ },
+ },
+ replacement: func(value any) unifiedresources.MonitoredSystemReplacement {
+ return proxmoxMonitoredSystemReplacement(value.(config.PVEInstance))
+ },
+ candidate: func(value any) unifiedresources.MonitoredSystemCandidate {
+ return proxmoxMonitoredSystemCandidate(value.(config.PVEInstance))
+ },
+ },
+ {
+ name: "pbs",
+ current: config.PBSInstance{
+ Name: " backup-a ",
+ Host: " https://backup-a.lab.local:8007 ",
+ },
+ updated: config.PBSInstance{
+ Name: "backup-b",
+ Host: "https://backup-b.lab.local:8007",
+ },
+ source: unifiedresources.SourcePBS,
+ currentRoot: unifiedresources.Resource{
+ ID: "pbs-a",
+ Type: unifiedresources.ResourceTypePBS,
+ Name: "backup-a",
+ Status: unifiedresources.StatusOnline,
+ PBS: &unifiedresources.PBSData{
+ InstanceID: "backup-a",
+ Hostname: "backup-a.lab.local",
+ HostURL: "https://backup-a.lab.local:8007",
+ },
+ },
+ replacement: func(value any) unifiedresources.MonitoredSystemReplacement {
+ return pbsMonitoredSystemReplacement(value.(config.PBSInstance))
+ },
+ candidate: func(value any) unifiedresources.MonitoredSystemCandidate {
+ return pbsMonitoredSystemCandidate(value.(config.PBSInstance))
+ },
+ },
+ {
+ name: "pmg",
+ current: config.PMGInstance{
+ Name: " mail-a ",
+ Host: " https://mail-a.lab.local:8006 ",
+ },
+ updated: config.PMGInstance{
+ Name: "mail-b",
+ Host: "https://mail-b.lab.local:8006",
+ },
+ source: unifiedresources.SourcePMG,
+ currentRoot: unifiedresources.Resource{
+ ID: "pmg-a",
+ Type: unifiedresources.ResourceTypePMG,
+ Name: "mail-a",
+ Status: unifiedresources.StatusOnline,
+ PMG: &unifiedresources.PMGData{
+ InstanceID: "mail-a",
+ Hostname: "mail-a.lab.local",
+ },
+ },
+ replacement: func(value any) unifiedresources.MonitoredSystemReplacement {
+ return pmgMonitoredSystemReplacement(value.(config.PMGInstance))
+ },
+ candidate: func(value any) unifiedresources.MonitoredSystemCandidate {
+ return pmgMonitoredSystemCandidate(value.(config.PMGInstance))
+ },
+ },
+ }
+
+ for _, tc := range testCases {
+ t.Run(tc.name, func(t *testing.T) {
+ replacement := tc.replacement(tc.current)
+ if replacement.Source != tc.source {
+ t.Fatalf("replacement source = %q, want %q", replacement.Source, tc.source)
+ }
+ if replacement.Matches != nil {
+ t.Fatal("configured node replacement must use the canonical selector contract, not a handler-local matcher")
+ }
+ if !replacement.MatchesResource(tc.currentRoot) {
+ t.Fatalf("replacement selector did not match current %s root", tc.name)
+ }
+
+ registry := unifiedresources.NewRegistry(nil)
+ registry.IngestRecords(tc.source, []unifiedresources.IngestRecord{
+ {
+ SourceID: tc.currentRoot.ID,
+ Resource: tc.currentRoot,
+ },
+ })
+
+ projection := unifiedresources.ProjectMonitoredSystemCandidateReplacement(
+ registry,
+ replacement,
+ tc.candidate(tc.updated),
+ )
+ if projection.CurrentCount != 1 {
+ t.Fatalf("CurrentCount = %d, want 1", projection.CurrentCount)
+ }
+ if projection.ProjectedCount != 1 {
+ t.Fatalf("ProjectedCount = %d, want 1", projection.ProjectedCount)
+ }
+ if projection.AdditionalCount != 0 {
+ t.Fatalf("AdditionalCount = %d, want 0", projection.AdditionalCount)
+ }
+ })
+ }
+}
+
func TestContract_DemoModeCommercialSurfacePolicy(t *testing.T) {
t.Run("hidden routes return not found", func(t *testing.T) {
next := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {