mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-11-29 17:21:13 +01:00
Extend the #1962 linked-agent memory fallback to Proxmox LXC containers (#2148). A correlated online Pulse agent running inside a container now supplies the container's memory metric instead of the cache-inclusive cluster/resources fallback, which can badly under-report shared-memory workloads. The agent sample is only trusted when its total matches the container's configured limit, so an agent without lxcfs cannot leak host memory into the guest row. Threads the previous-guest agent map through the efficient and node-by-node container builders and reads agent-owned memory from merged ContainerView resources. Change-source: pulse-maintainer
70 lines
1.4 KiB
Go
70 lines
1.4 KiB
Go
package monitoring
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/rcourtman/pulse-go-rewrite/pkg/proxmox"
|
|
)
|
|
|
|
func TestBuildVMFromClusterResource_PreservesProxmoxPool(t *testing.T) {
|
|
monitor := &Monitor{rateTracker: NewRateTracker()}
|
|
|
|
vm, _, _, _, _, ok := monitor.buildVMFromClusterResource(
|
|
context.Background(),
|
|
"cluster-a",
|
|
proxmox.ClusterResource{
|
|
Type: "qemu",
|
|
Node: "pve-a",
|
|
Pool: "prod-vms",
|
|
Name: "app-vm",
|
|
Status: "stopped",
|
|
VMID: 101,
|
|
MaxCPU: 4,
|
|
MaxMem: 8192,
|
|
MaxDisk: 1024,
|
|
Template: 0,
|
|
},
|
|
nil,
|
|
"",
|
|
nil,
|
|
nil,
|
|
)
|
|
if !ok {
|
|
t.Fatal("expected VM to be built")
|
|
}
|
|
if vm.Pool != "prod-vms" {
|
|
t.Fatalf("expected VM pool %q, got %+v", "prod-vms", vm)
|
|
}
|
|
}
|
|
|
|
func TestBuildContainerFromClusterResource_PreservesProxmoxPool(t *testing.T) {
|
|
monitor := &Monitor{rateTracker: NewRateTracker()}
|
|
|
|
container, _, _, _, ok := monitor.buildContainerFromClusterResource(
|
|
context.Background(),
|
|
"cluster-a",
|
|
proxmox.ClusterResource{
|
|
Type: "lxc",
|
|
Node: "pve-a",
|
|
Pool: "ops-lxc",
|
|
Name: "cache-ct",
|
|
Status: "stopped",
|
|
VMID: 202,
|
|
MaxCPU: 2,
|
|
MaxMem: 4096,
|
|
MaxDisk: 2048,
|
|
Template: 0,
|
|
},
|
|
nil,
|
|
map[int]bool{},
|
|
nil,
|
|
)
|
|
if !ok {
|
|
t.Fatal("expected container to be built")
|
|
}
|
|
if container.Pool != "ops-lxc" {
|
|
t.Fatalf("expected container pool %q, got %+v", "ops-lxc", container)
|
|
}
|
|
}
|