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.

Harden dotted hostname identity pin compatibility

mz010d6435b815
diff --git a/docs/release-control/v6/internal/subsystems/registry.json b/docs/release-control/v6/internal/subsystems/registry.json
index 8e3400bf21..396b4d304a 100644
--- a/docs/release-control/v6/internal/subsystems/registry.json
+++ b/docs/release-control/v6/internal/subsystems/registry.json
@@ -6571,6 +6571,7 @@
"allow_same_subsystem_tests": false,
"test_prefixes": [],
"exact_files": [
+ "internal/unifiedresources/canonical_id_pins_test.go",
"internal/unifiedresources/code_standards_test.go",
"internal/unifiedresources/kubernetes_registry_test.go",
"internal/unifiedresources/metrics_targets_test.go",
diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.md
index 57324f2968..667a68dfd4 100644
--- a/docs/release-control/v6/internal/subsystems/unified-resources.md
+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md
@@ -1348,7 +1348,12 @@ AI-only summary payloads, or page-local heuristics.
/ `ListResourceIdentityPins`, written diff-aware after monitor-adapter
rebuilds) and completes weak incoming identities from those pins
before matching and ID derivation
- (`internal/unifiedresources/canonical_id_pins.go`). Change-journal
+ (`internal/unifiedresources/canonical_id_pins.go`). Persisted primary
+ hostnames preserve their normalized dotted form. The pin index resolves
+ that exact primary hostname first and exposes the historical short-name
+ form only as an ambiguity-safe compatibility alias; two dotted hostnames
+ that share a first label must never resolve through that shared alias.
+ Change-journal
reads (`GetRecentChanges*` / `CountRecentChanges*`) must expand a
canonical ID to the era set recomputable from its pinned identity keys
(`ResourceIdentityPin.EraIDs`) so journal rows recorded under an
diff --git a/internal/unifiedresources/identity.go b/internal/unifiedresources/identity.go
index e44ccbd7ef..c44cb6050f 100644
--- a/internal/unifiedresources/identity.go
+++ b/internal/unifiedresources/identity.go
@@ -29,7 +29,7 @@ func NormalizeHostname(hostname string) string {
// machines that share a short name keep distinct identity keys.
func NormalizeFullHostname(hostname string) string {
host := strings.TrimSpace(strings.ToLower(hostname))
- return strings.TrimSuffix(host, ".")
+ return strings.TrimRight(host, ".")
}
// NormalizeMAC normalizes a MAC address to lower-case colon format.
diff --git a/internal/unifiedresources/identity_test.go b/internal/unifiedresources/identity_test.go
index 17f91f0332..e9aa5576dc 100644
--- a/internal/unifiedresources/identity_test.go
+++ b/internal/unifiedresources/identity_test.go
@@ -19,6 +19,21 @@ func TestNormalizeHostname(t *testing.T) {
}
}
+func TestNormalizeFullHostnamePreservesDottedNames(t *testing.T) {
+ cases := map[string]string{
+ "PVE1.Homelab.LAN": "pve1.homelab.lan",
+ "pve1.local": "pve1.local",
+ "pve1": "pve1",
+ "pve1.": "pve1",
+ "pve1...": "pve1",
+ }
+ for input, want := range cases {
+ if got := NormalizeFullHostname(input); got != want {
+ t.Fatalf("NormalizeFullHostname(%q) = %q, want %q", input, got, want)
+ }
+ }
+}
+
func TestMachineIDMatchMerges(t *testing.T) {
store := NewMemoryStore()
registry := NewRegistry(store)
diff --git a/internal/unifiedresources/ids_test.go b/internal/unifiedresources/ids_test.go
index c2bbfe37cf..31c40072a8 100644
--- a/internal/unifiedresources/ids_test.go
+++ b/internal/unifiedresources/ids_test.go
@@ -79,6 +79,19 @@ func TestResourceIdentityPinEraIDs(t *testing.T) {
}
}
+func TestResourceIdentityPinPreservesDottedPrimaryHostname(t *testing.T) {
+ pin := ResourceIdentityPin{
+ CanonicalID: "agent-custom",
+ ResourceType: ResourceTypeAgent,
+ MachineID: "machine-1",
+ Hostname: "Cloud.Rnd-Lax1.",
+ }.normalized()
+
+ if pin.Hostname != "cloud.rnd-lax1" {
+ t.Fatalf("normalized pin hostname = %q, want %q", pin.Hostname, "cloud.rnd-lax1")
+ }
+}
+
func TestResourceIdentityPinEraIDsSkipsWeakOnlyKeys(t *testing.T) {
pin := ResourceIdentityPin{
CanonicalID: "agent-custom",