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.

Fix tenant monitor broadcast nil hub panic

rcourtman1a3e5ec27d7d
diff --git a/docs/release-control/v6/internal/records/documentation-currentness-and-legacy-cleanup-v6-rc4-packet-2026-05-05.md b/docs/release-control/v6/internal/records/documentation-currentness-and-legacy-cleanup-v6-rc4-packet-2026-05-05.md
index 1447b25b73..3cf5f65757 100644
--- a/docs/release-control/v6/internal/records/documentation-currentness-and-legacy-cleanup-v6-rc4-packet-2026-05-05.md
+++ b/docs/release-control/v6/internal/records/documentation-currentness-and-legacy-cleanup-v6-rc4-packet-2026-05-05.md
@@ -124,6 +124,13 @@ canonical root contract: self-hosted v6 plans preserve paid continuity without
monitored-system volume caps, and `max_monitored_systems` remains only as
legacy metadata to scrub.
+The second draft release workflow exposed one more backend release-validation
+blocker before publication: tenant monitor startup can run in headless test
+contexts without a WebSocket hub, but the state broadcast helper only checked a
+plain nil interface and still dereferenced a typed nil `*websocket.Hub`. The
+monitor broadcast contract now treats typed nil broadcasters as absent, and the
+regression proof covers the tenant-scoped broadcast path.
+
No public issue comment, retitle, closure, or customer-facing message was made
as part of this packet update.
@@ -139,4 +146,9 @@ as part of this packet update.
- `prepare`, `frontend_checks`, `helm_smoke`, and `docker_build` passed
- `backend_tests` failed on stale RC3 Docker defaults and stale retired
monitored-system cap expectations
+- Draft release workflow `25384246365`:
+ - `prepare`, `frontend_checks`, `helm_smoke`, and `docker_build` passed
+ - `backend_tests` failed on a tenant monitor typed-nil WebSocket hub panic in
+ `internal/api`
- `go test -race ./internal/config ./tests/migration ./scripts/installtests`
+- `go test -race ./internal/monitoring ./internal/api`
diff --git a/docs/release-control/v6/internal/subsystems/deployment-installability.md b/docs/release-control/v6/internal/subsystems/deployment-installability.md
index d1d6047965..dbe6a1002e 100644
--- a/docs/release-control/v6/internal/subsystems/deployment-installability.md
+++ b/docs/release-control/v6/internal/subsystems/deployment-installability.md
@@ -189,9 +189,10 @@ server-side update execution surfaces.
are one of those release-risk themes and must be named in the current RC
packet before the release workflow is restarted.
Release-validation proof corrections that unblock an RC draft, including
- backend CI proof fixes that do not change runtime behavior, must still be
- named in the audit record and reflected in the candidate commit hash,
- commit count, and changed-scope summary before the workflow is restarted.
+ backend CI proof fixes that do not change runtime behavior and runtime
+ guard fixes discovered by the release workflow itself, must still be named
+ in the audit record and reflected in the candidate commit hash, commit
+ count, and changed-scope summary before the workflow is restarted.
The prerelease feedback intake template and active demo/update metadata must
also stay on generic or current-RC wording instead of hard-coding stale
`rc.1` examples once later candidates exist.
diff --git a/docs/release-control/v6/internal/subsystems/monitoring.md b/docs/release-control/v6/internal/subsystems/monitoring.md
index 7889e9d1df..cdce494ae6 100644
--- a/docs/release-control/v6/internal/subsystems/monitoring.md
+++ b/docs/release-control/v6/internal/subsystems/monitoring.md
@@ -217,6 +217,11 @@ publish those resources from the same canonical unified snapshot that
raw store-only inventory for broadcast. Otherwise cold hydrate and later
registry-backed refreshes can swap the operator-visible infrastructure set
under one running session.
+That websocket publication boundary must also treat an absent hub as an absent
+broadcast channel in both direct nil and typed-nil forms. Tenant-scoped
+background monitors can start in headless test or maintenance runtimes before a
+hub is wired, and state publication must no-op safely instead of dereferencing
+a nil `*websocket.Hub` during ticker refresh.
That same Docker/Podman monitoring boundary now also owns Docker
authorization-plugin posture. `internal/dockeragent/collect.go` must project
`system.Info().Plugins.Authorization` into the canonical agent report,
diff --git a/docs/releases/RELEASE_NOTES_v6_RC4_DRAFT.md b/docs/releases/RELEASE_NOTES_v6_RC4_DRAFT.md
index d4f03f11ee..5ab7818ab4 100644
--- a/docs/releases/RELEASE_NOTES_v6_RC4_DRAFT.md
+++ b/docs/releases/RELEASE_NOTES_v6_RC4_DRAFT.md
@@ -30,7 +30,9 @@ exact `rc.3` to `rc.4` candidate range, from the published `v6.0.0-rc.3` tag com
`3f16d7845a92d6bf0c5700728bd70e1f4fe32966`. The final prerelease target also
includes RC4 packet and release-validation commits that set the governed
version, pin Docker install defaults to `6.0.0-rc.4`, and align migration tests
-with the canonical self-hosted licensing contract.
+with the canonical self-hosted licensing contract. The final validation slice
+also makes tenant monitor state broadcasts no-op safely when a headless or test
+runtime has no WebSocket hub wired.
## Support Stance
@@ -91,6 +93,8 @@ with the canonical self-hosted licensing contract.
correct alert attribution.
- Metrics rollup writes are less noisy after duplicate or repeated rollup
opportunities.
+- Tenant monitor state broadcasts now tolerate runtimes without a WebSocket hub
+ instead of panicking during background state refresh.
### Product Surface And Operator Guidance
diff --git a/docs/releases/V6_CHANGELOG_RC4_DRAFT.md b/docs/releases/V6_CHANGELOG_RC4_DRAFT.md
index 01476930ed..3ee6dcd7de 100644
--- a/docs/releases/V6_CHANGELOG_RC4_DRAFT.md
+++ b/docs/releases/V6_CHANGELOG_RC4_DRAFT.md
@@ -38,7 +38,8 @@ setup hardening, TrueNAS/RAID/Ceph/storage correctness, Workloads empty-state
handling, Patrol mobile controls, mock-mode cleanup, and release-control
evidence. The final RC4 prerelease target also includes packet and
release-validation commits that pin Docker install defaults to `6.0.0-rc.4` and
-remove stale migration-test expectations for retired monitored-system caps.
+remove stale migration-test expectations for retired monitored-system caps, plus
+a tenant monitor broadcast guard for runtimes without a WebSocket hub.
## Major Changes
@@ -115,6 +116,7 @@ The range also includes:
- Ceph pool threshold resource identity preservation
- Workloads empty-state source detection
- mock-mode legacy sidecar cleanup
+- tenant monitor state broadcasts no-op safely when no WebSocket hub is wired
### 6. Patrol and docs are aligned with the current RC
diff --git a/internal/monitoring/canonical_guardrails_test.go b/internal/monitoring/canonical_guardrails_test.go
index da7ccc4092..5a46cc21b8 100644
--- a/internal/monitoring/canonical_guardrails_test.go
+++ b/internal/monitoring/canonical_guardrails_test.go
@@ -126,6 +126,26 @@ func TestGetStateRefreshesLiveAlertSnapshots(t *testing.T) {
}
}
+func TestStateBroadcastTreatsTypedNilHubAsAbsent(t *testing.T) {
+ data, err := os.ReadFile("monitor.go")
+ if err != nil {
+ t.Fatalf("failed to read monitor.go: %v", err)
+ }
+ source := string(data)
+
+ for _, snippet := range []string{
+ "func isNilStateBroadcaster(hub stateBroadcaster) bool {",
+ "if isNilStateBroadcaster(hub) {",
+ "value := reflect.ValueOf(hub)",
+ "case reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, reflect.Ptr, reflect.Slice:",
+ "return value.IsNil()",
+ } {
+ if !strings.Contains(source, snippet) {
+ t.Fatalf("monitor.go must contain %q", snippet)
+ }
+ }
+}
+
func TestMetricsStoreRuntimeOverridesStayOnMonitorBoundary(t *testing.T) {
data, err := os.ReadFile("monitor.go")
if err != nil {
diff --git a/internal/monitoring/monitor.go b/internal/monitoring/monitor.go
index 4520ade190..2d42444808 100644
--- a/internal/monitoring/monitor.go
+++ b/internal/monitoring/monitor.go
@@ -9,6 +9,7 @@ import (
"math/rand"
"os"
"path/filepath"
+ "reflect"
"sort"
"strings"
"sync"
@@ -3762,7 +3763,7 @@ type stateBroadcaster interface {
// Monitors with an explicit org ID (including "default") are tenant-scoped.
// Legacy monitors without an org ID broadcast globally.
func (m *Monitor) broadcastState(hub stateBroadcaster, frontendState interface{}) {
- if hub == nil {
+ if isNilStateBroadcaster(hub) {
return
}
@@ -3774,6 +3775,20 @@ func (m *Monitor) broadcastState(hub stateBroadcaster, frontendState interface{}
}
}
+func isNilStateBroadcaster(hub stateBroadcaster) bool {
+ if hub == nil {
+ return true
+ }
+
+ value := reflect.ValueOf(hub)
+ switch value.Kind() {
+ case reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, reflect.Ptr, reflect.Slice:
+ return value.IsNil()
+ default:
+ return false
+ }
+}
+
func (m *Monitor) broadcastEscalatedAlert(hub *websocket.Hub, alert *alerts.Alert) {
if hub == nil || alert == nil {
return
diff --git a/internal/monitoring/monitor_broadcast_tenant_test.go b/internal/monitoring/monitor_broadcast_tenant_test.go
index 1e9f2b7211..07dcf946ca 100644
--- a/internal/monitoring/monitor_broadcast_tenant_test.go
+++ b/internal/monitoring/monitor_broadcast_tenant_test.go
@@ -1,6 +1,10 @@
package monitoring
-import "testing"
+import (
+ "testing"
+
+ "github.com/rcourtman/pulse-go-rewrite/internal/websocket"
+)
type fakeStateBroadcaster struct {
globalBroadcasts int
@@ -44,6 +48,14 @@ func TestMonitorBroadcastStateUsesGlobalChannelForLegacyMonitor(t *testing.T) {
}
}
+func TestMonitorBroadcastStateIgnoresTypedNilHub(t *testing.T) {
+ m := &Monitor{}
+ m.SetOrgID("default")
+
+ var hub *websocket.Hub
+ m.broadcastState(hub, map[string]string{"kind": "state"})
+}
+
func TestMonitorSetOrgIDTrimsWhitespace(t *testing.T) {
m := &Monitor{}
m.SetOrgID(" org-a ")
diff --git a/scripts/release_control/render_release_body_test.py b/scripts/release_control/render_release_body_test.py
index f08b7f0624..c4591d13eb 100644
--- a/scripts/release_control/render_release_body_test.py
+++ b/scripts/release_control/render_release_body_test.py
@@ -155,6 +155,8 @@ Old metadata section.
self.assertIn("pin Docker install defaults to `6.0.0-rc.4`", changelog)
self.assertIn("Docker Compose and turnkey Docker installer defaults", release_notes)
self.assertIn("release-validation commits", changelog)
+ self.assertIn("Tenant monitor state broadcasts", release_notes)
+ self.assertIn("tenant monitor broadcast guard", changelog)
if __name__ == "__main__":