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.

Fix PVE version detection on agent hosts

rcourtmanaab37117653c
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
index fc8a089de1..efeafd6a2a 100644
--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
@@ -210,6 +210,10 @@ operator-facing system identity split: a Proxmox VE node may report a Debian
runtime platform underneath, but the host-agent OS identity and infrastructure
System badge must resolve and present `Proxmox VE` / `PVE` from PVE runtime
evidence instead of exposing the Debian base distro as the primary system label.
+The agent-side PVE version probe must prefer fast package metadata such as the
+installed `pve-manager` package before falling back to `pveversion`, and that
+fallback budget must tolerate slower ARM/Pi PVE installs so platform identity
+does not lose the runtime version on small lab nodes.
The lifecycle-owned infrastructure source manager also owns platform/system
grouping as source-management content, but not its table band presentation:
`frontend-modern/src/components/Settings/InfrastructureSourceManager.tsx` must
@@ -2148,6 +2152,11 @@ When gopsutil reports generic Linux platform fields on NAS appliances,
or QNAP QTS/QuTS version manifests before the first report is built, so
downstream monitoring and alerting do not depend on hostname or display-name
heuristics to infer the real vendor OS.
+Proxmox VE host identity follows the same vendor-aware rule: when `/etc/pve`,
+`pveversion`, or Proxmox package metadata proves the host is PVE,
+`internal/hostagent/` must report `Proxmox VE` plus the PVE product version
+when available, while preserving the underlying Linux runtime platform for
+runtime/platform-normalization decisions.
That same runtime continuity must stay on direct lifecycle proof routes too:
changes under `internal/hostagent/` must continue to carry the explicit
`unified-agent-runtime` proof, and changes under `internal/agentupdate/` must
diff --git a/internal/hostagent/agent_new_test.go b/internal/hostagent/agent_new_test.go
index f79ce1d067..7c26986f33 100644
--- a/internal/hostagent/agent_new_test.go
+++ b/internal/hostagent/agent_new_test.go
@@ -8,6 +8,7 @@ import (
"net/http"
"os"
"path/filepath"
+ "reflect"
"runtime"
"strings"
"testing"
@@ -130,6 +131,126 @@ func TestNew_ResolvesProxmoxVEHostIdentity(t *testing.T) {
}
}
+func TestNew_ResolvesProxmoxVEVersionFromPackageMetadata(t *testing.T) {
+ pveVersionCalled := false
+ mc := &mockCollector{
+ hostInfoFn: func(context.Context) (*gohost.InfoStat, error) {
+ return &gohost.InfoStat{
+ Hostname: "pve-host",
+ HostID: "hid",
+ Platform: "raspbian",
+ PlatformFamily: "debian",
+ PlatformVersion: "12.12",
+ KernelVersion: "6.12.47+rpt-rpi-v8",
+ KernelArch: runtime.GOARCH,
+ }, nil
+ },
+ statFn: func(name string) (os.FileInfo, error) {
+ if name == "/etc/pve" {
+ return nil, nil
+ }
+ return nil, os.ErrNotExist
+ },
+ lookPathFn: func(file string) (string, error) {
+ switch file {
+ case "dpkg-query":
+ return "/usr/bin/dpkg-query", nil
+ case "pveversion":
+ return "/usr/bin/pveversion", nil
+ default:
+ return "", os.ErrNotExist
+ }
+ },
+ commandCombinedOutputFn: func(ctx context.Context, name string, arg ...string) (string, error) {
+ switch name {
+ case "/usr/bin/dpkg-query":
+ wantArgs := []string{"-W", "-f=${Version}", "pve-manager"}
+ if !reflect.DeepEqual(arg, wantArgs) {
+ t.Fatalf("dpkg-query args = %#v, want %#v", arg, wantArgs)
+ }
+ return "8.3.3", nil
+ case "/usr/bin/pveversion":
+ pveVersionCalled = true
+ return "pve-manager/8.3.3/bbba1c53a1a65b24", nil
+ default:
+ t.Fatalf("unexpected command %q", name)
+ return "", nil
+ }
+ },
+ }
+
+ agent, err := New(Config{
+ APIToken: "token",
+ LogLevel: zerolog.InfoLevel,
+ Collector: mc,
+ })
+ if err != nil {
+ t.Fatalf("New() error = %v", err)
+ }
+ if agent.osName != proxmoxPVEOSName {
+ t.Fatalf("osName = %q, want %q", agent.osName, proxmoxPVEOSName)
+ }
+ if agent.osVersion != "8.3.3" {
+ t.Fatalf("osVersion = %q, want 8.3.3", agent.osVersion)
+ }
+ if pveVersionCalled {
+ t.Fatal("expected package metadata to avoid slow pveversion fallback")
+ }
+}
+
+func TestNew_UsesLongerProxmoxVEVersionFallbackBudget(t *testing.T) {
+ mc := &mockCollector{
+ hostInfoFn: func(context.Context) (*gohost.InfoStat, error) {
+ return &gohost.InfoStat{
+ Hostname: "pve-host",
+ HostID: "hid",
+ Platform: "raspbian",
+ PlatformFamily: "debian",
+ PlatformVersion: "12.12",
+ KernelVersion: "6.12.47+rpt-rpi-v8",
+ KernelArch: runtime.GOARCH,
+ }, nil
+ },
+ statFn: func(name string) (os.FileInfo, error) {
+ if name == "/etc/pve" {
+ return nil, nil
+ }
+ return nil, os.ErrNotExist
+ },
+ lookPathFn: func(file string) (string, error) {
+ if file == "pveversion" {
+ return "/usr/bin/pveversion", nil
+ }
+ return "", os.ErrNotExist
+ },
+ commandCombinedOutputFn: func(ctx context.Context, name string, arg ...string) (string, error) {
+ if name != "/usr/bin/pveversion" {
+ t.Fatalf("command name = %q, want /usr/bin/pveversion", name)
+ }
+ deadline, ok := ctx.Deadline()
+ if !ok {
+ t.Fatal("expected pveversion context to carry a deadline")
+ }
+ if remaining := time.Until(deadline); remaining < 7*time.Second {
+ t.Fatalf("pveversion timeout remaining = %v, want at least 7s", remaining)
+ }
+ return "pve-manager/8.3.3/bbba1c53a1a65b24 (running kernel: 6.12.47+rpt-rpi-v8)", nil
+ },
+ }
+
+ agent, err := New(Config{
+ APIToken: "token",
+ LogLevel: zerolog.InfoLevel,
+ Collector: mc,
+ })
+ if err != nil {
+ t.Fatalf("New() error = %v", err)
+ }
+ if agent.osVersion != "8.3.3" {
+ t.Fatalf("osVersion = %q, want 8.3.3", agent.osVersion)
+ }
+}
+
func TestNew_DoesNotUseDebianVersionForProxmoxVE(t *testing.T) {
mc := &mockCollector{
hostInfoFn: func(context.Context) (*gohost.InfoStat, error) {
diff --git a/internal/hostagent/os_identity.go b/internal/hostagent/os_identity.go
index 12f86cf715..bae5bce9e6 100644
--- a/internal/hostagent/os_identity.go
+++ b/internal/hostagent/os_identity.go
@@ -11,6 +11,7 @@ var unraidVersionPattern = regexp.MustCompile(`\b\d+(?:\.\d+)+(?:[-+._][A-Za-z0-
var proxmoxPVEVersionPattern = regexp.MustCompile(`(?i)\bpve-manager/([^/\s]+)`)
const proxmoxPVEOSName = "Proxmox VE"
+const proxmoxPVEVersionCommandTimeout = 10 * time.Second
func resolveHostOSIdentity(collector SystemCollector, osName, osVersion string) (string, string) {
currentName := strings.TrimSpace(osName)
@@ -189,17 +190,45 @@ func detectProxmoxVEOSIdentity(collector SystemCollector) (string, string, bool)
}
version := ""
- if pveVersionPath != "" {
- ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
- defer cancel()
+ if packageVersion := detectProxmoxVEPackageVersion(collector); packageVersion != "" {
+ version = packageVersion
+ } else if pveVersionPath != "" {
+ ctx, cancel := context.WithTimeout(context.Background(), proxmoxPVEVersionCommandTimeout)
if output, err := collector.CommandCombinedOutput(ctx, pveVersionPath); err == nil {
version = cleanProxmoxPVEVersion(output)
}
+ cancel()
}
return proxmoxPVEOSName, version, true
}
+func detectProxmoxVEPackageVersion(collector SystemCollector) string {
+ dpkgQueryPath, err := collector.LookPath("dpkg-query")
+ if err != nil || dpkgQueryPath == "" {
+ return ""
+ }
+
+ ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
+ defer cancel()
+ output, err := collector.CommandCombinedOutput(ctx, dpkgQueryPath, "-W", "-f=${Version}", "pve-manager")
+ if err != nil {
+ return ""
+ }
+ return cleanProxmoxPVEPackageVersion(output)
+}
+
+func cleanProxmoxPVEPackageVersion(raw string) string {
+ raw = strings.TrimSpace(raw)
+ if raw == "" {
+ return ""
+ }
+ if strings.ContainsAny(raw, "\r\n\t ") {
+ return ""
+ }
+ return raw
+}
+
func cleanProxmoxPVEVersion(raw string) string {
raw = strings.TrimSpace(raw)
if raw == "" {