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.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Compose current upstream allocation guard with reviewed maintenance repairs
pulse-triage[bot]49e37dddfcf3
diff --cc internal/api/http_metrics_test.goindex 8a32be88b4,d518d80e29..6fb06bdca9--- a/internal/api/http_metrics_test.go+++ b/internal/api/http_metrics_test.go@@@ -1,7 -1,11 +1,8 @@@package apiimport (+ "os"- "os/exec"- "regexp""strconv"- "strings""testing""time"@@@ -198,20 -202,49 +199,38 @@@ func TestNormalizeSegment(t *testing.T// could copy a short segment into a stack buffer and hide the allocation.var normalizeSegmentSink string+ // allocIsolationEnv names the test that a child process re-runs on its own.+ const allocIsolationEnv = "PULSE_TEST_ALLOC_ISOLATION"+-// measureAllocsInIsolation reports whether the calling test should take its-// testing.AllocsPerRun measurements now. AllocsPerRun diffs the process-wide-// malloc counter, so in a full internal/api run it also counts allocations by-// parallel tests and by goroutines that earlier tests left running; CI once saw-// normalizeRoute("/") report 419 allocations per call that way. In the parent,-// it re-runs only the calling test in a child process of the same test binary,-// where nothing else allocates, fails if the child fails, and returns false.-// In that child, it returns true.++// measureAllocsInIsolation keeps the upstream test entry point while using the++// bounded, measurement-marked child launcher shared with the background-fixture++// control. The child flag and upstream environment marker both select the actual++// measurement; the parent must observe that measurement, not just a passing test.+ func measureAllocsInIsolation(t *testing.T) bool {+ t.Helper()- if os.Getenv(allocIsolationEnv) == t.Name() {++ if *routeAllocationChild || os.Getenv(allocIsolationEnv) == t.Name() {++ t.Cleanup(func() { t.Log("ROUTE_ALLOCATION_MEASURED " + t.Name()) })+ return true+ }- cmd := exec.Command(os.Args[0], "-test.run=^"+regexp.QuoteMeta(t.Name())+"$", "-test.v")- cmd.Env = append(os.Environ(), allocIsolationEnv+"="+t.Name())- out, err := cmd.CombinedOutput()- if err != nil {- t.Fatalf("isolated allocation check failed: %v\n%s", err, out)- }- if !strings.Contains(string(out), "--- PASS: "+t.Name()) {- t.Fatalf("isolated allocation check did not run %s:\n%s", t.Name(), out)- }++ runRouteAllocationTest(t, t.Name())+ return false+ }+func TestNormalizeSegment_DoesNotAllocate(t *testing.T) {- isolatedRouteAllocationCheck(t, func() {- for _, seg := range []string{- "12345",- "550e8400-e29b-41d4-a716-446655440000",- "abcdefghijklmnopqrstuvwxyz1234567890abcdef",- "resources",- "metrics-store",- } {- if allocs := testing.AllocsPerRun(100, func() { normalizeSegmentSink = normalizeSegment(seg) }); allocs != 0 {- t.Errorf("normalizeSegment(%q) allocated %v times per call, want 0", seg, allocs)- }+ if !measureAllocsInIsolation(t) {+ return+ }+ for _, seg := range []string{+ "12345",+ "550e8400-e29b-41d4-a716-446655440000",+ "abcdefghijklmnopqrstuvwxyz1234567890abcdef",+ "resources",+ "metrics-store",+ } {+ if allocs := testing.AllocsPerRun(100, func() { normalizeSegmentSink = normalizeSegment(seg) }); allocs != 0 {+ t.Errorf("normalizeSegment(%q) allocated %v times per call, want 0", seg, allocs)}- })+ }}func TestNormalizeRoute(t *testing.T) {@@@ -270,16 -303,15 +289,17 @@@// The root and empty paths must return before splitting. Without the fast// path, "/" still normalizes to "/" but allocates a split slice on every call.+var normalizeRouteSink string+func TestNormalizeRoute_RootFastPathDoesNotAllocate(t *testing.T) {- isolatedRouteAllocationCheck(t, func() {- for _, path := range []string{"/", ""} {- if allocs := testing.AllocsPerRun(100, func() { normalizeRouteSink = normalizeRoute(path) }); allocs != 0 {- t.Errorf("normalizeRoute(%q) allocated %v times per call, want 0", path, allocs)- }+ if !measureAllocsInIsolation(t) {+ return+ }+ for _, path := range []string{"/", ""} {- if allocs := testing.AllocsPerRun(100, func() { _ = normalizeRoute(path) }); allocs != 0 {++ if allocs := testing.AllocsPerRun(100, func() { normalizeRouteSink = normalizeRoute(path) }); allocs != 0 {+ t.Errorf("normalizeRoute(%q) allocated %v times per call, want 0", path, allocs)}- })+ }}// ---------------------------------------------------------------------------