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.

Veto PVE cluster consolidation on contradicting TLS fingerprints

[email protected]f21d05e3cbdc
diff --git a/docs/release-control/v6/internal/subsystems/monitoring.md b/docs/release-control/v6/internal/subsystems/monitoring.md
index 1c23a58a5e..549aaa8938 100644
--- a/docs/release-control/v6/internal/subsystems/monitoring.md
+++ b/docs/release-control/v6/internal/subsystems/monitoring.md
@@ -225,6 +225,13 @@ uncertainty into removal. A newly reported member is admitted immediately.
Cluster display names are not global identity: config consolidation requires
overlapping endpoint authority, and different provider instances with the same
cluster/member names stay distinct in node and storage identity.
+Endpoint address overlap is not sufficient identity either: sites that reuse
+RFC1918 ranges can present colliding member IPs for different machines, so
+TOFU-captured TLS fingerprints veto consolidation whenever the instance
+authorities, a same-named endpoint, or a same-addressed endpoint carry
+contradicting non-empty fingerprints. The fail-safe direction is fixed: a
+certificate rotation may leave a genuinely duplicated cluster as two views,
+but two distinct clusters must never be silently folded into one.
Storage risk assessment owns the wearout evidence boundary for every consumer.
diff --git a/internal/config/pve_instances.go b/internal/config/pve_instances.go
index d8906afb9d..774299ca7a 100644
--- a/internal/config/pve_instances.go
+++ b/internal/config/pve_instances.go
@@ -62,6 +62,69 @@ func (instance PVEInstance) DeepCopy() PVEInstance {
return clonePVEInstances([]PVEInstance{instance})[0]
}
+// normalizePVEFingerprint reduces a TLS certificate fingerprint to a
+// comparable form. Comparison-only: unknown stays empty, no validation.
+func normalizePVEFingerprint(raw string) string {
+ normalized := strings.ToLower(strings.TrimSpace(raw))
+ normalized = strings.TrimPrefix(normalized, "sha256:")
+ normalized = strings.ReplaceAll(normalized, ":", "")
+ return strings.ReplaceAll(normalized, " ", "")
+}
+
+// pveFingerprintsConflict reports whether two TLS fingerprints are both known
+// and disagree. Contradicting fingerprints identify two different machines,
+// which outweighs any name or address coincidence between sites that reuse
+// node hostnames and RFC1918 ranges.
+func pveFingerprintsConflict(a, b string) bool {
+ fpA := normalizePVEFingerprint(a)
+ fpB := normalizePVEFingerprint(b)
+ return fpA != "" && fpB != "" && fpA != fpB
+}
+
+// pveClusterInstancesHaveFingerprintConflict reports whether two cluster
+// instances carry TOFU-captured TLS evidence that they are different clusters:
+// the instance authorities, a same-named endpoint, or a same-addressed
+// endpoint present contradicting certificate fingerprints. A conflict vetoes
+// consolidation even when cluster names and member addresses coincide. The
+// fail-safe direction is deliberate: a genuinely duplicated cluster whose
+// certificate rotated between discoveries stays as two views rather than two
+// distinct clusters being silently folded into one.
+func pveClusterInstancesHaveFingerprintConflict(a, b PVEInstance) bool {
+ if pveFingerprintsConflict(a.Fingerprint, b.Fingerprint) {
+ return true
+ }
+ indexEndpoints := func(instance PVEInstance) (byNode, byKey map[string]string) {
+ byNode = make(map[string]string)
+ byKey = make(map[string]string)
+ for _, endpoint := range instance.ClusterEndpoints {
+ fp := normalizePVEFingerprint(endpoint.Fingerprint)
+ if fp == "" {
+ continue
+ }
+ if node := strings.TrimSpace(strings.ToLower(endpoint.NodeName)); node != "" {
+ byNode[node] = fp
+ }
+ for _, key := range clusterEndpointIdentityKeys(endpoint) {
+ byKey[key] = fp
+ }
+ }
+ return byNode, byKey
+ }
+ aByNode, aByKey := indexEndpoints(a)
+ bByNode, bByKey := indexEndpoints(b)
+ for node, fp := range bByNode {
+ if existing, ok := aByNode[node]; ok && existing != fp {
+ return true
+ }
+ }
+ for key, fp := range bByKey {
+ if existing, ok := aByKey[key]; ok && existing != fp {
+ return true
+ }
+ }
+ return false
+}
+
func mergeDuplicateClusterInstances(instances []PVEInstance) ([]PVEInstance, bool) {
removed := make(map[int]struct{})
mergedAny := false
@@ -85,6 +148,7 @@ func mergeDuplicateClusterInstances(instances []PVEInstance) ([]PVEInstance, boo
duplicate := instances[dupIdx]
if !duplicate.IsCluster ||
!strings.EqualFold(strings.TrimSpace(primary.ClusterName), strings.TrimSpace(duplicate.ClusterName)) ||
+ pveClusterInstancesHaveFingerprintConflict(*primary, duplicate) ||
!pveClusterInstancesHaveStrongOverlap(*primary, duplicate) {
continue
}
@@ -446,6 +510,9 @@ func mergeStandalonePVEIntoClusters(instances []PVEInstance) bool {
}
endpoint := &instances[ref.clusterIdx].ClusterEndpoints[ref.endpointIdx]
+ if pveFingerprintsConflict(instances[idx].Fingerprint, endpoint.Fingerprint) {
+ continue
+ }
mergeClusterEndpointData(endpoint, ClusterEndpoint{
Host: instances[idx].Host,
GuestURL: instances[idx].GuestURL,
diff --git a/internal/config/pve_instances_test.go b/internal/config/pve_instances_test.go
index dbd0fbf7b8..cb39ed799a 100644
--- a/internal/config/pve_instances_test.go
+++ b/internal/config/pve_instances_test.go
@@ -203,3 +203,63 @@ func TestConsolidatePVEInstancesMergesDuplicateClusterAuthIntoPrimary(t *testing
t.Fatalf("expected 2 endpoints after consolidation, got %d", len(instances[0].ClusterEndpoints))
}
}
+
+func TestConsolidatePVEInstancesKeepsSameNameClustersWithCollidingPrivateIPs(t *testing.T) {
+ // Two customer sites reuse the same corosync cluster name and the same
+ // RFC1918 addressing, so discovered member IPs collide. The TOFU-captured
+ // TLS fingerprints are the evidence that these are different machines.
+ instances, changed := ConsolidatePVEInstances([]PVEInstance{
+ {
+ Name: "site-a",
+ Host: "https://site-a.example:8006",
+ ClusterName: "production",
+ IsCluster: true,
+ ClusterEndpoints: []ClusterEndpoint{
+ {NodeName: "pve01", Host: "https://192.168.1.10:8006", IP: "192.168.1.10", Fingerprint: "fp-site-a"},
+ },
+ },
+ {
+ Name: "site-b",
+ Host: "https://site-b.example:8006",
+ ClusterName: "production",
+ IsCluster: true,
+ ClusterEndpoints: []ClusterEndpoint{
+ {NodeName: "pve01", Host: "https://192.168.1.10:8006", IP: "192.168.1.10", Fingerprint: "fp-site-b"},
+ },
+ },
+ })
+
+ if changed {
+ t.Fatalf("same-name clusters with contradicting endpoint fingerprints must not be consolidated")
+ }
+ if len(instances) != 2 {
+ t.Fatalf("instances = %d, want 2 distinct clusters", len(instances))
+ }
+}
+
+func TestConsolidatePVEInstancesKeepsStandaloneWithContradictingFingerprint(t *testing.T) {
+ // A standalone whose address collides with a cluster endpoint at another
+ // site must not fold into that cluster when its TLS fingerprint disagrees.
+ instances, changed := ConsolidatePVEInstances([]PVEInstance{
+ {
+ Name: "site-a",
+ ClusterName: "cluster-A",
+ IsCluster: true,
+ ClusterEndpoints: []ClusterEndpoint{
+ {NodeName: "pve01", Host: "https://192.168.1.10:8006", Fingerprint: "fp-cluster"},
+ },
+ },
+ {
+ Name: "other-site-standalone",
+ Host: "192.168.1.10",
+ Fingerprint: "fp-standalone",
+ },
+ })
+
+ if changed {
+ t.Fatalf("standalone with contradicting fingerprint must not be consolidated into the cluster")
+ }
+ if len(instances) != 2 {
+ t.Fatalf("expected both instances to remain, got %d", len(instances))
+ }
+}