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.

Scrub stale monitored-system caps on self-hosted uncapped tiers

rcourtman943389827f98
diff --git a/pkg/licensing/activation_types_test.go b/pkg/licensing/activation_types_test.go
index dfdb014288..8699ded957 100644
--- a/pkg/licensing/activation_types_test.go
+++ b/pkg/licensing/activation_types_test.go
@@ -195,11 +195,13 @@ func TestGrantClaimsToClaimsWithContinuityAppliesGrandfatherFloor(t *testing.T)
GrandfatheredMonitoredSystemsCapturedAt: time.Now().Unix(),
})
+ // The raw MaxMonitoredSystems field still records the continuity floor, but
+ // self-hosted Pro is uncapped, so EffectiveLimits must not surface a cap.
if claims.MaxMonitoredSystems != 23 {
t.Fatalf("MaxMonitoredSystems = %d, want 23", claims.MaxMonitoredSystems)
}
- if got := claims.EffectiveLimits()[MaxMonitoredSystemsLicenseGateKey]; got != 23 {
- t.Fatalf("EffectiveLimits()[max_monitored_systems] = %d, want 23", got)
+ if got, ok := claims.EffectiveLimits()[MaxMonitoredSystemsLicenseGateKey]; ok {
+ t.Fatalf("EffectiveLimits()[max_monitored_systems] = %d present, want absent (uncapped self-hosted)", got)
}
}
@@ -219,11 +221,13 @@ func TestGrantClaimsToClaimsWithContinuityDoesNotLowerGrantLimit(t *testing.T) {
GrandfatheredMonitoredSystemsCapturedAt: time.Now().Unix(),
})
+ // Floor of 10 is below grant's 15, so the raw field is left at 15. Either
+ // way, self-hosted Pro is uncapped so EffectiveLimits does not surface a cap.
if claims.MaxMonitoredSystems != 15 {
t.Fatalf("MaxMonitoredSystems = %d, want 15", claims.MaxMonitoredSystems)
}
- if got := claims.EffectiveLimits()[MaxMonitoredSystemsLicenseGateKey]; got != 15 {
- t.Fatalf("EffectiveLimits()[max_monitored_systems] = %d, want 15", got)
+ if got, ok := claims.EffectiveLimits()[MaxMonitoredSystemsLicenseGateKey]; ok {
+ t.Fatalf("EffectiveLimits()[max_monitored_systems] = %d present, want absent (uncapped self-hosted)", got)
}
}
diff --git a/pkg/licensing/grant_refresh_test.go b/pkg/licensing/grant_refresh_test.go
index fef02aaa39..ce3335d3a8 100644
--- a/pkg/licensing/grant_refresh_test.go
+++ b/pkg/licensing/grant_refresh_test.go
@@ -536,8 +536,10 @@ func TestRefreshGrantOnce_PreservesLegacyGrandfatherFloor(t *testing.T) {
}
status := svc.Status()
- if status.MaxMonitoredSystems != 23 {
- t.Fatalf("status.MaxMonitoredSystems=%d, want 23", status.MaxMonitoredSystems)
+ // Self-hosted Pro is uncapped, so status reports 0 regardless of the
+ // captured continuity floor. The floor is still persisted for audit.
+ if status.MaxMonitoredSystems != 0 {
+ t.Fatalf("status.MaxMonitoredSystems=%d, want 0 (uncapped self-hosted)", status.MaxMonitoredSystems)
}
loaded, err := p.LoadActivationState()
diff --git a/pkg/licensing/models.go b/pkg/licensing/models.go
index e982d60cce..7b6dd30b11 100644
--- a/pkg/licensing/models.go
+++ b/pkg/licensing/models.go
@@ -68,6 +68,20 @@ func (c Claims) EffectiveCapabilities() []string {
return DeriveCapabilitiesFromTier(c.Tier, c.Features)
}
+// isSelfHostedUncappedTier reports whether a tier is a self-hosted tier that
+// must remain uncapped for core monitoring regardless of any persisted limit.
+// Cloud and MSP tiers resolve their limits from plan version, so they are
+// excluded. Enterprise is excluded because its claims carry explicit per-deal
+// limits that must be honored.
+func isSelfHostedUncappedTier(tier Tier) bool {
+ switch tier {
+ case TierFree, TierRelay, TierPro, TierProPlus, TierProAnnual, TierLifetime:
+ return true
+ default:
+ return false
+ }
+}
+
// EffectiveLimits returns explicit limits when present; otherwise limits derived from legacy fields.
func (c Claims) EffectiveLimits() map[string]int64 {
limits := NormalizeMonitoredSystemLimits(c.Limits)
@@ -80,10 +94,12 @@ func (c Claims) EffectiveLimits() map[string]int64 {
limits["max_guests"] = int64(c.MaxGuests)
}
}
- if c.Tier == TierLifetime || IsGrandfatheredRecurringV5PlanVersion(c.PlanVersion) {
- // Grandfathered lifetime licenses and active recurring v5 migrations
- // must remain uncapped even if older tokens or migrated records still
- // carry historical Pro-era limits.
+ if isSelfHostedUncappedTier(c.Tier) || IsGrandfatheredRecurringV5PlanVersion(c.PlanVersion) {
+ // Self-hosted tiers are uncapped for core monitoring, and grandfathered
+ // recurring v5 migrations must remain uncapped too. Older tokens or
+ // migrated activation records may still carry historical per-tier limits
+ // (e.g. a v5-migrated Community install persisted max_monitored_systems=1);
+ // scrub them so the current tier policy wins.
delete(limits, MaxMonitoredSystemsLicenseGateKey)
delete(limits, "max_guests")
}
diff --git a/pkg/licensing/models_test.go b/pkg/licensing/models_test.go
index 3d34fc9f17..0564bb99b0 100644
--- a/pkg/licensing/models_test.go
+++ b/pkg/licensing/models_test.go
@@ -117,6 +117,53 @@ func TestClaims_EffectiveLimits(t *testing.T) {
},
expected: map[string]int64{},
},
+ {
+ name: "free_strips_legacy_v5_cap_after_upgrade",
+ claims: Claims{
+ Tier: TierFree,
+ Limits: map[string]int64{"max_monitored_systems": 1, "max_guests": 5},
+ MaxMonitoredSystems: 1,
+ MaxGuests: 5,
+ },
+ expected: map[string]int64{},
+ },
+ {
+ name: "relay_strips_legacy_cap",
+ claims: Claims{
+ Tier: TierRelay,
+ Limits: map[string]int64{"max_monitored_systems": 8},
+ MaxMonitoredSystems: 8,
+ },
+ expected: map[string]int64{},
+ },
+ {
+ name: "pro_strips_legacy_cap",
+ claims: Claims{
+ Tier: TierPro,
+ Limits: map[string]int64{"max_monitored_systems": 15, "max_guests": 100},
+ MaxMonitoredSystems: 15,
+ MaxGuests: 100,
+ },
+ expected: map[string]int64{},
+ },
+ {
+ name: "pro_plus_strips_legacy_cap",
+ claims: Claims{
+ Tier: TierProPlus,
+ Limits: map[string]int64{"max_monitored_systems": 50},
+ MaxMonitoredSystems: 50,
+ },
+ expected: map[string]int64{},
+ },
+ {
+ name: "pro_annual_strips_legacy_cap",
+ claims: Claims{
+ Tier: TierProAnnual,
+ Limits: map[string]int64{"max_monitored_systems": 15},
+ MaxMonitoredSystems: 15,
+ },
+ expected: map[string]int64{},
+ },
}
for _, tt := range tests {
diff --git a/pkg/licensing/service.go b/pkg/licensing/service.go
index f320b9924d..b52b10f579 100644
--- a/pkg/licensing/service.go
+++ b/pkg/licensing/service.go
@@ -551,11 +551,11 @@ func (s *Service) monitoredSystemContinuityStatusLocked() *MonitoredSystemContin
effectiveLimit := planLimit
if s.license != nil {
+ // When a license is present, trust its claims. Self-hosted uncapped
+ // tiers return 0 here as a first-class "unlimited" signal, not a
+ // missing-data sentinel — do not fall back to the grant's plan limit.
effectiveLimit = monitoredSystemLimitFromClaims(s.license.Claims)
}
- if effectiveLimit <= 0 {
- effectiveLimit = planLimit
- }
status := &MonitoredSystemContinuityStatus{
PlanLimit: planLimit,
diff --git a/pkg/licensing/service_activate_test.go b/pkg/licensing/service_activate_test.go
index 5b4fcbe62c..caa7b4ea1e 100644
--- a/pkg/licensing/service_activate_test.go
+++ b/pkg/licensing/service_activate_test.go
@@ -431,16 +431,16 @@ func TestServiceCaptureLegacyMonitoredSystemGrandfatherFloorPersistsAndUpdatesSt
}
status := svc.Status()
- if status.MaxMonitoredSystems != 23 {
- t.Fatalf("status.MaxMonitoredSystems=%d, want 23", status.MaxMonitoredSystems)
+ if status.MaxMonitoredSystems != 0 {
+ t.Fatalf("status.MaxMonitoredSystems=%d, want 0 (uncapped self-hosted)", status.MaxMonitoredSystems)
}
current := svc.Current()
if current == nil {
t.Fatal("expected current license")
}
- if got := current.Claims.EffectiveLimits()[MaxMonitoredSystemsLicenseGateKey]; got != 23 {
- t.Fatalf("EffectiveLimits()[max_monitored_systems]=%d, want 23", got)
+ if got, ok := current.Claims.EffectiveLimits()[MaxMonitoredSystemsLicenseGateKey]; ok {
+ t.Fatalf("EffectiveLimits()[max_monitored_systems]=%d present, want absent (uncapped self-hosted)", got)
}
loaded, err := p.LoadActivationState()
@@ -486,10 +486,10 @@ func TestServiceStatus_ExposesMonitoredSystemContinuityForFallbackMigrations(t *
LegacyMigration: true,
},
wantPlanLimit: 10,
- wantEffectiveLimit: 10,
+ wantEffectiveLimit: 0,
wantFloor: 0,
wantCapturePending: true,
- wantMaxSystems: 10,
+ wantMaxSystems: 0,
},
{
name: "captured floor",
@@ -499,10 +499,10 @@ func TestServiceStatus_ExposesMonitoredSystemContinuityForFallbackMigrations(t *
GrandfatheredMonitoredSystemsCapturedAt: 123,
},
wantPlanLimit: 10,
- wantEffectiveLimit: 23,
+ wantEffectiveLimit: 0,
wantFloor: 23,
wantCapturePending: false,
- wantMaxSystems: 23,
+ wantMaxSystems: 0,
},
}