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.

Fail closed hosted refresh for inactive tenants

rcourtman931179cb2930
diff --git a/docs/release-control/v6/internal/subsystems/cloud-paid.md b/docs/release-control/v6/internal/subsystems/cloud-paid.md
index ab4f7c4760..bfe11bd3a0 100644
--- a/docs/release-control/v6/internal/subsystems/cloud-paid.md
+++ b/docs/release-control/v6/internal/subsystems/cloud-paid.md
@@ -206,6 +206,10 @@ runtime gating as separate unlinked claims.
1. Add or change limits through `pkg/licensing/`
2. Add or change hosted entitlement issuance through `internal/cloudcp/entitlements/service.go`
+ Hosted entitlement refresh is scoped to active workspace rows only. A tenant
+ in any non-`active` lifecycle state must return an inactive hosted entitlement
+ result even when the owning account's Stripe subscription is still active, so
+ soft-deleted or suspended workspaces cannot keep refreshing runtime leases.
3. Add or change control-plane plan storage through `internal/cloudcp/registry/models.go` and `internal/cloudcp/registry/registry.go`
4. Add or change MSP account-scoped workspace provisioning entry handlers through `internal/cloudcp/account/tenant_handlers.go`
5. Add or change public cloud self-serve signup price configuration,
diff --git a/internal/cloudcp/entitlements/service.go b/internal/cloudcp/entitlements/service.go
index aba3f32451..b14d65b7da 100644
--- a/internal/cloudcp/entitlements/service.go
+++ b/internal/cloudcp/entitlements/service.go
@@ -164,6 +164,9 @@ func (s *Service) refreshPaidEntitlement(entitlement *registry.HostedEntitlement
if tenant == nil {
return nil, ErrHostedEntitlementNotFound
}
+ if tenant.State != registry.TenantStateActive {
+ return nil, ErrHostedEntitlementInactive
+ }
expectedInstanceHost := tenantInstanceHost(s.baseURL, tenant.ID)
if expectedInstanceHost == "" || instanceHost != expectedInstanceHost {
diff --git a/internal/cloudcp/entitlements/service_test.go b/internal/cloudcp/entitlements/service_test.go
index 7a38405a8d..b1ab4ac13d 100644
--- a/internal/cloudcp/entitlements/service_test.go
+++ b/internal/cloudcp/entitlements/service_test.go
@@ -217,6 +217,51 @@ func TestRefreshPaidEntitlementRejectsTargetMismatch(t *testing.T) {
}
}
+func TestRefreshPaidEntitlementRejectsDeletedTenantWithActiveBilling(t *testing.T) {
+ svc, _, reg := newTestService(t)
+
+ accountID, err := registry.GenerateAccountID()
+ if err != nil {
+ t.Fatalf("GenerateAccountID: %v", err)
+ }
+ if err := reg.CreateAccount(&registry.Account{
+ ID: accountID,
+ Kind: registry.AccountKindIndividual,
+ DisplayName: "Pulse Labs",
+ }); err != nil {
+ t.Fatalf("CreateAccount: %v", err)
+ }
+ if err := reg.CreateStripeAccount(&registry.StripeAccount{
+ AccountID: accountID,
+ StripeCustomerID: "cus_active_deleted_tenant",
+ PlanVersion: "cloud_starter",
+ SubscriptionState: "active",
+ }); err != nil {
+ t.Fatalf("CreateStripeAccount: %v", err)
+ }
+
+ tenant := &registry.Tenant{
+ ID: "t-SERVICE06",
+ AccountID: accountID,
+ Email: "[email protected]",
+ State: registry.TenantStateDeleted,
+ }
+ if err := reg.Create(tenant); err != nil {
+ t.Fatalf("Create: %v", err)
+ }
+ if _, _, err := reg.StoreOrIssueHostedEntitlement(tenant.ID, "etr_deleted_tenant", time.Unix(1710000000, 0).UTC()); err != nil {
+ t.Fatalf("StoreOrIssueHostedEntitlement: %v", err)
+ }
+
+ _, err = svc.RefreshEntitlement("etr_deleted_tenant", "t-service06.cloud.example.com")
+ if err == nil {
+ t.Fatal("expected inactive entitlement")
+ }
+ if err != ErrHostedEntitlementInactive {
+ t.Fatalf("err=%v, want %v", err, ErrHostedEntitlementInactive)
+ }
+}
+
func TestRefreshPaidEntitlementCanonicalizesBaseURLForExpectedHost(t *testing.T) {
svc, pub, reg := newTestServiceWithBaseURL(t, "https://Cloud.Example.com:8443/admin")