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.

Keep internal saved pin conflicts out of cluster consolidation

pulse-triage[bot]3f9c974b5a01
diff --git a/docs/release-control/v6/internal/subsystems/monitoring.md b/docs/release-control/v6/internal/subsystems/monitoring.md
index 70935ac59b..20125d00c5 100644
--- a/docs/release-control/v6/internal/subsystems/monitoring.md
+++ b/docs/release-control/v6/internal/subsystems/monitoring.md
@@ -59,6 +59,10 @@ clients keep monitoring; topology changes wait for independently reconciled
configuration. `TestClusterPinConflictsSurviveMonitorLifecycle` exercises the
actual initialisation, missing-client retry and refresh/rebuild paths in all
three auth modes and both layouts, including normal refresh after reconciliation.
+Saved-view consolidation also refuses a view with internal pin contradictions,
+so map indexing cannot hide an earlier contradictory row before monitoring
+starts. `TestConsolidatePVEInstancesRetainsInternallyConflictingPins` covers
+both merge orders, repeated rows, same-node/address evidence and agreeing formats.
This establishes source/consumer behaviour, not native recovery or attribution
of a guest, PBS or certificate report.
diff --git a/docs/release-control/v6/internal/subsystems/security-privacy.md b/docs/release-control/v6/internal/subsystems/security-privacy.md
index d9f14d1346..d71a28a754 100644
--- a/docs/release-control/v6/internal/subsystems/security-privacy.md
+++ b/docs/release-control/v6/internal/subsystems/security-privacy.md
@@ -60,6 +60,10 @@ clients keep monitoring; topology changes wait for independently reconciled
configuration. `TestClusterPinConflictsSurviveMonitorLifecycle` exercises the
actual initialisation, missing-client retry and refresh/rebuild paths in all
three auth modes and both layouts, including normal refresh after reconciliation.
+Saved-view consolidation also refuses a view with internal pin contradictions,
+so map indexing cannot hide an earlier contradictory row before monitoring
+starts. `TestConsolidatePVEInstancesRetainsInternallyConflictingPins` covers
+both merge orders, repeated rows, same-node/address evidence and agreeing formats.
This establishes source/consumer behaviour, not native recovery or attribution
of a guest, PBS or certificate report.
diff --git a/internal/config/pve_conflicting_rows_test.go b/internal/config/pve_conflicting_rows_test.go
new file mode 100644
index 0000000000..12df670982
--- /dev/null
+++ b/internal/config/pve_conflicting_rows_test.go
@@ -0,0 +1,43 @@
+package config
+
+import (
+ "reflect"
+ "testing"
+)
+
+// Loading multiple saved views must not collapse one view's contradictory
+// rows before monitoring can refuse its unresolved trust. Cover both merge
+// orders and a final repeated row matching the other view's selected pin.
+func TestConsolidatePVEInstancesRetainsInternallyConflictingPins(t *testing.T) {
+ for _, layout := range []string{"same-node", "same-address"} {
+ for _, reverse := range []bool{false, true} {
+ t.Run(layout+map[bool]string{false: "/forward", true: "/reverse"}[reverse], func(t *testing.T) {
+ member := ClusterEndpoint{NodeName: "member", Host: "https://member.invalid:8006", Fingerprint: "aa:bb"}
+ conflicting := member
+ conflicting.Fingerprint = "cc:dd"
+ if layout == "same-address" {
+ conflicting.NodeName = "member-alias"
+ }
+ ambiguous := PVEInstance{Name: "Ambiguous", IsCluster: true, ClusterName: "home", Host: member.Host, Fingerprint: "aa:bb", ClusterEndpoints: []ClusterEndpoint{member, conflicting, member}}
+ ordinary := PVEInstance{Name: "Ordinary", IsCluster: true, ClusterName: "home", Host: member.Host, Fingerprint: "aa:bb", ClusterEndpoints: []ClusterEndpoint{member}}
+ instances := []PVEInstance{ambiguous, ordinary}
+ if reverse {
+ instances[0], instances[1] = instances[1], instances[0]
+ }
+ saved := []PVEInstance{instances[0].DeepCopy(), instances[1].DeepCopy()}
+ got, changed := ConsolidatePVEInstances(instances)
+ if changed || !reflect.DeepEqual(got, saved) || !reflect.DeepEqual(instances, saved) {
+ t.Fatal("consolidation discarded contradictory saved trust or changed source rows")
+ }
+ if PVEClusterInstancesShareIdentity(instances[0], instances[1]) {
+ t.Fatal("internally contradictory saved trust admitted an identity merge")
+ }
+ // Independently reconciled saved formats can still consolidate normally.
+ ambiguous.ClusterEndpoints[1].Fingerprint = "AA:BB"
+ if _, changed := ConsolidatePVEInstances([]PVEInstance{ambiguous, ordinary}); !changed {
+ t.Fatal("agreeing independently reconciled views could no longer consolidate")
+ }
+ })
+ }
+ }
+}
diff --git a/internal/config/pve_instances.go b/internal/config/pve_instances.go
index 8fdc78d20e..7feb513837 100644
--- a/internal/config/pve_instances.go
+++ b/internal/config/pve_instances.go
@@ -93,7 +93,7 @@ func pveClusterInstancesHaveFingerprintConflict(a, b PVEInstance) bool {
if ProxmoxFingerprintsConflict(a.Fingerprint, b.Fingerprint) {
return true
}
- indexEndpoints := func(instance PVEInstance) (byNode, byKey map[string]string) {
+ indexEndpoints := func(instance PVEInstance) (byNode, byKey map[string]string, ambiguous bool) {
byNode = make(map[string]string)
byKey = make(map[string]string)
for _, endpoint := range instance.ClusterEndpoints {
@@ -102,16 +102,28 @@ func pveClusterInstancesHaveFingerprintConflict(a, b PVEInstance) bool {
continue
}
if node := strings.TrimSpace(strings.ToLower(endpoint.NodeName)); node != "" {
+ if previous, ok := byNode[node]; ok && previous != fp {
+ ambiguous = true
+ }
byNode[node] = fp
}
for _, key := range clusterEndpointIdentityKeys(endpoint) {
+ if previous, ok := byKey[key]; ok && previous != fp {
+ ambiguous = true
+ }
byKey[key] = fp
}
}
- return byNode, byKey
+ return byNode, byKey, ambiguous
+ }
+ aByNode, aByKey, aAmbiguous := indexEndpoints(a)
+ bByNode, bByKey, bAmbiguous := indexEndpoints(b)
+ // Consolidation must not erase a contradiction within either saved view
+ // before the runtime trust resolver can refuse it. A later repeated row
+ // matching the other view is not independent reconciliation of saved trust.
+ if aAmbiguous || bAmbiguous {
+ return true
}
- aByNode, aByKey := indexEndpoints(a)
- bByNode, bByKey := indexEndpoints(b)
for node, fp := range bByNode {
if existing, ok := aByNode[node]; ok && existing != fp {
return true
diff --git a/internal/monitoring/monitor_pve_pin_conflict_test.go b/internal/monitoring/monitor_pve_pin_conflict_test.go
index ef634524b0..cad10deaae 100644
--- a/internal/monitoring/monitor_pve_pin_conflict_test.go
+++ b/internal/monitoring/monitor_pve_pin_conflict_test.go
@@ -202,7 +202,7 @@ func TestClusterPinConflictsSurviveMonitorLifecycle(t *testing.T) {
} else {
inst.User, inst.Password = "fixture@pam", "fixture-password"
}
- m := &Monitor{config: &config.Config{PVEInstances: []config.PVEInstance{inst}, ConnectionTimeout: 2 * time.Second}, pveClients: make(map[string]PVEClientInterface)}
+ m := &Monitor{config: &config.Config{PVEInstances: []config.PVEInstance{inst.DeepCopy()}, ConnectionTimeout: 2 * time.Second}, pveClients: make(map[string]PVEClientInterface)}
switch route {
case "init":
m.initPVEClients(m.config)