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.

Guard snapshot concurrency through executable collection proof

pulse-triage[bot]4bba27e0cbfe
diff --git a/internal/monitoring/canonical_guardrails_test.go b/internal/monitoring/canonical_guardrails_test.go
index be52e1a229..3176a447f4 100644
--- a/internal/monitoring/canonical_guardrails_test.go
+++ b/internal/monitoring/canonical_guardrails_test.go
@@ -442,23 +442,9 @@ func TestPBSBackupsSnapshotPreservesSourceArtifactFields(t *testing.T) {
}
func TestGuestSnapshotPollingStaysBoundedConcurrent(t *testing.T) {
- data, err := os.ReadFile("monitor_backups.go")
- if err != nil {
- t.Fatalf("failed to read monitor_backups.go: %v", err)
- }
- source := string(data)
-
- for _, snippet := range []string{
- "maxConcurrentGuestSnapshotPolls = 8",
- "targets := make([]guestSnapshotPollTarget, 0, activeGuests)",
- "results := make(chan guestSnapshotPollResult, len(targets))",
- "sem := make(chan struct{}, maxConcurrentGuestSnapshotPolls)",
- "polledGuestKeys[result.target.key] = struct{}{}",
- } {
- if !strings.Contains(source, snippet) {
- t.Fatalf("monitor_backups.go must contain %q", snippet)
- }
- }
+ // Guard real concurrency, waiting work and complete membership, rather
+ // than requiring a semaphore that still spawns a goroutine per guest.
+ testSnapshotPollWorkersBoundWaitingAndActiveWork(t)
}
func TestGetStateRefreshesLiveAlertSnapshots(t *testing.T) {
diff --git a/internal/monitoring/snapshot_poll_workers_test.go b/internal/monitoring/snapshot_poll_workers_test.go
index c69e82f5b2..42d24f8f5b 100644
--- a/internal/monitoring/snapshot_poll_workers_test.go
+++ b/internal/monitoring/snapshot_poll_workers_test.go
@@ -78,7 +78,7 @@ func snapshotCollectorGoroutines(t *testing.T) int {
return count
}
-func TestSnapshotPollWorkersBoundWaitingAndActiveWork(t *testing.T) {
+func testSnapshotPollWorkersBoundWaitingAndActiveWork(t *testing.T) {
for _, count := range []int{0, 1, 8, 9, 512} {
t.Run(fmt.Sprint(count), func(t *testing.T) {
synctest.Test(t, func(t *testing.T) {
@@ -123,12 +123,12 @@ func TestSnapshotPollWorkersBoundWaitingAndActiveWork(t *testing.T) {
require.Len(t, rows, count+1, "fresh target listings plus untouched peer")
for _, row := range rows {
if row.Instance == "peer" {
- require.Equal(t, "independent", row.Name)
+ require.Equal(t, models.GuestSnapshot{ID: "peer-prior", Instance: "peer", Node: "node", VMID: 1000, Type: "qemu", Name: "independent", Time: time.Unix(1690000000, 0)}, row)
continue
}
- require.Equal(t, "fresh", row.Name)
- require.Equal(t, time.Unix(1700000100, 0), row.Time)
- require.Equal(t, "accepted", row.Description)
+ kind := previous[fmt.Sprintf("%s/%d", row.Type, row.VMID)].Type
+ require.NotEmpty(t, kind, "snapshot belongs to an eligible typed guest")
+ require.Equal(t, models.GuestSnapshot{ID: fmt.Sprintf("site-node-%d-fresh", row.VMID), Instance: "site", Node: "node", VMID: row.VMID, Type: kind, Name: "fresh", Time: time.Unix(1700000100, 0), Description: "accepted", VMState: kind == "qemu"}, row)
}
})
})