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
Gate same-name cross-instance node aggregation on TLS identity
[email protected]07d2f9845562
diff --git a/docs/release-control/v6/internal/subsystems/monitoring.md b/docs/release-control/v6/internal/subsystems/monitoring.mdindex 549aaa8938..19b3d30dc7 100644--- a/docs/release-control/v6/internal/subsystems/monitoring.md+++ b/docs/release-control/v6/internal/subsystems/monitoring.md@@ -102,9 +102,19 @@ Node state aggregation is cluster-identity-scoped beyond presentation: ahostname match alone must never bind a node to a host agent, and neither ashared linked-agent identity nor an endpoint merge alias may fold two nodeslots into one, when the two sides carry contradicting non-empty cluster-names. A hostname-based agent match is also rejected when the node's endpoint-IP is absent from the candidate agent's reported IPs. Nodes with empty-cluster names keep merging into their cluster view so standalone and+names. Cluster names shared across different connection instances are equally+ambiguous: such views stay split unless matching TOFU-captured TLS+fingerprints, propagated from the instance's endpoint records onto each node,+prove both views reach the same machine — then the legitimate+same-cluster-added-twice duplicate still folds into one slot even without+config-level endpoint overlap. Contradicting or unknown fingerprints keep the+fail-safe split. Agent binding follows the same doctrine: an endpoint address+match is not machine identity across sites that reuse RFC1918 ranges, so+every hostname- or IP-based agent match is rejected when the candidate+agent's linked nodes live in a different named cluster or carry a different+TLS fingerprint, and a hostname-based match is also rejected when the node's+endpoint IP is absent from the candidate agent's reported IPs. Nodes with+empty cluster names keep merging into their cluster view so standalone andnot-yet-classified endpoint views of the same machine still fold together.Docker and Podman container CPU collection preserves the runtime-native rawper-core CPU percent, but monitoring-owned history and alert threshold@@ -231,7 +241,9 @@ TOFU-captured TLS fingerprints veto consolidation whenever the instanceauthorities, a same-named endpoint, or a same-addressed endpoint carrycontradicting non-empty fingerprints. The fail-safe direction is fixed: acertificate rotation may leave a genuinely duplicated cluster as two views,-but two distinct clusters must never be silently folded into one.+but two distinct clusters must never be silently folded into one. The same+per-endpoint fingerprint evidence propagates onto monitored nodes so node+state aggregation applies the identical doctrine one layer down.Storage risk assessment owns the wearout evidence boundary for every consumer.diff --git a/internal/models/models.go b/internal/models/models.goindex e0eb06fb2e..61afb6f2c9 100644--- a/internal/models/models.go+++ b/internal/models/models.go@@ -118,6 +118,11 @@ type Node struct {IsClusterMember bool `json:"isClusterMember"` // True if part of a clusterClusterName string `json:"clusterName"` // Name of cluster (empty if standalone)ProviderScopedIdentity bool `json:"providerScopedIdentity,omitempty"`+ // TLSFingerprint is the TOFU-captured TLS certificate fingerprint recorded+ // in configuration for this node's API endpoint, when known. It is machine+ // identity evidence for state aggregation only, never a polling or trust+ // setting, and is not published to clients.+ TLSFingerprint string `json:"-"`// Package updates - polled less frequently (every 30 mins)PendingUpdates int `json:"pendingUpdates"` // Number of pending apt updates@@ -3421,12 +3426,25 @@ func registerNodeAliases(}}+// normalizeNodeTLSFingerprint reduces a TLS certificate fingerprint to a+// comparable form. Comparison-only: unknown stays empty, no validation.+func normalizeNodeTLSFingerprint(raw string) string {+ normalized := strings.ToLower(strings.TrimSpace(raw))+ normalized = strings.TrimPrefix(normalized, "sha256:")+ normalized = strings.ReplaceAll(normalized, ":", "")+ return strings.ReplaceAll(normalized, " ", "")+}+// nodeProviderIdentityConflicts reports whether two classified cluster nodes// belong to different provider scopes. Cluster names are display labels and// can legitimately repeat; two non-empty connection instances therefore stay-// distinct even when the label and member hostname are identical. Empty-// cluster identity still permits a standalone/not-yet-classified view to merge-// into its canonical cluster view by stronger endpoint or linked-agent proof.+// distinct even when the label and member hostname are identical, unless+// matching TOFU-captured TLS fingerprints prove both views reach the same+// machine (the same cluster added twice). Contradicting or unknown+// fingerprints keep the fail-safe split: two distinct clusters must never be+// silently folded into one. Empty cluster identity still permits a+// standalone/not-yet-classified view to merge into its canonical cluster view+// by stronger endpoint or linked-agent proof.func nodeProviderIdentityConflicts(a, b Node) bool {clusterA := normalizeNodeIdentityPart(a.ClusterName)clusterB := normalizeNodeIdentityPart(b.ClusterName)@@ -3438,7 +3456,12 @@ func nodeProviderIdentityConflicts(a, b Node) bool {}instanceA := normalizeNodeIdentityPart(a.Instance)instanceB := normalizeNodeIdentityPart(b.Instance)- return instanceA != "" && instanceB != "" && instanceA != instanceB+ if instanceA == "" || instanceB == "" || instanceA == instanceB {+ return false+ }+ fpA := normalizeNodeTLSFingerprint(a.TLSFingerprint)+ fpB := normalizeNodeTLSFingerprint(b.TLSFingerprint)+ return fpA == "" || fpA != fpB}func resolveNodeMergeKey(@@ -3584,9 +3607,10 @@ func (s *State) UpdateNodesForInstance(instanceName string, nodes []Node) {defer s.mu.Unlock()// Preserve LinkedAgentID for nodes that are being updated, including when IDs churn.- existingNodeLinks := make(map[string]string) // nodeID -> linkedAgentID- existingNodeLinksByLogicalKey := make(map[string]string) // logical node key -> linkedAgentID- agentClusterHints := make(map[string]map[string]struct{}) // linkedAgentID -> normalized cluster names of its linked nodes+ existingNodeLinks := make(map[string]string) // nodeID -> linkedAgentID+ existingNodeLinksByLogicalKey := make(map[string]string) // logical node key -> linkedAgentID+ agentClusterHints := make(map[string]map[string]struct{}) // linkedAgentID -> normalized cluster names of its linked nodes+ agentFingerprintHints := make(map[string]map[string]struct{}) // linkedAgentID -> normalized TLS fingerprints of its linked nodesfor _, node := range s.Nodes {if node.LinkedAgentID == "" {continue@@ -3603,6 +3627,14 @@ func (s *State) UpdateNodesForInstance(instanceName string, nodes []Node) {}hints[cluster] = struct{}{}}+ if fingerprint := normalizeNodeTLSFingerprint(node.TLSFingerprint); fingerprint != "" {+ hints := agentFingerprintHints[node.LinkedAgentID]+ if hints == nil {+ hints = make(map[string]struct{})+ agentFingerprintHints[node.LinkedAgentID] = hints+ }+ hints[fingerprint] = struct{}{}+ }}// Build map excluding nodes from this instance (they'll be replaced by the new set).@@ -3724,10 +3756,12 @@ func (s *State) UpdateNodesForInstance(instanceName string, nodes []Node) {}}- // Hostname matches are weak evidence: two clusters can reuse the same node- // names on different subnets. Reject a candidate agent when the evidence we- // do hold contradicts the node - the agent's linked nodes live in a different- // named cluster, or the node's endpoint IP is absent from the IPs the agent+ // Hostname and address matches are weak evidence: two clusters can reuse+ // the same node names, and sites that reuse RFC1918 ranges can present the+ // same endpoint IP for different machines. Reject a candidate agent when+ // the evidence we do hold contradicts the node - the agent's linked nodes+ // live in a different named cluster, carry a different TLS certificate+ // fingerprint, or the node's endpoint IP is absent from the IPs the agent// reports.hostContradictsNode := func(hostID string, node Node) bool {if hints := agentClusterHints[hostID]; len(hints) > 0 {@@ -3737,6 +3771,13 @@ func (s *State) UpdateNodesForInstance(instanceName string, nodes []Node) {}}}+ if fingerprint := normalizeNodeTLSFingerprint(node.TLSFingerprint); fingerprint != "" {+ if hints := agentFingerprintHints[hostID]; len(hints) > 0 {+ if _, sameMachine := hints[fingerprint]; !sameMachine {+ return true+ }+ }+ }if nodeIP := normalizeIPAddress(extractHostEndpoint(node.Host)); nodeIP != "" {if ips := hostIPsByID[hostID]; len(ips) > 0 {if _, known := ips[nodeIP]; !known {@@ -3770,8 +3811,13 @@ func (s *State) UpdateNodesForInstance(instanceName string, nodes []Node) {endpoint := extractHostEndpoint(node.Host)if ip := normalizeIPAddress(endpoint); ip != "" {if ids, ok := hostAgentByIP[ip]; ok {+ // An address match alone is not machine identity across+ // sites that reuse RFC1918 ranges: the cluster and+ // fingerprint evidence must not contradict.for hostID := range ids {- endpointCandidates[hostID] = struct{}{}+ if !hostContradictsNode(hostID, node) {+ endpointCandidates[hostID] = struct{}{}+ }}}} else if endpoint != "" {diff --git a/internal/models/state_host_test.go b/internal/models/state_host_test.goindex e57f774371..cf29d6ce62 100644--- a/internal/models/state_host_test.go+++ b/internal/models/state_host_test.go@@ -1632,3 +1632,261 @@ func TestUpdateNodesForInstanceHostnameMatchRejectedWhenIPContradicts(t *testingt.Fatalf("LinkedAgentID = %q, want none (agent IPs contradict node endpoint)", state.Nodes[0].LinkedAgentID)}}++// Two different clusters at different sites can reuse the same corosync+// cluster name, the same member hostnames, and the same RFC1918 addressing+// (MSP support case: two "enacon" clusters both exposing pve01 on+// 192.168.1.11). The colliding endpoint-IP alias must not merge the two node+// slots, and the address match must not bind the second site's node to the+// first site's host agent when the TLS fingerprint evidence contradicts.+func TestUpdateNodesForInstanceSameNamedClustersWithCollidingIPsStayApart(t *testing.T) {+ state := &State{+ Hosts: []Host{+ {+ ID: "host-site-a-pve01",+ Hostname: "pve01",+ ReportIP: "192.168.1.11",+ NetworkInterfaces: []HostNetworkInterface{+ {Name: "eth0", Addresses: []string{"192.168.1.11/24"}},+ },+ },+ },+ Nodes: []Node{+ {+ ID: "site-a-pve01",+ Name: "pve01",+ Instance: "site-a",+ ClusterName: "enacon",+ IsClusterMember: true,+ Host: "https://192.168.1.11:8006",+ TLSFingerprint: "AA:AA:AA:AA",+ LinkedAgentID: "host-site-a-pve01",+ Status: "online",+ },+ },+ }++ state.UpdateNodesForInstance("site-b", []Node{+ {+ ID: "site-b-pve01",+ Name: "pve01",+ Instance: "site-b",+ ClusterName: "enacon",+ IsClusterMember: true,+ Host: "https://192.168.1.11:8006",+ TLSFingerprint: "BB:BB:BB:BB",+ Status: "online",+ },+ })++ if len(state.Nodes) != 2 {+ t.Fatalf("nodes = %#v, want 2 (one per site)", state.Nodes)+ }+ byID := make(map[string]Node)+ for _, node := range state.Nodes {+ byID[node.ID] = node+ }+ siteA, ok := byID["site-a-pve01"]+ if !ok {+ t.Fatalf("site-a-pve01 was clobbered, nodes = %#v", state.Nodes)+ }+ if siteA.LinkedAgentID != "host-site-a-pve01" {+ t.Fatalf("site-a-pve01 LinkedAgentID = %q, want host-site-a-pve01", siteA.LinkedAgentID)+ }+ siteB, ok := byID["site-b-pve01"]+ if !ok {+ t.Fatalf("site-b-pve01 missing, nodes = %#v", state.Nodes)+ }+ if siteB.LinkedAgentID != "" {+ t.Fatalf("site-b-pve01 LinkedAgentID = %q, want none (fingerprint contradicts the colliding-IP agent match)", siteB.LinkedAgentID)+ }+}++// The endpoint-IP agent match must also respect the cluster-identity+// contradiction when no fingerprints are known: an agent whose linked nodes+// live in cluster "enacon" must not bind to a "rewo" node that presents the+// same RFC1918 address from another site.+func TestUpdateNodesForInstanceEndpointIPMatchRejectedWhenClusterContradicts(t *testing.T) {+ state := &State{+ Hosts: []Host{+ {+ ID: "host-enacon-pve01",+ Hostname: "pve01",+ ReportIP: "192.168.1.11",+ NetworkInterfaces: []HostNetworkInterface{+ {Name: "eth0", Addresses: []string{"192.168.1.11/24"}},+ },+ },+ },+ Nodes: []Node{+ {+ ID: "enacon-pve01",+ Name: "pve01",+ Instance: "enacon",+ ClusterName: "enacon",+ IsClusterMember: true,+ Host: "https://192.168.1.11:8006",+ LinkedAgentID: "host-enacon-pve01",+ Status: "online",+ },+ },+ }++ state.UpdateNodesForInstance("rewo", []Node{+ {+ ID: "rewo-pve01",+ Name: "pve01",+ Instance: "rewo",+ ClusterName: "rewo",+ IsClusterMember: true,+ Host: "https://192.168.1.11:8006",+ Status: "online",+ },+ })++ if len(state.Nodes) != 2 {+ t.Fatalf("nodes = %#v, want 2 (one per cluster)", state.Nodes)+ }+ for _, node := range state.Nodes {+ if node.ClusterName == "rewo" && node.LinkedAgentID != "" {+ t.Fatalf("rewo pve01 LinkedAgentID = %q, want none (agent belongs to the enacon cluster)", node.LinkedAgentID)+ }+ }+}++// The same cluster added twice through different connection instances is the+// legitimate duplicate: when both views carry the same TOFU-captured TLS+// fingerprint for the same-named node, the endpoint alias must still fold+// them into one slot even though the instances differ.+func TestUpdateNodesForInstanceSameClusterAddedTwiceMergesWithMatchingFingerprints(t *testing.T) {+ state := &State{+ Nodes: []Node{+ {+ ID: "enacon-a-pve01",+ Name: "pve01",+ Instance: "enacon-a",+ ClusterName: "enacon",+ IsClusterMember: true,+ Host: "https://192.168.1.11:8006",+ TLSFingerprint: "AA:AA:AA:AA",+ Status: "online",+ },+ },+ }++ state.UpdateNodesForInstance("enacon-b", []Node{+ {+ ID: "enacon-b-pve01",+ Name: "pve01",+ Instance: "enacon-b",+ ClusterName: "enacon",+ IsClusterMember: true,+ Host: "https://192.168.1.11:8006",+ TLSFingerprint: "aaaaaaaa",+ Status: "online",+ },+ })++ if len(state.Nodes) != 1 {+ t.Fatalf("nodes = %#v, want 1 (matching fingerprints prove one machine)", state.Nodes)+ }+ if state.Nodes[0].Name != "pve01" {+ t.Fatalf("merged node = %#v, want pve01", state.Nodes[0])+ }+}++// Without fingerprint evidence the same-named cluster from another instance+// stays split: unknown identity must never fold two possibly-distinct+// clusters into one (fail-safe direction).+func TestUpdateNodesForInstanceSameNamedClustersStayApartWithoutFingerprints(t *testing.T) {+ state := &State{+ Nodes: []Node{+ {+ ID: "enacon-a-pve01",+ Name: "pve01",+ Instance: "enacon-a",+ ClusterName: "enacon",+ IsClusterMember: true,+ Host: "https://192.168.1.11:8006",+ Status: "online",+ },+ },+ }++ state.UpdateNodesForInstance("enacon-b", []Node{+ {+ ID: "enacon-b-pve01",+ Name: "pve01",+ Instance: "enacon-b",+ ClusterName: "enacon",+ IsClusterMember: true,+ Host: "https://192.168.1.11:8006",+ Status: "online",+ },+ })++ if len(state.Nodes) != 2 {+ t.Fatalf("nodes = %#v, want 2 (unknown identity must not merge)", state.Nodes)+ }+}++// A shared agent link is the strongest cross-view merge signal, but for+// same-named clusters from different instances it must still be gated on+// fingerprint identity: matching fingerprints merge the duplicate views onto+// one slot, contradicting fingerprints never do.+func TestUpdateNodesForInstanceSharedAgentLinkMergeGatedOnFingerprint(t *testing.T) {+ makeState := func(existingFP string) *State {+ return &State{+ Hosts: []Host{+ {+ ID: "host-pve01",+ Hostname: "pve01",+ ReportIP: "192.168.1.11",+ NetworkInterfaces: []HostNetworkInterface{+ {Name: "eth0", Addresses: []string{"192.168.1.11/24"}},+ },+ },+ },+ Nodes: []Node{+ {+ ID: "enacon-a-pve01",+ Name: "pve01",+ Instance: "enacon-a",+ ClusterName: "enacon",+ IsClusterMember: true,+ Host: "https://pve01.site-a.internal:8006",+ TLSFingerprint: existingFP,+ LinkedAgentID: "host-pve01",+ Status: "online",+ },+ },+ }+ }+ incoming := func(fp string) []Node {+ return []Node{+ {+ ID: "enacon-b-pve01",+ Name: "pve01",+ Instance: "enacon-b",+ ClusterName: "enacon",+ IsClusterMember: true,+ Host: "https://192.168.1.11:8006",+ TLSFingerprint: fp,+ LinkedAgentID: "host-pve01",+ Status: "online",+ },+ }+ }++ merged := makeState("AA:AA:AA:AA")+ merged.UpdateNodesForInstance("enacon-b", incoming("AA:AA:AA:AA"))+ if len(merged.Nodes) != 1 {+ t.Fatalf("matching fingerprints: nodes = %#v, want 1", merged.Nodes)+ }++ split := makeState("AA:AA:AA:AA")+ split.UpdateNodesForInstance("enacon-b", incoming("BB:BB:BB:BB"))+ if len(split.Nodes) != 2 {+ t.Fatalf("contradicting fingerprints: nodes = %#v, want 2", split.Nodes)+ }+}diff --git a/internal/monitoring/monitor_node_tls_fingerprint_test.go b/internal/monitoring/monitor_node_tls_fingerprint_test.gonew file mode 100644index 0000000000..44e94fd07d--- /dev/null+++ b/internal/monitoring/monitor_node_tls_fingerprint_test.go@@ -0,0 +1,53 @@+package monitoring++import (+ "testing"++ "github.com/rcourtman/pulse-go-rewrite/internal/config"+)++// The TLS fingerprint propagated onto a node is per-machine identity+// evidence: a standalone node inherits the instance fingerprint, a cluster+// node inherits only its own named endpoint's fingerprint, and ambiguous or+// absent records stay unknown rather than asserting identity.+func TestPVENodeTLSFingerprint(t *testing.T) {+ standalone := &config.PVEInstance{Fingerprint: "AA:BB"}+ if got := pveNodeTLSFingerprint(standalone, "pve01"); got != "AA:BB" {+ t.Fatalf("standalone fingerprint = %q, want AA:BB", got)+ }++ cluster := &config.PVEInstance{+ IsCluster: true,+ Fingerprint: "CC:DD",+ ClusterEndpoints: []config.ClusterEndpoint{+ {NodeName: "pve01", Fingerprint: "AA:BB"},+ {NodeName: "pve02"},+ },+ }+ if got := pveNodeTLSFingerprint(cluster, "pve01"); got != "AA:BB" {+ t.Fatalf("cluster endpoint fingerprint = %q, want AA:BB", got)+ }+ // The instance-level fingerprint pins whichever member the connection URL+ // reaches; it must never be attributed to a different named member.+ if got := pveNodeTLSFingerprint(cluster, "pve02"); got != "" {+ t.Fatalf("member without endpoint fingerprint = %q, want unknown", got)+ }+ if got := pveNodeTLSFingerprint(cluster, "pve99"); got != "" {+ t.Fatalf("unknown member = %q, want unknown", got)+ }++ ambiguous := &config.PVEInstance{+ IsCluster: true,+ ClusterEndpoints: []config.ClusterEndpoint{+ {NodeName: "pve01", Fingerprint: "AA:BB"},+ {NodeName: "PVE01", Fingerprint: "EE:FF"},+ },+ }+ if got := pveNodeTLSFingerprint(ambiguous, "pve01"); got != "" {+ t.Fatalf("ambiguous duplicate endpoints = %q, want unknown", got)+ }++ if got := pveNodeTLSFingerprint(nil, "pve01"); got != "" {+ t.Fatalf("nil instance = %q, want unknown", got)+ }+}diff --git a/internal/monitoring/monitor_polling_node.go b/internal/monitoring/monitor_polling_node.goindex 85d5efec9f..eb640ba4bc 100644--- a/internal/monitoring/monitor_polling_node.go+++ b/internal/monitoring/monitor_polling_node.go@@ -75,6 +75,7 @@ func (m *Monitor) pollPVENode(IsClusterMember: instanceCfg.IsCluster,ClusterName: instanceCfg.ClusterName,ProviderScopedIdentity: m.pveNodeUsesProviderScopedIdentity(instanceName, instanceCfg),+ TLSFingerprint: pveNodeTLSFingerprint(instanceCfg, node.Node),TemperatureMonitoringEnabled: instanceCfg.TemperatureMonitoringEnabled,}var nodeDiskSource stringdiff --git a/internal/monitoring/monitor_polling_node_helpers.go b/internal/monitoring/monitor_polling_node_helpers.goindex 711a8f11c4..a2aa52e298 100644--- a/internal/monitoring/monitor_polling_node_helpers.go+++ b/internal/monitoring/monitor_polling_node_helpers.go@@ -87,6 +87,38 @@ func (m *Monitor) pveNodeID(instanceName string, instanceCfg *config.PVEInstancereturn m.pveNodeIdentityScope(instanceName, instanceCfg) + "-" + nativeName}+// pveNodeTLSFingerprint resolves the TOFU-captured TLS certificate+// fingerprint recorded in configuration for one node's API endpoint. The+// fingerprint is per-machine identity evidence for node state aggregation, so+// a cluster node only inherits the fingerprint of its own named endpoint -+// never the instance-level fingerprint, which pins whichever member the+// connection URL happens to reach. Unknown stays empty and asserts nothing.+func pveNodeTLSFingerprint(instanceCfg *config.PVEInstance, nodeName string) string {+ if instanceCfg == nil {+ return ""+ }+ if !instanceCfg.IsCluster {+ return strings.TrimSpace(instanceCfg.Fingerprint)+ }+ nodeName = strings.TrimSpace(nodeName)+ match := ""+ for _, endpoint := range instanceCfg.ClusterEndpoints {+ if !strings.EqualFold(strings.TrimSpace(endpoint.NodeName), nodeName) {+ continue+ }+ fingerprint := strings.TrimSpace(endpoint.Fingerprint)+ if fingerprint == "" {+ continue+ }+ if match != "" && !strings.EqualFold(match, fingerprint) {+ // Ambiguous duplicate endpoint records fail unknown.+ return ""+ }+ match = fingerprint+ }+ return match+}+func (m *Monitor) pveNodeUsesProviderScopedIdentity(instanceName string, instanceCfg *config.PVEInstance) bool {if instanceCfg == nil || !instanceCfg.IsCluster || strings.TrimSpace(instanceCfg.ClusterName) == "" {return falsediff --git a/internal/monitoring/monitor_pve.go b/internal/monitoring/monitor_pve.goindex 5f4ced3161..1edc33ccc9 100644--- a/internal/monitoring/monitor_pve.go+++ b/internal/monitoring/monitor_pve.go@@ -674,6 +674,7 @@ func (m *Monitor) placeholderNodeForInstance(instanceName string, instanceCfg *cIsClusterMember: instanceCfg.IsCluster,ClusterName: instanceCfg.ClusterName,ProviderScopedIdentity: m.pveNodeUsesProviderScopedIdentity(instanceName, instanceCfg),+ TLSFingerprint: pveNodeTLSFingerprint(instanceCfg, nodeName),TemperatureMonitoringEnabled: instanceCfg.TemperatureMonitoringEnabled,}}