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(truenas): make api integration default-on

rcourtmand3d242cc5086
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
index 248be4e200..94ef112abe 100644
--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
@@ -454,6 +454,10 @@ and `useTrueNASSettingsPanelState.ts` must surface the shared runtime health,
poll cadence, discovered contribution summary, and canonical infrastructure /
workloads / storage / recovery handoffs coming from `/api/truenas/connections`
instead of falling back to panel-local inference or agent-first setup guidance.
+When that same platform workspace reports TrueNAS as unavailable, the disabled
+state must mean the server has explicitly opted out of the default-on TrueNAS
+integration, not that operators still need to enable a hidden feature gate for
+normal product use.
That same API-backed platform workspace owner now also includes the shared
presentation helpers `frontend-modern/src/utils/clusterEndpointPresentation.ts`
and `frontend-modern/src/utils/proxmoxSettingsPresentation.ts`, so endpoint
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index 0925ded42e..40e65b7ae3 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -625,6 +625,10 @@ inventing a settings-local shadow fetch path. Zero-value legacy
`pollIntervalSeconds` config must normalize back to the canonical 60-second
default at this same boundary instead of leaking ambiguous `0` values to the
frontend.
+That same `/api/truenas/connections` boundary also owns explicit disabled-path
+semantics: the `truenas_disabled` response exists only when the server has
+explicitly opted out of the default-on TrueNAS integration, not as the normal
+bootstrap state for a supported platform.
That same backend API boundary now also owns the negative space around
assistant control. Wiring native TrueNAS app actions into
`internal/api/router.go`, `internal/api/ai_handler.go`, or adjacent backend
diff --git a/docs/release-control/v6/internal/subsystems/monitoring.md b/docs/release-control/v6/internal/subsystems/monitoring.md
index ee2a9166a6..d1073fab78 100644
--- a/docs/release-control/v6/internal/subsystems/monitoring.md
+++ b/docs/release-control/v6/internal/subsystems/monitoring.md
@@ -233,6 +233,9 @@ TrueNAS connection's `pollIntervalSeconds`, keep the next poll schedule plus
last success/failure state in one canonical runtime owner, and project the most
recent discovered host/pool/dataset/app/disk/recovery counts there instead of
recomputing settings health panel-by-panel.
+That same runtime owner also defines the feature-default contract for TrueNAS:
+the API-backed integration is on by default, and `PULSE_ENABLE_TRUENAS` is an
+explicit opt-out switch rather than a required bootstrap toggle.
That same monitoring boundary now also owns live TrueNAS disk temperatures.
`internal/truenas/client.go` and `internal/truenas/provider.go` must ingest
`disk.temperatures` from the TrueNAS API, fall back to modern
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index 37552f4549..33acb9864d 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -63,6 +63,10 @@ querying, and the operator-facing storage health presentation layer.
2. Add or change recovery page UX through `frontend-modern/src/components/Recovery/` and keep canonical route/query/filter state ownership in `frontend-modern/src/features/recovery/useRecoverySurfaceState.ts`
3. Add or change storage page UX through `frontend-modern/src/pages/Storage.tsx`, `frontend-modern/src/components/Storage/`, `frontend-modern/src/features/storageBackups/`, and the shared storage-source contract in `frontend-modern/src/utils/storageSources.ts`
4. Route transport changes for storage and recovery endpoints through `internal/api/` and the owning `api-contracts` proof routes
+ That same adjacent API boundary also owns TrueNAS feature-default semantics for
+ provider-backed recovery: storage and recovery must treat `truenas_disabled`
+ as an explicit platform opt-out, not as the baseline onboarding state for a
+ supported platform.
5. Route canonical storage/recovery resource selection through `frontend-modern/src/hooks/useUnifiedResources.ts` and the owning `unified-resources` contract
That shared hook now also projects resource `clusterId` through the shared cluster-name helper, so storage and recovery links keep the same cluster-context label as other unified-resource consumers instead of rebuilding a local fallback chain.
6. Preserve API-owned node identity continuity in shared `internal/api/` helpers so storage and recovery transport attachments do not fork by hostname-versus-IP drift across the same runtime.
@@ -1563,6 +1567,10 @@ in the TrueNAS settings workspace. Storage and recovery may consume the
resulting datasets, apps, disks, and recovery artifacts, but they must not
redefine those settings-runtime health semantics or handoff routes inside
storage/recovery-local transport or page contracts.
+That same adjacent platform boundary also owns the feature-default truth for
+TrueNAS: storage and recovery must treat provider-backed TrueNAS recovery as
+available by default and only treat `truenas_disabled` as an explicit platform
+opt-out, not as the baseline onboarding state for a supported platform.
That same shared boundary also owns the line between recovery data and
assistant control. Backend-native TrueNAS app actions may refresh the poller
and recovery ingest after a control event, but storage and recovery surfaces
diff --git a/frontend-modern/src/components/Settings/InfrastructurePlatformConnectionsSummaryCard.tsx b/frontend-modern/src/components/Settings/InfrastructurePlatformConnectionsSummaryCard.tsx
index 75b9a730b8..3fa8ad75b7 100644
--- a/frontend-modern/src/components/Settings/InfrastructurePlatformConnectionsSummaryCard.tsx
+++ b/frontend-modern/src/components/Settings/InfrastructurePlatformConnectionsSummaryCard.tsx
@@ -68,7 +68,7 @@ export const InfrastructurePlatformConnectionsSummaryCard: Component<
<p class="mt-1 text-xs text-muted">
{props.truenasAvailable
? 'API-backed NAS connections'
- : 'Enable the TrueNAS integration to add API-backed NAS systems.'}
+ : 'Explicitly disabled on this Pulse server.'}
</p>
</div>
</div>
diff --git a/frontend-modern/src/components/Settings/TrueNASSettingsPanel.tsx b/frontend-modern/src/components/Settings/TrueNASSettingsPanel.tsx
index 3ff7a518fb..0206648911 100644
--- a/frontend-modern/src/components/Settings/TrueNASSettingsPanel.tsx
+++ b/frontend-modern/src/components/Settings/TrueNASSettingsPanel.tsx
@@ -165,10 +165,14 @@ export const TrueNASSettingsPanel: Component<TrueNASSettingsPanelProps> = (props
title="TrueNAS integration is disabled"
description={
<>
- <p>{state.featureDisabledMessage() || 'TrueNAS integration is not enabled.'}</p>
+ <p>
+ {state.featureDisabledMessage() ||
+ 'TrueNAS integration has been explicitly disabled on this Pulse server.'}
+ </p>
<p class="mt-2">
- Enable <code>PULSE_ENABLE_TRUENAS=true</code> on the Pulse server and restart the
- service before adding TrueNAS connections.
+ Remove <code>PULSE_ENABLE_TRUENAS=false</code> or set it back to{' '}
+ <code>true</code> on the Pulse server, then restart the service before managing
+ TrueNAS connections.
</p>
</>
}
diff --git a/frontend-modern/src/components/Settings/__tests__/InfrastructureOperationsController.test.tsx b/frontend-modern/src/components/Settings/__tests__/InfrastructureOperationsController.test.tsx
index 1263761ba3..178eda1f79 100644
--- a/frontend-modern/src/components/Settings/__tests__/InfrastructureOperationsController.test.tsx
+++ b/frontend-modern/src/components/Settings/__tests__/InfrastructureOperationsController.test.tsx
@@ -196,9 +196,7 @@ describe('InfrastructurePlatformConnectionsSummaryCard', () => {
));
expect(screen.getByText('Disabled')).toBeInTheDocument();
- expect(
- screen.getByText('Enable the TrueNAS integration to add API-backed NAS systems.'),
- ).toBeInTheDocument();
+ expect(screen.getByText('Explicitly disabled on this Pulse server.')).toBeInTheDocument();
});
});
diff --git a/frontend-modern/src/components/Settings/__tests__/TrueNASSettingsPanel.test.tsx b/frontend-modern/src/components/Settings/__tests__/TrueNASSettingsPanel.test.tsx
index dc220b932d..aadd102804 100644
--- a/frontend-modern/src/components/Settings/__tests__/TrueNASSettingsPanel.test.tsx
+++ b/frontend-modern/src/components/Settings/__tests__/TrueNASSettingsPanel.test.tsx
@@ -161,12 +161,17 @@ describe('TrueNASSettingsPanel', () => {
it('shows the feature gate warning when the backend path is disabled', () => {
mockState.featureDisabled.mockReturnValue(true);
- mockState.featureDisabledMessage.mockReturnValue('truenas_disabled');
+ mockState.featureDisabledMessage.mockReturnValue(
+ 'TrueNAS integration has been explicitly disabled',
+ );
renderPanel();
expect(screen.getByText('TrueNAS integration is disabled')).toBeInTheDocument();
- expect(screen.getByText('truenas_disabled')).toBeInTheDocument();
+ expect(
+ screen.getByText('TrueNAS integration has been explicitly disabled'),
+ ).toBeInTheDocument();
+ expect(screen.getByText(/PULSE_ENABLE_TRUENAS=false/)).toBeInTheDocument();
expect(screen.queryByText('TrueNAS connections')).not.toBeInTheDocument();
});
});
diff --git a/frontend-modern/src/components/Settings/__tests__/useTrueNASSettingsPanelState.test.tsx b/frontend-modern/src/components/Settings/__tests__/useTrueNASSettingsPanelState.test.tsx
index abf63358b4..c598cef3f7 100644
--- a/frontend-modern/src/components/Settings/__tests__/useTrueNASSettingsPanelState.test.tsx
+++ b/frontend-modern/src/components/Settings/__tests__/useTrueNASSettingsPanelState.test.tsx
@@ -36,13 +36,15 @@ describe('useTrueNASSettingsPanelState', () => {
it('treats a 404 list response as a feature-disabled integration state', async () => {
vi.mocked(TrueNASAPI.listConnections).mockRejectedValueOnce({
status: 404,
- message: 'truenas_disabled',
+ message: 'TrueNAS integration has been explicitly disabled',
});
const { result } = renderHook(() => useTrueNASSettingsPanelState());
await waitFor(() => expect(result.featureDisabled()).toBe(true));
- expect(result.featureDisabledMessage()).toBe('truenas_disabled');
+ expect(result.featureDisabledMessage()).toBe(
+ 'TrueNAS integration has been explicitly disabled',
+ );
expect(result.connections()).toEqual([]);
});
diff --git a/frontend-modern/src/components/Settings/useTrueNASSettingsPanelState.ts b/frontend-modern/src/components/Settings/useTrueNASSettingsPanelState.ts
index 11417efcfb..c5200834a5 100644
--- a/frontend-modern/src/components/Settings/useTrueNASSettingsPanelState.ts
+++ b/frontend-modern/src/components/Settings/useTrueNASSettingsPanelState.ts
@@ -172,7 +172,9 @@ export function useTrueNASSettingsPanelState() {
} catch (error) {
if (apiErrorStatus(error) === 404) {
setFeatureDisabled(true);
- setFeatureDisabledMessage(getErrorMessage(error, 'TrueNAS integration is not enabled'));
+ setFeatureDisabledMessage(
+ getErrorMessage(error, 'TrueNAS integration has been explicitly disabled'),
+ );
setConnections([]);
return;
}
diff --git a/internal/api/contract_test.go b/internal/api/contract_test.go
index 56a3d0135f..eefea89c18 100644
--- a/internal/api/contract_test.go
+++ b/internal/api/contract_test.go
@@ -84,6 +84,22 @@ func TestContract_WireAIChatDependencies_WiresTrueNASAppActionProvider(t *testin
}
}
+func TestContract_TrueNASConnectionsDisabledMessageIsExplicit(t *testing.T) {
+ setTrueNASFeatureForTest(t, false)
+ handler, _, _ := newTrueNASHandlersForTest(t, nil)
+
+ req := httptest.NewRequest(http.MethodGet, "/api/truenas/connections", nil)
+ rec := httptest.NewRecorder()
+ handler.HandleList(rec, req)
+
+ if rec.Code != http.StatusNotFound {
+ t.Fatalf("expected 404 when TrueNAS integration is disabled, got %d: %s", rec.Code, rec.Body.String())
+ }
+ if !strings.Contains(rec.Body.String(), "explicitly disabled") {
+ t.Fatalf("expected explicit disable message, got %s", rec.Body.String())
+ }
+}
+
func TestContract_SSOTestRejectsMetadataURLWithUserinfo(t *testing.T) {
called := make(chan struct{}, 1)
metadataServer := newIPv4HTTPServer(t, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
diff --git a/internal/api/truenas_handlers.go b/internal/api/truenas_handlers.go
index 5c934f3682..82300cc97b 100644
--- a/internal/api/truenas_handlers.go
+++ b/internal/api/truenas_handlers.go
@@ -320,7 +320,7 @@ func (h *TrueNASHandlers) featureEnabled(w http.ResponseWriter) bool {
if truenas.IsFeatureEnabled() {
return true
}
- writeErrorResponse(w, http.StatusNotFound, "truenas_disabled", "TrueNAS integration is not enabled", nil)
+ writeErrorResponse(w, http.StatusNotFound, "truenas_disabled", "TrueNAS integration has been explicitly disabled", nil)
return false
}
diff --git a/internal/api/truenas_handlers_test.go b/internal/api/truenas_handlers_test.go
index d572bf7e9c..359a050725 100644
--- a/internal/api/truenas_handlers_test.go
+++ b/internal/api/truenas_handlers_test.go
@@ -110,6 +110,9 @@ func TestTrueNASHandlers_HandleAdd_ValidationAndFeatureGate(t *testing.T) {
if rec.Code != http.StatusNotFound {
t.Fatalf("expected 404, got %d: %s", rec.Code, rec.Body.String())
}
+ if !strings.Contains(rec.Body.String(), "explicitly disabled") {
+ t.Fatalf("expected explicit disable message, got %s", rec.Body.String())
+ }
})
}
diff --git a/internal/truenas/contract_test.go b/internal/truenas/contract_test.go
index 9e166a3f45..727138ae10 100644
--- a/internal/truenas/contract_test.go
+++ b/internal/truenas/contract_test.go
@@ -22,6 +22,18 @@ func TestProviderFeatureFlagGatesFixtureRecords(t *testing.T) {
}
}
+func TestFeatureFlagDefaultsTrueNASOnUnlessExplicitlyDisabled(t *testing.T) {
+ if !parseFeatureEnabled("") {
+ t.Fatal("expected empty TrueNAS feature env to default to enabled")
+ }
+ if !parseFeatureEnabled(" ") {
+ t.Fatal("expected blank TrueNAS feature env to default to enabled")
+ }
+ if parseFeatureEnabled("false") {
+ t.Fatal("expected explicit false TrueNAS feature env to disable the integration")
+ }
+}
+
func TestRegistryIngestRecordsTreatsTrueNASAsGenericDataSource(t *testing.T) {
previous := IsFeatureEnabled()
SetFeatureEnabled(true)
diff --git a/internal/truenas/provider.go b/internal/truenas/provider.go
index dc68f70dc8..67fb909398 100644
--- a/internal/truenas/provider.go
+++ b/internal/truenas/provider.go
@@ -16,19 +16,21 @@ import (
)
const (
- // FeatureTrueNAS gates fixture-first TrueNAS ingestion.
+ // FeatureTrueNAS allows explicit opt-out of the default-on TrueNAS API-backed
+ // platform integration.
FeatureTrueNAS = "PULSE_ENABLE_TRUENAS"
)
var featureTrueNASEnabled atomic.Bool
func init() {
- featureTrueNASEnabled.Store(parseBool(os.Getenv(FeatureTrueNAS)))
+ featureTrueNASEnabled.Store(parseFeatureEnabled(os.Getenv(FeatureTrueNAS)))
}
var errNilSnapshot = errors.New("truenas provider fetcher returned nil snapshot")
-// IsFeatureEnabled returns whether fixture-driven TrueNAS ingestion is enabled.
+// IsFeatureEnabled returns whether the TrueNAS API-backed platform integration
+// is enabled.
func IsFeatureEnabled() bool {
return featureTrueNASEnabled.Load()
}
@@ -1560,6 +1562,13 @@ func parentPoolFromDataset(datasetName string) string {
return strings.TrimSpace(parts[0])
}
+func parseFeatureEnabled(raw string) bool {
+ if strings.TrimSpace(raw) == "" {
+ return true
+ }
+ return parseBool(raw)
+}
+
func parseBool(raw string) bool {
switch strings.ToLower(strings.TrimSpace(raw)) {
case "1", "true", "yes", "on":
diff --git a/internal/truenas/provider_additional_test.go b/internal/truenas/provider_additional_test.go
index ad0dc12e84..edb73f0ecf 100644
--- a/internal/truenas/provider_additional_test.go
+++ b/internal/truenas/provider_additional_test.go
@@ -66,6 +66,15 @@ func TestStatusFromSystemAndParseBoolBranches(t *testing.T) {
t.Fatalf("statusFromSystem(unhealthy) = %q, want %q", got, unifiedresources.StatusWarning)
}
+ if !parseFeatureEnabled("") {
+ t.Fatal("expected parseFeatureEnabled to default empty values to true")
+ }
+ if !parseFeatureEnabled(" \t ") {
+ t.Fatal("expected parseFeatureEnabled to default blank values to true")
+ }
+ if parseFeatureEnabled("off") {
+ t.Fatal("expected parseFeatureEnabled to treat explicit off as false")
+ }
if !parseBool(" YeS ") {
t.Fatal("expected parseBool to treat yes as true")
}
diff --git a/tests/integration/tests/21-truenas-settings-platform-connections.spec.ts b/tests/integration/tests/21-truenas-settings-platform-connections.spec.ts
index fe45fe5ee3..bfd567f6e9 100644
--- a/tests/integration/tests/21-truenas-settings-platform-connections.spec.ts
+++ b/tests/integration/tests/21-truenas-settings-platform-connections.spec.ts
@@ -316,4 +316,40 @@ test.describe('TrueNAS platform connections settings', () => {
fs.mkdirSync(path.dirname(OPERATIONS_SCREENSHOT_PATH), { recursive: true });
await page.screenshot({ path: OPERATIONS_SCREENSHOT_PATH, fullPage: true });
});
+
+ test('treats disabled TrueNAS as an explicit opt-out instead of a setup prerequisite', async ({
+ page,
+ }) => {
+ await page.route('**/api/truenas/connections', async (route) => {
+ if (route.request().method() !== 'GET') {
+ await route.continue();
+ return;
+ }
+
+ await route.fulfill({
+ status: 404,
+ contentType: 'application/json',
+ body: JSON.stringify({
+ error: 'truenas_disabled',
+ message: 'TrueNAS integration has been explicitly disabled',
+ }),
+ });
+ });
+
+ await page.goto('/settings/infrastructure/platforms/truenas', {
+ waitUntil: 'domcontentloaded',
+ });
+ await page.waitForURL(/\/settings\/infrastructure\/platforms\/truenas/, {
+ timeout: 15_000,
+ });
+
+ await expect(page.getByText('TrueNAS integration is disabled')).toBeVisible();
+ await expect(
+ page.getByText('TrueNAS integration has been explicitly disabled'),
+ ).toBeVisible();
+ await expect(page.getByText(/PULSE_ENABLE_TRUENAS=false/)).toBeVisible();
+ await expect(page.getByText(/set it back to true/i)).toBeVisible();
+ await expect(page.getByRole('button', { name: 'Add TrueNAS connection' })).not.toBeVisible();
+ await expect(page.locator('[data-testid^=\"truenas-connection-\"]')).toHaveCount(0);
+ });
});