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 LXC filesystem paths native-proof

pulse-triage[bot]8fde82b8a242
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
index f654949d24..ad07738db5 100644
--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
@@ -54,13 +54,22 @@ standby evidence. Enumeration and each device probe have independent bounded
deadlines so one slow disk cannot consume the complete SMART pass, while
command errors retain bounded stderr for compatibility diagnosis.
On a PVE node, the Unified Agent may also report the mounted filesystem
-capacity of running LXCs through the fixed local `pct list` and
-`pct df <vmid>` command set. This collector is automatic when `pct` is
-available, uses one shared deadline plus per-command byte ceilings, caps guest
-and disk counts, never accepts an unvalidated VMID as an argument, and does not
-invoke `pct df` for guests the preceding list reported stopped. The report
-carries VMID and exact container name so monitoring can reject stale migration
-or rename correlations.
+capacity of running LXCs. The collector uses the fixed local `pct list` command
+to admit only node-local running guests, reads each admitted guest's main
+`/etc/pve/lxc/<vmid>.conf` mount declarations, resolves its init PID through
+the fixed `lxc-info -n <vmid> -p` shape, and probes usage through the Linux
+`/proc/<pid>/root` namespace. A configured path that resolves to the same
+device as its parent is not a live mount and must be omitted instead of
+borrowing the parent's capacity. Least-privilege installs that cannot read the
+config, resolve the PID, or traverse `/proc` may fall back to the fixed
+`pct df <vmid>` query for that container only. The complete pass has a bounded
+collection window, every container has an independent deadline, command output
+has byte ceilings, guest and disk counts are capped, unvalidated VMIDs never
+become arguments, and stopped guests are never queried. Linux namespace paths
+remain slash-canonical in every native build so cross-platform verification
+cannot accidentally test only the fallback. The report carries VMID and exact
+container name so monitoring can reject stale migration or rename
+correlations.
`internal/monitoring/monitor.go` also serializes shared unified-resource
websocket payloads. Carrying plural availability facets through that serializer
is an adjacent monitoring/API projection and does not change agent enrollment,
diff --git a/internal/hostagent/agent_metrics_test.go b/internal/hostagent/agent_metrics_test.go
index f63984a8d2..dd895994e3 100644
--- a/internal/hostagent/agent_metrics_test.go
+++ b/internal/hostagent/agent_metrics_test.go
@@ -58,6 +58,12 @@ func TestAgentMetricsSMARTProbeAttemptsRetryExplicitSAT(t *testing.T) {
}
}
+func TestProxmoxLXCConfigPathRemainsLinuxNative(t *testing.T) {
+ if got, want := proxmoxLXCConfigPath(100), "/etc/pve/lxc/100.conf"; got != want {
+ t.Fatalf("proxmoxLXCConfigPath(100) = %q, want %q", got, want)
+ }
+}
+
func TestBuildReport(t *testing.T) {
// Setup mocks
fixedTime := time.Date(2025, 1, 1, 12, 0, 0, 0, time.UTC)
diff --git a/internal/hostagent/proxmox_lxc_filesystems.go b/internal/hostagent/proxmox_lxc_filesystems.go
index bf2b6bcad7..aa3f194881 100644
--- a/internal/hostagent/proxmox_lxc_filesystems.go
+++ b/internal/hostagent/proxmox_lxc_filesystems.go
@@ -219,7 +219,7 @@ func (a *Agent) collectProxmoxLXCContainerDisksFast(
lxcInfoPath string,
vmid int,
) ([]agentshost.Disk, error) {
- raw, err := a.collector.ReadFile(filepath.Join(proxmoxLXCConfigDir, strconv.Itoa(vmid)+".conf"))
+ raw, err := a.collector.ReadFile(proxmoxLXCConfigPath(vmid))
if err != nil {
return nil, fmt.Errorf("read container config: %w", err)
}
@@ -315,6 +315,13 @@ func (a *Agent) collectProxmoxLXCContainerDisksFast(
return result, nil
}
+func proxmoxLXCConfigPath(vmid int) string {
+ // The collector reads the Linux Proxmox namespace even when native tests
+ // exercise this path from another GOOS. filepath.Join would turn this into
+ // a Windows path and silently force the slower pct fallback.
+ return path.Join(proxmoxLXCConfigDir, strconv.Itoa(vmid)+".conf")
+}
+
// parseProxmoxLXCConfigMounts extracts rootfs and mpN entries from the main
// section of a container config. Parsing stops at the first section header so
// snapshot and pending sections can never contribute mounts.