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.

Observe tenant runtime completion before the successful deletion check

pulse-triage[bot]560f691b0380
diff --git a/internal/monitoring/alert_checks_shutdown_test.go b/internal/monitoring/alert_checks_shutdown_test.go
index 78076bf74d..96fb51569b 100644
--- a/internal/monitoring/alert_checks_shutdown_test.go
+++ b/internal/monitoring/alert_checks_shutdown_test.go
@@ -76,6 +76,21 @@ func blockFirstShutdownAlert(t *testing.T, monitor *Monitor) (<-chan struct{}, f
return entered, unblock
}
+func awaitTenantRuntimeShutdown(t *testing.T, manager *MultiTenantMonitor, orgID string) {
+ t.Helper()
+ manager.mu.RLock()
+ done := manager.tenantDone[orgID]
+ manager.mu.RUnlock()
+ if done == nil {
+ t.Fatal("tenant has no owned runtime completion signal")
+ }
+ select {
+ case <-done:
+ case <-time.After(5 * time.Second):
+ t.Fatal("tenant runtime did not join its released writer")
+ }
+}
+
func TestMonitorStartJoinsMockAlertChecksBeforeReturning(t *testing.T) {
configureAlertShutdownFixture(t)
monitor, err := New(&config.Config{DataPath: t.TempDir()})
@@ -213,6 +228,10 @@ func TestTenantDeletionRetainsBlockedAlertPassThenRemovesCompletedRuntime(t *tes
t.Fatalf("blocked runtime lost its organization data: %v", err)
}
unblock()
+ // Releasing the callback is not completion of the remaining alert pass,
+ // sampler or Start. Observe the owned runtime signal, not a second race
+ // against the deliberately short refusal budget (especially under -race).
+ awaitTenantRuntimeShutdown(t, manager, "alert-owner")
if err := manager.BeginTenantDeletion("alert-owner"); err != nil {
t.Fatalf("completed alert pass prevented safe removal: %v", err)
}
diff --git a/internal/monitoring/alert_projection_shutdown_test.go b/internal/monitoring/alert_projection_shutdown_test.go
index 5119db70dd..e12a90900b 100644
--- a/internal/monitoring/alert_projection_shutdown_test.go
+++ b/internal/monitoring/alert_projection_shutdown_test.go
@@ -315,6 +315,7 @@ func TestTenantDeletionRetainsBlockedAlertProjectionThenRemovesCompletedRuntime(
_, err = os.Stat(filepath.Join(orgPath, "org.json"))
require.NoError(t, err, "blocked writer must retain organization bytes")
unblock()
+ awaitTenantRuntimeShutdown(t, manager, "history-owner")
require.NoError(t, manager.BeginTenantDeletion("history-owner"))
require.NoError(t, persistence.DeleteOrganization("history-owner"))
manager.FinishTenantDeletion("history-owner")