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.

Require qualified Proxmox pin endpoints

pulse-triage[bot]7558d422eab8
diff --git a/internal/unifiedresources/canonical_id_pins.go b/internal/unifiedresources/canonical_id_pins.go
index 384712afd5..ece08ab9b7 100644
--- a/internal/unifiedresources/canonical_id_pins.go
+++ b/internal/unifiedresources/canonical_id_pins.go
@@ -145,8 +145,8 @@ func (index *identityPinIndex) findProxmoxNode(resource Resource, identity Resou
}
clusterName := strings.TrimSpace(identity.ClusterName)
- endpoint := NormalizeFullHostname(extractHostname(resource.Proxmox.HostURL))
- if endpoint != "" && net.ParseIP(endpoint) == nil {
+ endpoint := proxmoxProviderPinHostname(resource)
+ if endpoint != "" {
if clusterName != "" {
if pin, ok := resolvePinBucket(index.byClusterHost[clusterHostPinKey(clusterName, endpoint)], endpoint, machineID, dmiUUID); ok {
return pin, true
@@ -171,6 +171,23 @@ func (index *identityPinIndex) findProxmoxNode(resource Resource, identity Resou
return ResourceIdentityPin{}, false
}
+// proxmoxProviderPinHostname returns endpoint evidence that is sufficiently
+// scoped to persist and recover a Proxmox node pin. IP addresses and
+// single-label names are commonly reused across independent private networks,
+// so neither can distinguish estates on its own. A qualified configured name
+// can preserve standalone continuity without falling back to the native node's
+// typically short hostname.
+func proxmoxProviderPinHostname(resource Resource) string {
+ if resource.Proxmox == nil {
+ return ""
+ }
+ endpoint := NormalizeFullHostname(extractHostname(resource.Proxmox.HostURL))
+ if endpoint == "" || net.ParseIP(endpoint) != nil || !strings.Contains(endpoint, ".") {
+ return ""
+ }
+ return endpoint
+}
+
// resolvePinBucket resolves a hostname bucket lookup. The bucket must be
// unambiguous (exactly one pin), the pinned hostname must be the incoming one
// or its short/FQDN equivalent (two distinct FQDNs sharing a short name never
diff --git a/internal/unifiedresources/ids.go b/internal/unifiedresources/ids.go
index 0811f16d93..7be3372e17 100644
--- a/internal/unifiedresources/ids.go
+++ b/internal/unifiedresources/ids.go
@@ -4,7 +4,6 @@ import (
"crypto/sha256"
"encoding/hex"
"fmt"
- "net"
"strconv"
"strings"
)
@@ -177,7 +176,7 @@ func identityPinForResource(resource *Resource) (ResourceIdentityPin, bool) {
// pin that provider-scoped hostname so a provider-only boot can recover the
// machine identity without making the short name globally authoritative.
if resource.Proxmox != nil {
- if endpoint := NormalizeFullHostname(extractHostname(resource.Proxmox.HostURL)); endpoint != "" && net.ParseIP(endpoint) == nil {
+ if endpoint := proxmoxProviderPinHostname(*resource); endpoint != "" {
hostname = endpoint
}
}
diff --git a/internal/unifiedresources/issue1753_provider_scope_test.go b/internal/unifiedresources/issue1753_provider_scope_test.go
index 5cebdadede..0c52ab136d 100644
--- a/internal/unifiedresources/issue1753_provider_scope_test.go
+++ b/internal/unifiedresources/issue1753_provider_scope_test.go
@@ -93,3 +93,36 @@ func TestIssue1753LegacyShortHostnamePinCannotClaimMultipleProviderScopes(t *tes
}
}
}
+
+func TestIssue1753RepeatedShortProviderEndpointCannotClaimLegacyPin(t *testing.T) {
+ store := NewMemoryStore()
+ if err := store.UpsertResourceIdentityPins([]ResourceIdentityPin{{
+ CanonicalID: MachineIdentityCanonicalID(ResourceTypeAgent, "machine-staging"),
+ ResourceType: ResourceTypeAgent,
+ MachineID: "machine-staging",
+ Hostname: "pve",
+ }}); err != nil {
+ t.Fatalf("seed legacy identity pin: %v", err)
+ }
+
+ registry := NewRegistry(store)
+ registry.IngestSnapshot(models.StateSnapshot{Nodes: []models.Node{
+ {ID: "staging-pve", NodeIdentity: "staging-pve", Name: "pve", DisplayName: "Staging", Instance: "staging", Host: "https://pve:8006", Status: "online"},
+ {ID: "production-pve", NodeIdentity: "production-pve", Name: "pve", DisplayName: "Production", Instance: "production", Host: "https://pve:8006", Status: "online"},
+ }})
+
+ var nodes []Resource
+ for _, resource := range registry.ListForPresentation() {
+ if resource.Type == ResourceTypeAgent && resource.Proxmox != nil {
+ nodes = append(nodes, resource)
+ }
+ }
+ if len(nodes) != 2 {
+ t.Fatalf("repeated short endpoint collapsed provider scopes: %+v", nodes)
+ }
+ for _, node := range nodes {
+ if node.Identity.MachineID != "" {
+ t.Fatalf("short endpoint leaked machine identity into %q: %+v", node.Proxmox.Instance, node.Identity)
+ }
+ }
+}