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 the system hostname when migrating to the safe profile

rcourtman5ad599fc98f0
diff --git a/scripts/install.sh b/scripts/install.sh
index a0bdd04a7e..0320b7addd 100755
--- a/scripts/install.sh
+++ b/scripts/install.sh
@@ -669,10 +669,10 @@ collector_lifecycle_binary() {
}
resolve_safe_profile_hostname() {
+ # Pin the system hostname the agent already reports. hostname -f would
+ # rename a host to its FQDN on migration while root-profile hosts keep the
+ # short name, and the server's authority check accepts either form.
local resolved_hostname="${HOSTNAME_OVERRIDE:-}"
- if [[ -z "$resolved_hostname" ]]; then
- resolved_hostname=$(hostname -f 2>/dev/null || true)
- fi
if [[ -z "$resolved_hostname" ]]; then
resolved_hostname=$(hostname 2>/dev/null || true)
fi
diff --git a/scripts/installtests/install_sh_test.go b/scripts/installtests/install_sh_test.go
index 42e6c3bfc1..3e16f4d825 100644
--- a/scripts/installtests/install_sh_test.go
+++ b/scripts/installtests/install_sh_test.go
@@ -8328,6 +8328,36 @@ reduce_safe_profile_collector_authority
}
}
+// Migrating to the safe profile must keep the name the agent already reported.
+// Pinning hostname -f renamed Proxmox hosts to their FQDN while every
+// root-profile host kept its short system hostname.
+func TestInstallSHSafeProfileHostnameKeepsSystemHostname(t *testing.T) {
+ script := `
+set -euo pipefail
+hostname() {
+ if [[ "${1:-}" == "-f" || "${1:-}" == "--fqdn" ]]; then
+ printf 'luna.nexus.example.test\n'
+ else
+ printf 'Luna\n'
+ fi
+}
+` + extractInstallShellFunction(t, "resolve_safe_profile_hostname") + `
+HOSTNAME_OVERRIDE=""
+resolve_safe_profile_hostname
+printf 'resolved=%s\n' "$HOSTNAME_OVERRIDE"
+HOSTNAME_OVERRIDE="Pinned.Example.Test."
+resolve_safe_profile_hostname
+printf 'explicit=%s\n' "$HOSTNAME_OVERRIDE"
+`
+ out, err := exec.Command("bash", "-c", script).CombinedOutput()
+ if err != nil {
+ t.Fatalf("resolve safe profile hostname: %v\n%s", err, out)
+ }
+ if got := string(out); got != "resolved=luna\nexplicit=pinned.example.test\n" {
+ t.Fatalf("safe profile hostname output = %q", got)
+ }
+}
+
func TestInstallSHCollectorLifecycleRejectsActiveMITMForgedSuccess(t *testing.T) {
const token = "collector-mitm-secret"
var authorizationSeen bool