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.

Merge origin/pulse/v6-release and fix reconciled API regressions

rcourtman893d003c0a2f
diff --cc docs/release-control/v6/internal/PULSE_ACCOUNT_PORTAL_SPEC.md
index f6b19a3a41,2baccf0350..7f9fc22942
--- a/docs/release-control/v6/internal/PULSE_ACCOUNT_PORTAL_SPEC.md
+++ b/docs/release-control/v6/internal/PULSE_ACCOUNT_PORTAL_SPEC.md
@@@ -82,11 -82,23 +82,24 @@@ One user may belong to multiple account
workspaces and multiple self-hosted licenses. MSP is therefore an account kind
with stronger workspace-management needs, not a completely separate portal.
+ Portal authentication must follow that same commercial identity model. `Pulse
+ Account` sign-in cannot be limited to hosted-tenant members only; the portal
+ magic-link path must accept both:
+
+ 1. hosted Cloud/MSP identities that already resolve through the control-plane
+ tenant/account registry
+ 2. self-hosted commercial identities that resolve through the shared
+ license/commercial account surface even when they have no hosted tenant
+
+ When the portal explicitly requests a portal-target magic link, the resulting
+ verification flow must create a control-plane session and return the user to
+ `/portal` rather than forcing a tenant handoff redirect.
+
## Canonical Information Architecture
-The future Pulse account surface should be one shell with product-aware areas,
-not separate portals for each commercial motion.
+The future Pulse account surface should be one shell with task-first areas, not
+separate portals for each commercial motion or section names derived from
+Pulse's internal product model.
Primary areas:
diff --cc docs/release-control/v6/internal/subsystems/api-contracts.md
index 65079aaf65,6e6538aabf..68fd7f12b5
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@@ -251,15 -215,12 +251,21 @@@ account identity context, signed-out ve
summaries, and renderer-owned public, commercial, and control-plane route
configuration, including the canonical bootstrap route path, magic-link request
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 shared `internal/api/` boundary also owns trusted-proxy websocket
+origin continuity for hosted runtimes. When a hosted tenant is opened through
+the cloud proxy, the runtime must derive the effective same-origin
+`https://<tenant-host>` boundary from trusted forwarded host/proto headers
+only after the hosted container contract has injected explicit proxy CIDRs, so
+live updates stay connected without weakening cross-site websocket checks.
+ Commercial self-service actions in that shell must stay same-origin as well:
+ the frontend may only call the portal-owned `/api/portal/commercial/*` routes,
+ and `internal/cloudcp/portal/commercial_proxy.go` plus `internal/cloudcp/routes.go`
+ own the server-side proxy boundary to the shared license/commercial APIs so
+ the browser runtime does not widen control-plane CSP with direct cross-origin
+ commercial fetches.
`/portal` is now one bootstrap-driven shell for both anonymous and
authenticated users, so new account frontend work must extend that shared
contract rather than inventing a second local payload shape, reviving separate
diff --cc docs/release-control/v6/internal/subsystems/cloud-paid.md
index 01f462379b,ce5298a5ca..95e48ac043
--- a/docs/release-control/v6/internal/subsystems/cloud-paid.md
+++ b/docs/release-control/v6/internal/subsystems/cloud-paid.md
@@@ -272,10 -256,17 +272,18 @@@ The trial-start rate-limit contract is
`/api/license/trial/start` retries are allowed as a short human-scale burst so
operators can revisit the hosted handoff without getting locked out for a day,
and both the local app server and hosted trial signup limiters must return the
-actual remaining backoff through `Retry-After` rather than a coarse full-window
-guess. Shared trial-start presentation must treat that backoff as canonical and
+actual remaining backoff through `Retry-After` and
+`details.retry_after_seconds` rather than a coarse full-window guess. Shared
+trial-start presentation must treat that backoff as canonical and surface it
+consistently instead of flattening every `429` into generic copy.
+ Hosted tenant organization seeding and hosted handoff role mapping now belong
+ to the same cloud-paid truth too. `internal/cloudcp/stripe/provisioner.go`
+ must seed tenant org members from the shared account-role-to-organization-role
+ mapping, and hosted handoff/runtime consumers must preserve that same mapping
+ when older workspaces need membership continuity repaired at open time. Cloud,
+ MSP, and commercial account roles therefore have one canonical translation into
+ tenant org permissions instead of drifting between provisioning-time seeds and
+ handoff-time access repair.
-surface it consistently instead of flattening every `429` into generic copy.
For the hosted self-serve flow, that also means the public trial pages and form
posts must render the owned Pulse trial experience with preserved instance/form
state when rate limited, rather than dropping users onto a generic control-plane
diff --cc docs/release-control/v6/internal/subsystems/performance-and-scalability.md
index f21029a8d4,29e0f07212..e76cd5b9b7
--- a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
+++ b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
@@@ -204,12 -206,6 +204,16 @@@ and `frontend-modern/src/components/Das
filters, stats, and table visibility driven by the workload route's own
REST-backed health so websocket churn does not hide already-fetched workloads
or swap the protected hot path into a false disconnected shell.
+The same performance ownership now applies to the downsampled
+`pkg/metrics/store.go` batched query path. `QueryAllBatch` may drop the global
+SQLite `ORDER BY resource_id, metric_type, bucket_ts` sort from the grouped
- query only if the runtime preserves ascending timestamps within every returned
- resource/metric series and the hot-path proof keeps both latency and ordering
- guarded together in the explicit metrics SLO surface.
++query only if the runtime preserves ascending timestamps plus correct
++avg/min/max bucket aggregates within every returned resource/metric series, and
++the hot-path proof keeps latency, ordering, and aggregate correctness guarded
++together in the explicit metrics SLO surface. That protected surface should
++stay on one ordered index scan plus Go-side bucket aggregation rather than
++forcing SQLite to `GROUP BY` computed buckets through a temp B-tree on the
++fleet-scale dashboard path.
That runtime is now intentionally split by concern:
`frontend-modern/src/components/Dashboard/useDashboardState.ts` owns
top-level dashboard orchestration, workload loading, and composition across
diff --cc internal/api/api_foundation_test.go
index a9ebbccf83,a9ebbccf83..445d30cebf
--- a/internal/api/api_foundation_test.go
+++ b/internal/api/api_foundation_test.go
@@@ -83,6 -83,6 +83,21 @@@ func TestTenantMiddleware_FullChain(t *
}
}
++func TestSetMultiTenantEnabled_SyncsDevModeFeatureGate(t *testing.T) {
++ t.Setenv("PULSE_DEV", "true")
++ defer SetMultiTenantEnabled(false)
++
++ SetMultiTenantEnabled(false)
++ if newLicenseService().HasFeature(featureMultiTenantKey) {
++ t.Fatalf("expected dev-mode service to deny %q when helper disables multi-tenant", featureMultiTenantKey)
++ }
++
++ SetMultiTenantEnabled(true)
++ if !newLicenseService().HasFeature(featureMultiTenantKey) {
++ t.Fatalf("expected dev-mode service to allow %q when helper enables multi-tenant", featureMultiTenantKey)
++ }
++}
++
func TestRequireMultiTenant_Middleware(t *testing.T) {
defer SetMultiTenantEnabled(false)
diff --cc internal/api/middleware_license.go
index 9aaafd1638,9aaafd1638..2bbee59bfb
--- a/internal/api/middleware_license.go
+++ b/internal/api/middleware_license.go
@@@ -93,8 -93,8 +93,15 @@@ func NewMultiTenantChecker(hostedMode b
}
// SetMultiTenantEnabled allows programmatic control of the feature flag (for testing).
++// It also keeps the env-backed dev-mode entitlement path aligned so tests exercise
++// the same multi-tenant state through both middleware and license-service checks.
func SetMultiTenantEnabled(enabled bool) {
multiTenantEnabled = enabled
++ if enabled {
++ _ = os.Setenv("PULSE_MULTI_TENANT_ENABLED", "true")
++ return
++ }
++ _ = os.Unsetenv("PULSE_MULTI_TENANT_ENABLED")
}
// LicenseServiceProvider provides license service for a given context.
diff --cc internal/api/router.go
index 6c57f24353,55d60efa70..dbfcd2f03a
--- a/internal/api/router.go
+++ b/internal/api/router.go
@@@ -7545,13 -7536,13 +7559,41 @@@ func (r *Router) handleMetricsHistory(
}
return apiPoints
}
-- mockModeEnabled := mock.IsMockEnabled()
-- vms := monitor.VMsSnapshot()
-- containers := monitor.ContainersSnapshot()
-- nodes := monitor.NodesSnapshot()
-- storagePools := monitor.StorageSnapshot()
-- dockerHosts := monitor.DockerHostsSnapshot()
-- hosts := monitor.HostsSnapshot()
++ // Most requests are served from the metrics store. Keep the fallback/read-state
++ // snapshots lazy so store-backed history does not pay an O(fleet-size) copy cost.
++ var (
++ fallbackStateOnce sync.Once
++ vms []models.VM
++ containers []models.Container
++ nodes []models.Node
++ storagePools []models.Storage
++ dockerHosts []models.DockerHost
++ hosts []models.Host
++
++ diskFallbackOnce sync.Once
++ physicalDisks []unifiedresources.Resource
++ )
++
++ loadFallbackState := func() {
++ fallbackStateOnce.Do(func() {
++ vms = monitor.VMsSnapshot()
++ containers = monitor.ContainersSnapshot()
++ nodes = monitor.NodesSnapshot()
++ storagePools = monitor.StorageSnapshot()
++ dockerHosts = monitor.DockerHostsSnapshot()
++ hosts = monitor.HostsSnapshot()
++ })
++ }
++
++ loadPhysicalDisks := func() {
++ diskFallbackOnce.Do(func() {
++ for _, resource := range monitor.GetUnifiedResources() {
++ if resource.Type == unifiedresources.ResourceTypePhysicalDisk && resource.PhysicalDisk != nil {
++ physicalDisks = append(physicalDisks, resource)
++ }
++ }
++ })
++ }
parseGuestID := func(id string) (string, string, int, bool) {
parts := strings.Split(id, ":")
@@@ -7566,6 -7557,6 +7608,7 @@@
}
findVM := func(id string) *models.VM {
++ loadFallbackState()
for i := range vms {
if vms[i].ID == id {
return &vms[i]
@@@ -7583,6 -7574,6 +7626,7 @@@
}
findContainer := func(id string) *models.Container {
++ loadFallbackState()
for i := range containers {
if containers[i].ID == id {
return &containers[i]
@@@ -7600,6 -7591,6 +7644,7 @@@
}
findNode := func(id string) *models.Node {
++ loadFallbackState()
for i := range nodes {
if nodes[i].ID == id {
return &nodes[i]
@@@ -7609,6 -7600,6 +7654,7 @@@
}
findStorage := func(id string) *models.Storage {
++ loadFallbackState()
for i := range storagePools {
if storagePools[i].ID == id {
return &storagePools[i]
@@@ -7618,6 -7609,6 +7664,7 @@@
}
findDockerHost := func(id string) *models.DockerHost {
++ loadFallbackState()
for i := range dockerHosts {
if dockerHosts[i].ID == id {
return &dockerHosts[i]
@@@ -7627,6 -7618,6 +7674,7 @@@
}
findHost := func(id string) *models.Host {
++ loadFallbackState()
for i := range hosts {
if hosts[i].ID == id {
return &hosts[i]
@@@ -7636,6 -7627,6 +7684,7 @@@
}
findDockerContainer := func(id string) *models.DockerContainer {
++ loadFallbackState()
for i := range dockerHosts {
host := &dockerHosts[i]
for j := range host.Containers {
@@@ -7647,14 -7638,14 +7696,8 @@@
return nil
}
-- physicalDisks := make([]unifiedresources.Resource, 0)
-- for _, resource := range monitor.GetUnifiedResources() {
-- if resource.Type == unifiedresources.ResourceTypePhysicalDisk && resource.PhysicalDisk != nil {
-- physicalDisks = append(physicalDisks, resource)
-- }
-- }
--
findDisk := func(id string) *unifiedresources.Resource {
++ loadPhysicalDisks()
target := strings.TrimSpace(id)
if target == "" {
return nil
@@@ -7829,7 -7820,7 +7872,7 @@@
return nil, "", false
}
-- if mockModeEnabled && runtimeResourceType == "disk" && metricType == "smart_temp" {
++ if mock.IsMockEnabled() && runtimeResourceType == "disk" && metricType == "smart_temp" {
if disk := findDisk(resourceID); disk != nil && disk.PhysicalDisk != nil && disk.PhysicalDisk.Temperature > 0 {
series := buildSyntheticMetricHistorySeries(
end,
@@@ -8103,7 -8094,7 +8146,7 @@@
}
}
-- if response == nil && mockModeEnabled && runtimeResourceType == "disk" && metricType == "smart_temp" {
++ if response == nil && mock.IsMockEnabled() && runtimeResourceType == "disk" && metricType == "smart_temp" {
targetPoints := targetMockSeriesPoints(duration, historyMaxPoints)
if len(points) > 0 && len(points) < targetPoints {
current := points[len(points)-1].Value
diff --cc internal/cloudcp/portal/bootstrap.go
index ee72ae34bc,898d8674cf..7076f4b34b
--- a/internal/cloudcp/portal/bootstrap.go
+++ b/internal/cloudcp/portal/bootstrap.go
@@@ -28,20 -26,19 +28,21 @@@ type BootstrapAccount struct
}
type BootstrapData struct {
- Authenticated bool `json:"authenticated"`
- Email string `json:"email"`
- PublicSiteURL string `json:"public_site_url"`
- SupportEmail string `json:"support_email"`
- CommercialAPIBasePath string `json:"commercial_api_base_path"`
- PortalPath string `json:"portal_path"`
- BootstrapPath string `json:"bootstrap_path"`
- MagicLinkRequestPath string `json:"magic_link_request_path"`
- SignupPath string `json:"signup_path"`
- LogoutPath string `json:"logout_path"`
- AccountAPIBasePath string `json:"account_api_base_path"`
- PortalAPIBasePath string `json:"portal_api_base_path"`
- Accounts []BootstrapAccount `json:"accounts"`
+ Authenticated bool `json:"authenticated"`
+ Email string `json:"email"`
+ HasSelfHostedCommercial bool `json:"has_self_hosted_commercial"`
+ PublicSiteURL string `json:"public_site_url"`
+ SupportEmail string `json:"support_email"`
+ CommercialAPIBaseURL string `json:"commercial_api_base_url"`
++ CommercialAPIBasePath string `json:"commercial_api_base_path"`
+ PortalPath string `json:"portal_path"`
+ BootstrapPath string `json:"bootstrap_path"`
+ MagicLinkRequestPath string `json:"magic_link_request_path"`
+ SignupPath string `json:"signup_path"`
+ LogoutPath string `json:"logout_path"`
+ AccountAPIBasePath string `json:"account_api_base_path"`
+ PortalAPIBasePath string `json:"portal_api_base_path"`
+ Accounts []BootstrapAccount `json:"accounts"`
}
func MarshalBootstrapJSON(data BootstrapData) (template.JS, error) {
@@@ -84,20 -75,19 +85,21 @@@ func BuildBootstrapData(authenticated b
}
return BootstrapData{
- Authenticated: authenticated,
- Email: email,
- PublicSiteURL: defaultPublicSiteURL,
- SupportEmail: defaultSupportEmail,
- CommercialAPIBasePath: PortalCommercialAPIBasePath,
- PortalPath: defaultPortalPath,
- BootstrapPath: PortalBootstrapPath,
- MagicLinkRequestPath: PortalMagicLinkRequestPath,
- SignupPath: PortalSignupPath,
- LogoutPath: defaultLogoutPath,
- AccountAPIBasePath: defaultAccountAPIBasePath,
- PortalAPIBasePath: defaultPortalAPIBasePath,
- Accounts: bootstrapAccounts,
+ Authenticated: authenticated,
+ Email: email,
+ HasSelfHostedCommercial: hasSelfHostedCommercial,
+ PublicSiteURL: defaultPublicSiteURL,
+ SupportEmail: defaultSupportEmail,
+ CommercialAPIBaseURL: defaultCommercialAPIBaseURL,
++ CommercialAPIBasePath: PortalCommercialAPIBasePath,
+ PortalPath: defaultPortalPath,
+ BootstrapPath: PortalBootstrapPath,
+ MagicLinkRequestPath: PortalMagicLinkRequestPath,
+ SignupPath: PortalSignupPath,
+ LogoutPath: defaultLogoutPath,
+ AccountAPIBasePath: defaultAccountAPIBasePath,
+ PortalAPIBasePath: defaultPortalAPIBasePath,
+ Accounts: bootstrapAccounts,
}
}
diff --cc internal/cloudcp/portal/handlers_test.go
index 4eb307bcf8,f09ea51658..ebe6824624
--- a/internal/cloudcp/portal/handlers_test.go
+++ b/internal/cloudcp/portal/handlers_test.go
@@@ -1152,72 -1190,3 +1152,75 @@@ func TestBillingPortalRedirect_NoReturn
t.Fatalf("ReturnURL = %q, want nil (no return URL configured)", stripe.StringValue(capturedParams.ReturnURL))
}
}
+
+func TestCommercialProxy_Success(t *testing.T) {
+ upstream := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ if r.Method != http.MethodPost {
+ t.Fatalf("method = %s, want POST", r.Method)
+ }
+ if r.URL.Path != "/v1/manage/request" {
+ t.Fatalf("path = %q", r.URL.Path)
+ }
+ if got := r.Header.Get("Content-Type"); got != "application/json" {
+ t.Fatalf("content-type = %q", got)
+ }
+ var payload map[string]any
+ if err := json.NewDecoder(r.Body).Decode(&payload); err != nil {
+ t.Fatalf("decode request: %v", err)
+ }
+ if got := payload["email"]; got != "[email protected]" {
+ t.Fatalf("email = %#v", got)
+ }
+ w.Header().Set("Content-Type", "application/json")
+ w.WriteHeader(http.StatusOK)
+ _, _ = w.Write([]byte(`{"ok":true}`))
+ }))
+ defer upstream.Close()
+
+ rec := httptest.NewRecorder()
+ req := httptest.NewRequest(http.MethodPost, PortalCommercialProxyPath+"v1/manage/request", strings.NewReader(`{"email":"[email protected]"}`))
+ req.Header.Set("Content-Type", "application/json")
++ req.SetPathValue("commercial_path", "v1/manage/request")
+
+ HandleCommercialProxy(CommercialProxyConfig{BaseURL: upstream.URL})(rec, req)
+
+ if rec.Code != http.StatusOK {
+ t.Fatalf("status = %d, want %d (body=%q)", rec.Code, http.StatusOK, rec.Body.String())
+ }
+ if got := strings.TrimSpace(rec.Body.String()); got != `{"ok":true}` {
+ t.Fatalf("body = %q", got)
+ }
+}
+
+func TestCommercialProxy_RejectsUnsupportedRoute(t *testing.T) {
+ rec := httptest.NewRecorder()
+ req := httptest.NewRequest(http.MethodPost, PortalCommercialProxyPath+"v1/not-allowed", strings.NewReader(`{}`))
++ req.SetPathValue("commercial_path", "v1/not-allowed")
+
+ HandleCommercialProxy(CommercialProxyConfig{BaseURL: "https://license.pulserelay.pro"})(rec, req)
+
+ if rec.Code != http.StatusNotFound {
+ t.Fatalf("status = %d, want %d", rec.Code, http.StatusNotFound)
+ }
+}
+
+func TestCommercialProxy_UpstreamFailureReturnsBadGateway(t *testing.T) {
+ upstream := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ w.WriteHeader(http.StatusBadGateway)
+ _, _ = w.Write([]byte(`{"error":"upstream unavailable"}`))
+ }))
+ defer upstream.Close()
+
+ rec := httptest.NewRecorder()
+ req := httptest.NewRequest(http.MethodPost, PortalCommercialProxyPath+"v1/manage/request", strings.NewReader(`{"email":"[email protected]"}`))
++ req.SetPathValue("commercial_path", "v1/manage/request")
+
+ HandleCommercialProxy(CommercialProxyConfig{BaseURL: upstream.URL})(rec, req)
+
+ if rec.Code != http.StatusBadGateway {
+ t.Fatalf("status = %d, want %d", rec.Code, http.StatusBadGateway)
+ }
+ if got := strings.TrimSpace(rec.Body.String()); got != `{"error":"upstream unavailable"}` {
+ t.Fatalf("body = %q", got)
+ }
+}
diff --cc internal/cloudcp/portal/page.go
index ebf7147bec,b80016dda0..f9316adffc
--- a/internal/cloudcp/portal/page.go
+++ b/internal/cloudcp/portal/page.go
@@@ -44,13 -42,12 +44,13 @@@ type portalPageData struct
}
const (
- defaultPublicSiteURL = "https://pulserelay.pro"
- defaultSupportEmail = "[email protected]"
- defaultPortalPath = PortalPagePath
- defaultLogoutPath = PortalLogoutPath
- defaultAccountAPIBasePath = PortalAccountAPIBasePath
- defaultPortalAPIBasePath = PortalAPIBasePath
+ defaultPublicSiteURL = "https://pulserelay.pro"
+ defaultSupportEmail = "[email protected]"
- defaultCommercialAPIBaseURL = "/api/portal/commercial"
++ defaultCommercialAPIBaseURL = PortalCommercialAPIBasePath
+ defaultPortalPath = PortalPagePath
+ defaultLogoutPath = PortalLogoutPath
+ defaultAccountAPIBasePath = PortalAccountAPIBasePath
+ defaultPortalAPIBasePath = PortalAPIBasePath
)
var errPortalAuthRequired = errors.New("portal auth required")
diff --cc internal/cloudcp/portal/paths.go
index f21d9e9f27,903aba1efa..497fc67536
--- a/internal/cloudcp/portal/paths.go
+++ b/internal/cloudcp/portal/paths.go
@@@ -1,15 -1,16 +1,17 @@@
package portal
const (
- PortalPagePath = "/portal"
- PortalBootstrapPath = "/api/portal/bootstrap"
- PortalDashboardPath = "/api/portal/dashboard"
- PortalWorkspacePath = "/api/portal/workspaces/{tenant_id}"
- PortalBillingPath = "/api/portal/billing"
- PortalCommercialProxyPath = "/api/portal/commercial/"
- PortalLogoutPath = "/auth/logout"
- PortalMagicLinkRequestPath = "/api/public/magic-link/request"
- PortalSignupPath = "/signup"
- PortalAccountAPIBasePath = "/api/accounts"
- PortalAPIBasePath = "/api/portal"
+ PortalPagePath = "/portal"
+ PortalBootstrapPath = "/api/portal/bootstrap"
+ PortalDashboardPath = "/api/portal/dashboard"
+ PortalWorkspacePath = "/api/portal/workspaces/{tenant_id}"
+ PortalBillingPath = "/api/portal/billing"
+ PortalCommercialAPIBasePath = "/api/portal/commercial"
+ PortalCommercialAPIPath = "/api/portal/commercial/{commercial_path...}"
++ PortalCommercialProxyPath = PortalCommercialAPIBasePath + "/"
+ PortalLogoutPath = "/auth/logout"
+ PortalMagicLinkRequestPath = "/api/public/magic-link/request"
+ PortalSignupPath = "/signup"
+ PortalAccountAPIBasePath = "/api/accounts"
+ PortalAPIBasePath = "/api/portal"
)