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.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Prevent mock license migration warnings
rcourtman2c0899e2086b
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.mdindex 1ab258e2ee..3cb8632de2 100644--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md@@ -1598,6 +1598,11 @@ the intentionally sparse public response.4. Keep shared agent-side TLS identity fail-closed across `cmd/pulse-agent/main.go`, `internal/hostagent/`, `internal/agentupdate/`, `internal/remoteconfig/client.go`, and `internal/agenttls/config.go`. Self-signed deployments may use a canonical pinned Pulse server certificate fingerprint, but lifecycle transport must route that pin through reporting, enrollment, command websocket, remote-config, and self-update clients instead of widening `PULSE_INSECURE_SKIP_VERIFY` into a blanket MITM carve-out. A configured custom CA bundle is part of that same trust boundary: if the bundle is unreadable or invalid, lifecycle transport must refuse the connection path rather than silently downgrading back to system roots.5. Keep release-grade updater trust fail-closed across `internal/agentupdate/`, `internal/dockeragent/`, and the shared `internal/api/unified_agent.go` download helpers. When release builds embed trusted update signing keys, published agent binaries and installer assets must carry detached `.sig` plus `.sshsig` sidecars; updater/runtime paths must require `X-Signature-Ed25519` in addition to `X-Checksum-Sha256`, and installer-owned download flows must require the matching base64-encoded `X-Signature-SSHSIG`, instead of silently downgrading to checksum-only trust.6. Keep shared `internal/api/` helper edits isolated from agent lifecycle semantics: Patrol-specific status transport or alert-trigger wiring changes in shared handlers must not bleed into auto-register, installer, or fleet-control behavior unless this contract moves in the same slice.+ Commercial migration startup behavior in+ `internal/api/licensing_handlers.go` and `internal/api/licensing_bridge.go`+ remains a cloud-paid/API concern. Suppressing synthetic mock-license+ exchange must not change agent enrollment, reporting credentials, install+ commands, update continuity, or fleet-control authority.Audit-log list, filter, pagination, and storage-error contract changes in`internal/api/activity_audit_handlers.go` remain security/API behavior.They must not change agent enrollment, reporting, command transport,diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.mdindex 84fcd4e6e9..e9b8a45655 100644--- a/docs/release-control/v6/internal/subsystems/api-contracts.md+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md@@ -209,6 +209,10 @@ Browser API types and presentation helpers must treat `exchange_stale_key` plus`retrieve_current_key` and `exchange_connectivity_required` plus`allow_license_egress` as explicit migration states rather than inferring themfrom HTTP status alone.+Ordinary non-release mock mode uses isolated synthetic persistence, so startup+must not send a persisted mock JWT to the configured commercial exchange or+publish a stale `commercial_migration` failure from that synthetic key. Explicit+license-panel activation remains the opt-in path for deliberate migration tests.Customer license invalidation is also a shared API/cloud-paid contract.Customer Pulse may call `POST /v1/grants/status` only with its encrypteddiff --git a/docs/release-control/v6/internal/subsystems/cloud-paid.md b/docs/release-control/v6/internal/subsystems/cloud-paid.mdindex 516fdd1950..7880105171 100644--- a/docs/release-control/v6/internal/subsystems/cloud-paid.md+++ b/docs/release-control/v6/internal/subsystems/cloud-paid.md@@ -299,6 +299,11 @@ avoids a cloud-control-plane report data path across clients.pending must self-retry in the background with backoff for the life ofthe process so a transient license-server or DNS failure at first bootnever strands a paying upgrader on Community until a manual restart.+ Ordinary non-release mock mode uses isolated synthetic persistence and must+ neither submit a persisted mock JWT to the configured commercial license+ server nor retain a resulting `commercial_migration` notice across mock+ restarts. Explicit license-panel activation remains available for deliberate+ migration exercises, while non-mock startup migration behavior is unchanged.Signature-valid v5 JWTs that are expired beyond the v5 grace window butcorrespond to a newer retrievable server-side key or live entitlement mustclassify as terminal stale-key recovery (`exchange_stale_key` withdiff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.mdindex 3168e31d4b..c62ddf5419 100644--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md@@ -733,6 +733,11 @@ recovery scope, or a storage/recovery-owned secret source.1. Add or change recovery-point persistence, rollups, or series derivation through `internal/recovery/`4. Route transport changes for storage and recovery endpoints through `internal/api/` and the owning `api-contracts` proof routes+ Commercial migration startup behavior in+ `internal/api/licensing_handlers.go` and `internal/api/licensing_bridge.go`+ remains adjacent cloud-paid/API state. Synthetic mock-license suppression+ must not become a storage entitlement, recovery-readiness signal, backup+ artifact rule, or provider credential path.Report branding validation and reporting request assembly in`internal/api/system_settings.go` and`internal/api/metrics_reporting_handlers.go` remain adjacentdiff --git a/internal/api/contract_test.go b/internal/api/contract_test.goindex 15740a34bb..db2f47c1fe 100644--- a/internal/api/contract_test.go+++ b/internal/api/contract_test.go@@ -8112,6 +8112,30 @@ func TestContract_LegacyMigrationFallbackStaysUncappedJSONSnapshot(t *testing.T)assertJSONSnapshot(t, got, want)}+func TestContract_MockModeCannotMasqueradeAsPaidLegacyMigration(t *testing.T) {+ handlersSource, err := os.ReadFile("licensing_handlers.go")+ if err != nil {+ t.Fatalf("read licensing handlers: %v", err)+ }+ bridgeSource, err := os.ReadFile("licensing_bridge.go")+ if err != nil {+ t.Fatalf("read licensing bridge: %v", err)+ }++ for _, required := range []string{+ "mockFixturesEnabled := isDemoModeFromLicensing()",+ "!mockFixturesEnabled && !isLicenseValidationDevModeFromLicensing()",+ "setCommercialMigrationState(orgID, nil)",+ } {+ if !strings.Contains(string(handlersSource), required) {+ t.Fatalf("licensing startup missing mock migration boundary %q", required)+ }+ }+ if !strings.Contains(string(bridgeSource), "return pkglicensing.IsDemoMode()") {+ t.Fatal("licensing bridge must use the build-tagged demo-mode authority")+ }+}+func TestContract_HostedBillingStateFallbackJSONSnapshot(t *testing.T) {baseDir := t.TempDir()store := config.NewFileBillingStore(baseDir)diff --git a/internal/api/licensing_bridge.go b/internal/api/licensing_bridge.goindex 12d66b4b93..6dd007d6b2 100644--- a/internal/api/licensing_bridge.go+++ b/internal/api/licensing_bridge.go@@ -149,6 +149,10 @@ func isLicenseValidationDevModeFromLicensing() bool {return pkglicensing.IsLicenseValidationDevMode()}+func isDemoModeFromLicensing() bool {+ return pkglicensing.IsDemoMode()+}+func newLicenseEvaluatorForBillingStoreFromLicensing(store billingStoreModel, orgID string, cacheTTL time.Duration, expectedInstanceHost string) *licenseEvaluator {return pkglicensing.NewEvaluator(pkglicensing.NewDatabaseSource(store, orgID, cacheTTL).WithExpectedInstanceHost(expectedInstanceHost),diff --git a/internal/api/licensing_handlers.go b/internal/api/licensing_handlers.goindex 1fc91df680..861595932b 100644--- a/internal/api/licensing_handlers.go+++ b/internal/api/licensing_handlers.go@@ -574,9 +574,21 @@ func (h *LicenseHandlers) getTenantComponents(ctx context.Context) (*licenseServ}}+ // Mock mode uses an isolated synthetic data directory. Old test JWTs can+ // legitimately remain there across dev sessions, but they must never be+ // submitted to the configured commercial license server or surface as a+ // verified paid-license migration failure. Explicit activation from the+ // license panel remains available when a developer wants to exercise it.+ mockFixturesEnabled := isDemoModeFromLicensing()+ if persistence != nil && mockFixturesEnabled && !service.IsActivated() {+ if clearErr := h.setCommercialMigrationState(orgID, nil); clearErr != nil {+ log.Warn().Str("org_id", orgID).Err(clearErr).Msg("Failed to clear stale commercial migration state in mock mode")+ }+ }+// Strict v6 automatically exchanges persisted legacy JWT licenses into the// activation/grant model on startup when no activation state exists yet.- if persistence != nil && !isLicenseValidationDevModeFromLicensing() && !service.IsActivated() {+ if persistence != nil && !mockFixturesEnabled && !isLicenseValidationDevModeFromLicensing() && !service.IsActivated() {legacyJWT, loadErr := persistence.Load()if loadErr != nil {if !os.IsNotExist(loadErr) {diff --git a/internal/api/licensing_handlers_auto_migrate_test.go b/internal/api/licensing_handlers_auto_migrate_test.goindex 8364f70b99..2d7d06ddd0 100644--- a/internal/api/licensing_handlers_auto_migrate_test.go+++ b/internal/api/licensing_handlers_auto_migrate_test.go@@ -162,6 +162,91 @@ func TestGetTenantComponents_AutoExchangesPersistedLegacyJWT(t *testing.T) {handlers.StopAllBackgroundLoops()}+func TestGetTenantComponents_MockModeSkipsPersistedLegacyAutoExchangeAndClearsNotice(t *testing.T) {+ t.Setenv("PULSE_LICENSE_DEV_MODE", "false")+ t.Setenv("PULSE_MOCK_MODE", "true")++ var exchangeCalled atomic.Int32+ server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {+ if r.URL.Path == "/v1/licenses/exchange" {+ exchangeCalled.Add(1)+ }+ w.WriteHeader(http.StatusInternalServerError)+ }))+ defer server.Close()+ t.Setenv("PULSE_LICENSE_SERVER_URL", server.URL)++ baseDir := t.TempDir()+ mtp := config.NewMultiTenantPersistence(baseDir)+ cp, err := mtp.GetPersistence("default")+ if err != nil {+ t.Fatalf("init default persistence: %v", err)+ }++ legacyJWT, err := licensetestsupport.GenerateLicenseForTesting("[email protected]", pkglicensing.TierPro, 24*time.Hour)+ if err != nil {+ t.Fatalf("generate test license: %v", err)+ }+ persistence, err := pkglicensing.NewPersistence(cp.GetConfigDir())+ if err != nil {+ t.Fatalf("new persistence: %v", err)+ }+ if err := persistence.Save(legacyJWT); err != nil {+ t.Fatalf("save legacy JWT: %v", err)+ }++ store := config.NewFileBillingStore(baseDir)+ if err := store.SaveBillingState("default", &pkglicensing.BillingState{+ Capabilities: []string{},+ Limits: map[string]int64{},+ MetersEnabled: []string{},+ PlanVersion: "expired",+ SubscriptionState: pkglicensing.SubStateExpired,+ CommercialMigration: &pkglicensing.CommercialMigrationStatus{+ Source: pkglicensing.CommercialMigrationSourceV5License,+ State: pkglicensing.CommercialMigrationStateFailed,+ Reason: pkglicensing.CommercialMigrationReasonExchangeInvalid,+ RecommendedAction: pkglicensing.CommercialMigrationActionEnterSupportedV5,+ },+ }); err != nil {+ t.Fatalf("save stale commercial migration state: %v", err)+ }++ handlers := NewLicenseHandlers(mtp, false)+ ctx := context.WithValue(context.Background(), OrgIDContextKey, "default")+ svc := handlers.Service(ctx)+ if svc == nil {+ t.Fatal("expected non-nil service")+ }+ if svc.IsActivated() {+ t.Fatal("mock mode must not auto-activate a persisted legacy fixture")+ }+ if exchangeCalled.Load() != 0 {+ t.Fatalf("mock mode sent persisted fixture to license exchange %d times", exchangeCalled.Load())+ }++ persistedLegacy, err := persistence.Load()+ if err != nil {+ t.Fatalf("load preserved mock legacy JWT: %v", err)+ }+ if persistedLegacy != legacyJWT {+ t.Fatal("mock mode must preserve the fixture for explicit migration testing")+ }++ state, err := store.GetBillingState("default")+ if err != nil {+ t.Fatalf("load cleared billing state: %v", err)+ }+ if state == nil {+ t.Fatal("expected billing state to remain present")+ }+ if state.CommercialMigration != nil {+ t.Fatalf("stale mock commercial migration state was not cleared: %+v", state.CommercialMigration)+ }++ handlers.StopAllBackgroundLoops()+}+func TestSetCommercialMigrationState_AutoMigrateEscalatesSustainedTransportFailure(t *testing.T) {baseDir := t.TempDir()mtp := config.NewMultiTenantPersistence(baseDir)diff --git a/pkg/licensing/dev_mode_release_test.go b/pkg/licensing/dev_mode_release_test.gonew file mode 100644index 0000000000..a2ffa21c7a--- /dev/null+++ b/pkg/licensing/dev_mode_release_test.go@@ -0,0 +1,13 @@+//go:build release++package licensing++import "testing"++func TestReleaseBuildIgnoresMockModeForCommercialStartup(t *testing.T) {+ t.Setenv("PULSE_MOCK_MODE", "true")++ if IsDemoMode() {+ t.Fatal("release build must ignore PULSE_MOCK_MODE")+ }+}diff --git a/pkg/licensing/service.go b/pkg/licensing/service.goindex 0594edc64e..1a8b70ecb8 100644--- a/pkg/licensing/service.go+++ b/pkg/licensing/service.go@@ -234,6 +234,12 @@ func IsLicenseValidationDevMode() bool {return isLicenseValidationDevMode()}+// IsDemoMode reports whether synthetic demo fixtures are enabled for this+// build. Release builds always return false even if PULSE_MOCK_MODE is set.+func IsDemoMode() bool {+ return isDemoMode()+}+// ActivateWithKey activates a license using an activation key from the license server.// It creates an installation, receives a relay grant, parses it, and sets the// resulting license as active. The activation state is persisted for background refresh.diff --git a/pkg/licensing/service_activate_test.go b/pkg/licensing/service_activate_test.goindex 5f8a2bd87c..62bfc34089 100644--- a/pkg/licensing/service_activate_test.go+++ b/pkg/licensing/service_activate_test.go@@ -749,6 +749,9 @@ func TestServiceStatus_DevModeMultiTenantBypassDoesNotChangeCustomerFacingStatusfunc TestServiceStatus_MockModeDoesNotAdvertiseSyntheticCapabilities(t *testing.T) {t.Setenv("PULSE_MOCK_MODE", "true")+ if !IsDemoMode() {+ t.Fatal("IsDemoMode()=false, want true in a non-release mock build")+ }svc := NewService()status := svc.Status()