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.

Hide deleted workspaces from portal APIs

rcourtman2d4da7e08e10
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index 7e860dc323..f60b869ce1 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -887,6 +887,11 @@ path, signup path, and stable workspace summary fields such as `created_at`.
That workspace summary contract must expose explicit health semantics: `healthy`
for passing health checks, `checking` only when no completed health check
exists yet, and `unhealthy` for a failed latest health check.
+That same portal API contract treats `deleting` and `deleted` tenants as
+control-plane history, not visible workspace payloads: the browser bootstrap,
+`/api/portal/dashboard`, and `/api/portal/workspaces/{tenant_id}` must filter
+soft-deleted rows consistently, with detail reads returning `404` for hidden
+workspaces rather than leaking retired runtime records into the account shell.
That same shared `internal/api/` plus `internal/websocket/hub.go` boundary also
owns browser websocket origin continuity for reverse-proxied runtimes. Same-host
browser origins must continue to connect when a reverse proxy preserves the
diff --git a/docs/release-control/v6/internal/subsystems/cloud-paid.md b/docs/release-control/v6/internal/subsystems/cloud-paid.md
index 5838c76cdc..ab4f7c4760 100644
--- a/docs/release-control/v6/internal/subsystems/cloud-paid.md
+++ b/docs/release-control/v6/internal/subsystems/cloud-paid.md
@@ -228,6 +228,11 @@ runtime gating as separate unlinked claims.
`Summary` destination. The top of `Workspaces` may surface one quiet inline
facts line plus one next-action row before the list, but it must not turn
that summary into a second overview deck, metric grid, or competing shell.
+ Portal workspace payloads are live-workspace surfaces, not registry history
+ dumps: tenants in `deleting` or `deleted` state must stay hidden from the
+ browser bootstrap, `/api/portal/dashboard`, and workspace-detail API so
+ soft-deleted runtime cleanup preserves billing/account continuity without
+ presenting retired hosted workspaces as actionable customer state.
Pulse Account self-hosted upgrade and pricing-preview copy must describe
Community as included core monitoring plus paid Relay/Pro extras. It must
not frame self-hosted checkout as buying unlimited monitoring or monitored-
diff --git a/internal/cloudcp/portal/handlers.go b/internal/cloudcp/portal/handlers.go
index 75c09e16e1..950becc9c0 100644
--- a/internal/cloudcp/portal/handlers.go
+++ b/internal/cloudcp/portal/handlers.go
@@ -115,7 +115,7 @@ func HandlePortalDashboard(reg *registry.TenantRegistry) http.HandlerFunc {
}
for _, t := range tenants {
- if t == nil {
+ if !isPortalVisibleTenant(t) {
continue
}
@@ -190,6 +190,10 @@ func HandlePortalWorkspaceDetail(reg *registry.TenantRegistry) http.HandlerFunc
http.Error(w, "tenant not found", http.StatusNotFound)
return
}
+ if !isPortalVisibleTenant(t) {
+ http.Error(w, "tenant not found", http.StatusNotFound)
+ return
+ }
resp := workspaceDetailResponse{
Account: accountInfo{
@@ -206,6 +210,13 @@ func HandlePortalWorkspaceDetail(reg *registry.TenantRegistry) http.HandlerFunc
}
}
+func isPortalVisibleTenant(t *registry.Tenant) bool {
+ if t == nil {
+ return false
+ }
+ return t.State != registry.TenantStateDeleted && t.State != registry.TenantStateDeleting
+}
+
// HandlePortalBootstrap returns the renderer-owned Pulse Account bootstrap payload.
// Route: GET /api/portal/bootstrap
//
diff --git a/internal/cloudcp/portal/handlers_test.go b/internal/cloudcp/portal/handlers_test.go
index 8e12f1746f..0c8055a72f 100644
--- a/internal/cloudcp/portal/handlers_test.go
+++ b/internal/cloudcp/portal/handlers_test.go
@@ -151,6 +151,14 @@ func TestPortalDashboard(t *testing.T) {
if err != nil {
t.Fatal(err)
}
+ tenantDeletedID, err := registry.GenerateTenantID()
+ if err != nil {
+ t.Fatal(err)
+ }
+ tenantDeletingID, err := registry.GenerateTenantID()
+ if err != nil {
+ t.Fatal(err)
+ }
created1 := time.Date(2026, 2, 10, 10, 0, 0, 0, time.UTC)
created2 := time.Date(2026, 2, 10, 11, 0, 0, 0, time.UTC)
@@ -177,6 +185,24 @@ func TestPortalDashboard(t *testing.T) {
}); err != nil {
t.Fatal(err)
}
+ if err := reg.Create(&registry.Tenant{
+ ID: tenantDeletedID,
+ AccountID: accountID,
+ DisplayName: "Deleted Workspace",
+ State: registry.TenantStateDeleted,
+ CreatedAt: created2,
+ }); err != nil {
+ t.Fatal(err)
+ }
+ if err := reg.Create(&registry.Tenant{
+ ID: tenantDeletingID,
+ AccountID: accountID,
+ DisplayName: "Deleting Workspace",
+ State: registry.TenantStateDeleting,
+ CreatedAt: created2,
+ }); err != nil {
+ t.Fatal(err)
+ }
req := httptest.NewRequest(http.MethodGet, "/api/portal/dashboard?account_id="+accountID, nil)
rec := doRequest(t, mux, req)
@@ -379,6 +405,39 @@ func TestPortalWorkspaceDetail(t *testing.T) {
}
}
+func TestPortalWorkspaceDetailHidesDeletedWorkspaces(t *testing.T) {
+ reg := newTestRegistry(t)
+ mux := newTestMux(reg)
+
+ accountID, err := registry.GenerateAccountID()
+ if err != nil {
+ t.Fatal(err)
+ }
+ if err := reg.CreateAccount(&registry.Account{ID: accountID, Kind: registry.AccountKindMSP, DisplayName: "Example MSP"}); err != nil {
+ t.Fatal(err)
+ }
+
+ tenantID, err := registry.GenerateTenantID()
+ if err != nil {
+ t.Fatal(err)
+ }
+ if err := reg.Create(&registry.Tenant{
+ ID: tenantID,
+ AccountID: accountID,
+ DisplayName: "Deleted Workspace",
+ State: registry.TenantStateDeleted,
+ CreatedAt: time.Date(2026, 2, 10, 10, 0, 0, 0, time.UTC),
+ }); err != nil {
+ t.Fatal(err)
+ }
+
+ req := httptest.NewRequest(http.MethodGet, "/api/portal/workspaces/"+tenantID+"?account_id="+accountID, nil)
+ rec := doRequest(t, mux, req)
+ if rec.Code != http.StatusNotFound {
+ t.Fatalf("status = %d, want %d (body=%q)", rec.Code, http.StatusNotFound, rec.Body.String())
+ }
+}
+
// --- Billing portal redirect tests ---
func newBillingHandler(t *testing.T, reg *registry.TenantRegistry, apiKey string, returnURL string,
diff --git a/internal/cloudcp/portal/page.go b/internal/cloudcp/portal/page.go
index e546bb6a49..6dcd337901 100644
--- a/internal/cloudcp/portal/page.go
+++ b/internal/cloudcp/portal/page.go
@@ -166,10 +166,7 @@ func loadPortalAccountsForUser(reg *registry.TenantRegistry, userID string) ([]p
workspaces := make([]portalPageWorkspace, 0, len(tenants))
for _, t := range tenants {
- if t == nil {
- continue
- }
- if t.State == registry.TenantStateDeleted || t.State == registry.TenantStateDeleting {
+ if !isPortalVisibleTenant(t) {
continue
}
workspaces = append(workspaces, portalPageWorkspace{