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.

v6(settings): phase 8 — per-surface Monitor* scope for TrueNAS and VMware

rcourtman406b966b8622
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
index 696849b94c..caaf13e08a 100644
--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
@@ -361,6 +361,17 @@ an add-only capacity posture.
last error) rather than the legacy `InfrastructureActiveRowDetails`
surface-breakdown drawer; the active-row drawer is no longer mounted
by the workspace for unified rows.
+ The TrueNAS and VMware credential slots carry per-surface Monitor*
+ scope the same way the PVE/PBS/PMG credential slot already does:
+ `TrueNASSettingsPanelState`/`VMwareSettingsPanelState` read and
+ write positive `MonitorDatasets`/`MonitorPools`/`MonitorReplication`
+ (TrueNAS) and `MonitorVMs`/`MonitorHosts`/`MonitorDatastores`
+ (VMware) booleans, and the credential slot renders a
+ "Collection scope" checkbox cluster backed by those fields. The
+ unified aggregator must project those flags into the connection
+ row's `scope` map and keep `capabilities.supportsScope: true` for
+ TrueNAS/VMware — reintroducing the per-type Stop-this-surface
+ dialog or hard-coding scope to a fixed all-true map is forbidden.
## Forbidden Paths
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index e77df66d26..c2c476a0ab 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -22,7 +22,6 @@
Own canonical runtime payload shapes between backend and frontend.
## Canonical Files
-
1. `internal/api/contract_test.go`
2. `internal/api/resources.go`
3. `internal/api/alerts.go`
@@ -84,6 +83,7 @@ Own canonical runtime payload shapes between backend and frontend.
59. `internal/api/connections_handlers.go`
60. `internal/api/connections_probe.go`
61. `frontend-modern/src/api/connections.ts`
+62. `frontend-modern/src/api/hostedSignup.ts`
## Shared Boundaries
@@ -1193,6 +1193,23 @@ preserve the canonical top-level `code` plus string-valued `details.error` and
`frontend-modern/src/utils/apiClient.ts` plus
`frontend-modern/src/api/responseUtils.ts` must carry that metadata through the
shared error object without inventing a VMware-only fetch or parsing path.
+That same TrueNAS and VMware platform-connections contract now also owns
+per-surface scope as a first-class field on the connection shape. The
+TrueNAS connection payload must carry positive `monitorDatasets`,
+`monitorPools`, and `monitorReplication` booleans; the VMware connection
+payload must carry positive `monitorVms`, `monitorHosts`, and
+`monitorDatastores` booleans. `internal/config/truenas.go` and
+`internal/config/vmware.go` must default those fields to true on new
+instances and migrate legacy all-false records to all-true inside
+`ApplyDefaults`, so existing `truenas.json` and `vmware.json` on disk
+continue monitoring every surface after upgrade. The unified
+`/api/connections` aggregator in `internal/api/connections_aggregator.go`
+must project those booleans into the connection row's `scope` map and
+declare `capabilities.supportsScope: true` for TrueNAS and VMware rather
+than hard-coding an all-true scope; `frontend-modern/src/api/truenas.ts`
+and `frontend-modern/src/api/vmware.ts` must round-trip the booleans
+through their `normalize*Connection` and `serialize*ConnectionInput`
+helpers without dropping them on edit-save.
That same VMware API boundary now also owns the phase-1 runtime negative
space around inventory projection. `internal/api/router.go` may wire VMware's
supplemental ingest into the shared `/api/resources` surface so canonical
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index 9ce6857894..56d18703dd 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -201,7 +201,7 @@ querying, and the operator-facing storage health presentation layer.
adjacent pages may react to the message, but they must not reinterpret it
as a storage install prerequisite, provider-connection error, or
recovery-capability verdict.
-21. Keep provider-backed recovery onboarding on the adjacent platform-connections contract. When `internal/api/` grows or changes TrueNAS connection CRUD, masked-secret preservation, saved-connection retest routes, edit-form saved-test payload overlays, or similar provider setup flows, storage and recovery may consume the resulting recovery points but must not absorb that connection-management ownership into storage/recovery-local handlers or page flows.
+21. Keep provider-backed recovery onboarding on the adjacent platform-connections contract. When `internal/api/` grows or changes TrueNAS connection CRUD, masked-secret preservation, saved-connection retest routes, edit-form saved-test payload overlays, or similar provider setup flows, storage and recovery may consume the resulting recovery points but must not absorb that connection-management ownership into storage/recovery-local handlers or page flows. That same adjacency also covers per-surface scope as it flows through the unified connections aggregator: when `internal/api/connections_aggregator.go` projects TrueNAS `MonitorDatasets`/`MonitorPools`/`MonitorReplication` flags into the aggregator's `scope` map, storage and recovery may observe that projection to explain dataset/pool/replication coverage to operators but must not reinterpret those flags as a recovery freshness verdict, restore-capability gate, or storage-local scope registry.
22. Keep backend-native platform actions on the adjacent AI/runtime and platform contracts. When `internal/api/` wires native TrueNAS app control for Assistant, storage and recovery may consume the refreshed recovery points afterward, but they must not grow a parallel recovery-local action transport or action-specific payload shape.
23. Keep backend-native platform diagnostics on the adjacent AI/runtime and platform contracts. When `internal/api/` wires native TrueNAS app log reads for Assistant, storage and recovery may use those diagnostics during investigation, but they must not grow a parallel recovery-local log transport or diagnostic payload shape.
24. Keep backend-native platform configuration reads on the adjacent AI/runtime and platform contracts. When `internal/api/` wires native TrueNAS app config for Assistant, storage and recovery may use that runtime shape during investigation, but they must not grow a parallel recovery-local config transport or provider-shaped configuration payload.
diff --git a/frontend-modern/src/api/__tests__/truenas.test.ts b/frontend-modern/src/api/__tests__/truenas.test.ts
index fa0b21f303..183fa9726d 100644
--- a/frontend-modern/src/api/__tests__/truenas.test.ts
+++ b/frontend-modern/src/api/__tests__/truenas.test.ts
@@ -73,10 +73,73 @@ describe('TrueNASAPI', () => {
disks: 8,
recoveryArtifacts: 18,
},
+ monitorDatasets: false,
+ monitorPools: false,
+ monitorReplication: false,
},
]);
});
+ it('round-trips per-surface monitor* flags through list and update payloads', async () => {
+ vi.mocked(apiFetchJSON)
+ .mockResolvedValueOnce([
+ {
+ id: 'conn-1',
+ name: 'tower',
+ host: 'truenas.local',
+ useHttps: true,
+ insecureSkipVerify: false,
+ enabled: true,
+ pollIntervalSeconds: 60,
+ monitorDatasets: true,
+ monitorPools: false,
+ monitorReplication: true,
+ },
+ ])
+ .mockResolvedValueOnce({
+ id: 'conn-1',
+ name: 'tower',
+ host: 'truenas.local',
+ useHttps: true,
+ insecureSkipVerify: false,
+ enabled: true,
+ pollIntervalSeconds: 60,
+ monitorDatasets: false,
+ monitorPools: true,
+ monitorReplication: false,
+ });
+
+ const connections = await TrueNASAPI.listConnections();
+ expect(connections[0]).toMatchObject({
+ monitorDatasets: true,
+ monitorPools: false,
+ monitorReplication: true,
+ });
+
+ await TrueNASAPI.updateConnection('conn-1', {
+ host: 'truenas.local',
+ useHttps: true,
+ enabled: true,
+ monitorDatasets: false,
+ monitorPools: true,
+ monitorReplication: false,
+ });
+ expect(apiFetchJSON).toHaveBeenLastCalledWith(
+ '/api/truenas/connections/conn-1',
+ expect.objectContaining({
+ method: 'PUT',
+ body: JSON.stringify({
+ host: 'truenas.local',
+ useHttps: true,
+ enabled: true,
+ monitorDatasets: false,
+ monitorPools: true,
+ monitorReplication: false,
+ }),
+ }),
+ );
+ });
+
it('creates, updates, deletes, and tests connections through canonical routes', async () => {
vi.mocked(apiFetchJSON)
.mockResolvedValueOnce({
diff --git a/frontend-modern/src/api/__tests__/vmware.test.ts b/frontend-modern/src/api/__tests__/vmware.test.ts
index 070d3d4aca..2cc5971399 100644
--- a/frontend-modern/src/api/__tests__/vmware.test.ts
+++ b/frontend-modern/src/api/__tests__/vmware.test.ts
@@ -82,10 +82,67 @@ describe('VMwareAPI', () => {
},
],
},
+ monitorVms: false,
+ monitorHosts: false,
+ monitorDatastores: false,
},
]);
});
+ it('round-trips per-surface monitor* flags through list and update payloads', async () => {
+ vi.mocked(apiFetchJSON)
+ .mockResolvedValueOnce([
+ {
+ id: 'conn-1',
+ name: 'lab-vcenter',
+ host: 'vcsa.lab.local',
+ insecureSkipVerify: false,
+ enabled: true,
+ monitorVms: true,
+ monitorHosts: false,
+ monitorDatastores: true,
+ },
+ ])
+ .mockResolvedValueOnce({
+ id: 'conn-1',
+ name: 'lab-vcenter',
+ host: 'vcsa.lab.local',
+ insecureSkipVerify: false,
+ enabled: true,
+ monitorVms: false,
+ monitorHosts: true,
+ monitorDatastores: false,
+ });
+
+ const connections = await VMwareAPI.listConnections();
+ expect(connections[0]).toMatchObject({
+ monitorVms: true,
+ monitorHosts: false,
+ monitorDatastores: true,
+ });
+
+ await VMwareAPI.updateConnection('conn-1', {
+ host: 'vcsa.lab.local',
+ enabled: true,
+ monitorVms: false,
+ monitorHosts: true,
+ monitorDatastores: false,
+ });
+ expect(apiFetchJSON).toHaveBeenLastCalledWith(
+ '/api/vmware/connections/conn-1',
+ expect.objectContaining({
+ method: 'PUT',
+ body: JSON.stringify({
+ host: 'vcsa.lab.local',
+ enabled: true,
+ monitorVms: false,
+ monitorHosts: true,
+ monitorDatastores: false,
+ }),
+ }),
+ );
+ });
+
it('creates, updates, deletes, and tests connections through canonical routes', async () => {
vi.mocked(apiFetchJSON)
.mockResolvedValueOnce({
diff --git a/frontend-modern/src/api/truenas.ts b/frontend-modern/src/api/truenas.ts
index 1bec372695..398bcbcf30 100644
--- a/frontend-modern/src/api/truenas.ts
+++ b/frontend-modern/src/api/truenas.ts
@@ -61,6 +61,9 @@ export interface TrueNASConnection {
fingerprint?: string;
enabled: boolean;
pollIntervalSeconds?: number;
+ monitorDatasets: boolean;
+ monitorPools: boolean;
+ monitorReplication: boolean;
poll?: TrueNASConnectionPollStatus;
observed?: TrueNASConnectionObservedSummary;
}
@@ -77,6 +80,9 @@ export interface TrueNASConnectionInput {
fingerprint?: string;
enabled?: boolean;
pollIntervalSeconds?: number;
+ monitorDatasets?: boolean;
+ monitorPools?: boolean;
+ monitorReplication?: boolean;
}
export interface TrueNASConnectionTestResult {
@@ -137,6 +143,9 @@ const normalizeTrueNASConnection = (connection: RawTrueNASConnection): TrueNASCo
fingerprint: optionalTrimmedString(connection.fingerprint),
enabled: strictBoolean(connection.enabled),
pollIntervalSeconds: finiteNumberOrUndefined(connection.pollIntervalSeconds),
+ monitorDatasets: strictBoolean(connection.monitorDatasets),
+ monitorPools: strictBoolean(connection.monitorPools),
+ monitorReplication: strictBoolean(connection.monitorReplication),
poll: normalizeTrueNASConnectionPoll(connection.poll),
observed: normalizeTrueNASConnectionObservedSummary(connection.observed),
});
@@ -157,6 +166,11 @@ const serializeTrueNASConnectionInput = (input: TrueNASConnectionInput) => ({
...(input.pollIntervalSeconds !== undefined
? { pollIntervalSeconds: input.pollIntervalSeconds }
: {}),
+ ...(input.monitorDatasets !== undefined ? { monitorDatasets: input.monitorDatasets } : {}),
+ ...(input.monitorPools !== undefined ? { monitorPools: input.monitorPools } : {}),
+ ...(input.monitorReplication !== undefined
+ ? { monitorReplication: input.monitorReplication }
+ : {}),
});
export const isRedactedTrueNASSecret = (value: string | null | undefined) =>
diff --git a/frontend-modern/src/api/vmware.ts b/frontend-modern/src/api/vmware.ts
index 21dd179f3e..4e0e945934 100644
--- a/frontend-modern/src/api/vmware.ts
+++ b/frontend-modern/src/api/vmware.ts
@@ -63,6 +63,9 @@ export interface VMwareConnection {
password?: string;
insecureSkipVerify: boolean;
enabled: boolean;
+ monitorVms: boolean;
+ monitorHosts: boolean;
+ monitorDatastores: boolean;
poll?: VMwareConnectionPollStatus;
observed?: VMwareConnectionObservedSummary;
}
@@ -75,6 +78,9 @@ export interface VMwareConnectionInput {
password?: string;
insecureSkipVerify?: boolean;
enabled?: boolean;
+ monitorVms?: boolean;
+ monitorHosts?: boolean;
+ monitorDatastores?: boolean;
}
export interface VMwareConnectionTestResult {
@@ -137,6 +143,9 @@ const normalizeVMwareConnection = (
password: optionalTrimmedString(connection.password),
insecureSkipVerify: strictBoolean(connection.insecureSkipVerify),
enabled: strictBoolean(connection.enabled),
+ monitorVms: strictBoolean(connection.monitorVms),
+ monitorHosts: strictBoolean(connection.monitorHosts),
+ monitorDatastores: strictBoolean(connection.monitorDatastores),
poll: normalizeVMwareConnectionPoll(connection.poll ?? connection.test),
observed: normalizeVMwareConnectionObservedSummary(connection.observed),
});
@@ -151,6 +160,11 @@ const serializeVMwareConnectionInput = (input: VMwareConnectionInput) => ({
? { insecureSkipVerify: input.insecureSkipVerify }
: {}),
...(input.enabled !== undefined ? { enabled: input.enabled } : {}),
+ ...(input.monitorVms !== undefined ? { monitorVms: input.monitorVms } : {}),
+ ...(input.monitorHosts !== undefined ? { monitorHosts: input.monitorHosts } : {}),
+ ...(input.monitorDatastores !== undefined
+ ? { monitorDatastores: input.monitorDatastores }
+ : {}),
});
export const isRedactedVMwareSecret = (value: string | null | undefined) =>
diff --git a/frontend-modern/src/components/Settings/ConnectionEditor/CredentialSlots/TrueNASCredentialSlot.tsx b/frontend-modern/src/components/Settings/ConnectionEditor/CredentialSlots/TrueNASCredentialSlot.tsx
index 415860946d..ab4443683f 100644
--- a/frontend-modern/src/components/Settings/ConnectionEditor/CredentialSlots/TrueNASCredentialSlot.tsx
+++ b/frontend-modern/src/components/Settings/ConnectionEditor/CredentialSlots/TrueNASCredentialSlot.tsx
@@ -221,6 +221,59 @@ export const TrueNASCredentialSlot: Component<TrueNASCredentialSlotProps> = (pro
</div>
</div>
+ <div class="space-y-3 rounded-md border border-border bg-surface p-4">
+ <div>
+ <div class="text-sm font-semibold text-base-content">Collection scope</div>
+ <p class="mt-0.5 text-xs text-muted">
+ Pulse only collects the surfaces you keep enabled. Disable anything you don't need.
+ </p>
+ </div>
+ <div class="grid gap-2 sm:grid-cols-3">
+ <label class="flex items-start gap-2 text-sm text-base-content">
+ <input
+ type="checkbox"
+ class={formCheckbox + ' mt-0.5'}
+ checked={props.state.form().monitorDatasets}
+ onChange={(event) =>
+ props.state.updateForm({ monitorDatasets: event.currentTarget.checked })
+ }
+ />
+ <span>
+ <span class="font-medium">Datasets</span>
+ <span class="block text-xs text-muted">Dataset sizes, quotas, snapshots.</span>
+ </span>
+ </label>
+ <label class="flex items-start gap-2 text-sm text-base-content">
+ <input
+ type="checkbox"
+ class={formCheckbox + ' mt-0.5'}
+ checked={props.state.form().monitorPools}
+ onChange={(event) =>
+ props.state.updateForm({ monitorPools: event.currentTarget.checked })
+ }
+ />
+ <span>
+ <span class="font-medium">Pools</span>
+ <span class="block text-xs text-muted">ZFS pool health, capacity, scrubs.</span>
+ </span>
+ </label>
+ <label class="flex items-start gap-2 text-sm text-base-content">
+ <input
+ type="checkbox"
+ class={formCheckbox + ' mt-0.5'}
+ checked={props.state.form().monitorReplication}
+ onChange={(event) =>
+ props.state.updateForm({ monitorReplication: event.currentTarget.checked })
+ }
+ />
+ <span>
+ <span class="font-medium">Replication</span>
+ <span class="block text-xs text-muted">Replication tasks and their state.</span>
+ </span>
+ </label>
+ </div>
+ </div>
+
<MonitoredSystemAdmissionPreview
preview={props.state.monitoredSystemPreview()}
loading={props.state.previewing()}
diff --git a/frontend-modern/src/components/Settings/ConnectionEditor/CredentialSlots/VMwareCredentialSlot.tsx b/frontend-modern/src/components/Settings/ConnectionEditor/CredentialSlots/VMwareCredentialSlot.tsx
index 2c03edd84d..e8d97422e3 100644
--- a/frontend-modern/src/components/Settings/ConnectionEditor/CredentialSlots/VMwareCredentialSlot.tsx
+++ b/frontend-modern/src/components/Settings/ConnectionEditor/CredentialSlots/VMwareCredentialSlot.tsx
@@ -159,6 +159,59 @@ export const VMwareCredentialSlot: Component<VMwareCredentialSlotProps> = (props
</label>
</div>
+ <div class="space-y-3 rounded-md border border-border bg-surface p-4">
+ <div>
+ <div class="text-sm font-semibold text-base-content">Collection scope</div>
+ <p class="mt-0.5 text-xs text-muted">
+ Pulse only collects the surfaces you keep enabled. Disable anything you don't need.
+ </p>
+ </div>
+ <div class="grid gap-2 sm:grid-cols-3">
+ <label class="flex items-start gap-2 text-sm text-base-content">
+ <input
+ type="checkbox"
+ class={formCheckbox + ' mt-0.5'}
+ checked={props.state.form().monitorVms}
+ onChange={(event) =>
+ props.state.updateForm({ monitorVms: event.currentTarget.checked })
+ }
+ />
+ <span>
+ <span class="font-medium">VMs</span>
+ <span class="block text-xs text-muted">Power state, resources, snapshots.</span>
+ </span>
+ </label>
+ <label class="flex items-start gap-2 text-sm text-base-content">
+ <input
+ type="checkbox"
+ class={formCheckbox + ' mt-0.5'}
+ checked={props.state.form().monitorHosts}
+ onChange={(event) =>
+ props.state.updateForm({ monitorHosts: event.currentTarget.checked })
+ }
+ />
+ <span>
+ <span class="font-medium">Hosts</span>
+ <span class="block text-xs text-muted">ESXi host health and capacity.</span>
+ </span>
+ </label>
+ <label class="flex items-start gap-2 text-sm text-base-content">
+ <input
+ type="checkbox"
+ class={formCheckbox + ' mt-0.5'}
+ checked={props.state.form().monitorDatastores}
+ onChange={(event) =>
+ props.state.updateForm({ monitorDatastores: event.currentTarget.checked })
+ }
+ />
+ <span>
+ <span class="font-medium">Datastores</span>
+ <span class="block text-xs text-muted">Capacity and status per datastore.</span>
+ </span>
+ </label>
+ </div>
+ </div>
+
<MonitoredSystemAdmissionPreview
preview={props.state.monitoredSystemPreview()}
loading={props.state.previewing()}
diff --git a/frontend-modern/src/components/Settings/__tests__/TrueNASSettingsPanel.test.tsx b/frontend-modern/src/components/Settings/__tests__/TrueNASSettingsPanel.test.tsx
index 076fad15b7..67d4001bdd 100644
--- a/frontend-modern/src/components/Settings/__tests__/TrueNASSettingsPanel.test.tsx
+++ b/frontend-modern/src/components/Settings/__tests__/TrueNASSettingsPanel.test.tsx
@@ -116,6 +116,9 @@ describe('TrueNASSettingsPanel', () => {
useHttps: true,
insecureSkipVerify: false,
enabled: true,
+ monitorDatasets: true,
+ monitorPools: true,
+ monitorReplication: true,
poll: {
intervalSeconds: 60,
lastSuccessAt: new Date(Date.now() - 60_000).toISOString(),
@@ -141,6 +144,9 @@ describe('TrueNASSettingsPanel', () => {
insecureSkipVerify: false,
enabled: false,
pollIntervalSeconds: 300,
+ monitorDatasets: true,
+ monitorPools: true,
+ monitorReplication: true,
},
]);
diff --git a/frontend-modern/src/components/Settings/__tests__/VMwareSettingsPanel.test.tsx b/frontend-modern/src/components/Settings/__tests__/VMwareSettingsPanel.test.tsx
index 969c292bb0..0bc14fedf0 100644
--- a/frontend-modern/src/components/Settings/__tests__/VMwareSettingsPanel.test.tsx
+++ b/frontend-modern/src/components/Settings/__tests__/VMwareSettingsPanel.test.tsx
@@ -104,6 +104,9 @@ describe('VMwareSettingsPanel', () => {
password: '********',
insecureSkipVerify: false,
enabled: true,
+ monitorVms: true,
+ monitorHosts: true,
+ monitorDatastores: true,
poll: {
lastSuccessAt: new Date(Date.now() - 60_000).toISOString(),
},
@@ -122,6 +125,9 @@ describe('VMwareSettingsPanel', () => {
username: '[email protected]',
insecureSkipVerify: true,
enabled: true,
+ monitorVms: true,
+ monitorHosts: true,
+ monitorDatastores: true,
poll: {
lastAttemptAt: new Date(Date.now() - 30_000).toISOString(),
lastError: {
@@ -138,6 +144,9 @@ describe('VMwareSettingsPanel', () => {
username: '[email protected]',
insecureSkipVerify: false,
enabled: true,
+ monitorVms: true,
+ monitorHosts: true,
+ monitorDatastores: true,
poll: {
lastSuccessAt: new Date(Date.now() - 120_000).toISOString(),
},
diff --git a/frontend-modern/src/components/Settings/useTrueNASSettingsPanelState.ts b/frontend-modern/src/components/Settings/useTrueNASSettingsPanelState.ts
index 567ce9b55a..f39973527b 100644
--- a/frontend-modern/src/components/Settings/useTrueNASSettingsPanelState.ts
+++ b/frontend-modern/src/components/Settings/useTrueNASSettingsPanelState.ts
@@ -35,6 +35,9 @@ export interface TrueNASConnectionFormState {
insecureSkipVerify: boolean;
fingerprint: string;
enabled: boolean;
+ monitorDatasets: boolean;
+ monitorPools: boolean;
+ monitorReplication: boolean;
hasStoredApiKey: boolean;
hasStoredPassword: boolean;
}
@@ -54,6 +57,9 @@ const createEmptyFormState = (): TrueNASConnectionFormState => ({
insecureSkipVerify: false,
fingerprint: '',
enabled: true,
+ monitorDatasets: true,
+ monitorPools: true,
+ monitorReplication: true,
hasStoredApiKey: false,
hasStoredPassword: false,
});
@@ -79,6 +85,9 @@ const buildFormStateFromConnection = (
insecureSkipVerify: connection.insecureSkipVerify,
fingerprint: connection.fingerprint || '',
enabled: connection.enabled,
+ monitorDatasets: connection.monitorDatasets,
+ monitorPools: connection.monitorPools,
+ monitorReplication: connection.monitorReplication,
hasStoredApiKey: hasStoredAPIKey,
hasStoredPassword: hasStoredPassword,
};
@@ -145,6 +154,9 @@ const buildConnectionInput = (form: TrueNASConnectionFormState): TrueNASConnecti
insecureSkipVerify: form.insecureSkipVerify,
...(fingerprint ? { fingerprint } : {}),
enabled: form.enabled,
+ monitorDatasets: form.monitorDatasets,
+ monitorPools: form.monitorPools,
+ monitorReplication: form.monitorReplication,
};
if (form.authMode === 'apiKey') {
diff --git a/frontend-modern/src/components/Settings/useVMwareSettingsPanelState.ts b/frontend-modern/src/components/Settings/useVMwareSettingsPanelState.ts
index 463c30f29c..94c9ce175f 100644
--- a/frontend-modern/src/components/Settings/useVMwareSettingsPanelState.ts
+++ b/frontend-modern/src/components/Settings/useVMwareSettingsPanelState.ts
@@ -32,6 +32,9 @@ export interface VMwareConnectionFormState {
password: string;
insecureSkipVerify: boolean;
enabled: boolean;
+ monitorVms: boolean;
+ monitorHosts: boolean;
+ monitorDatastores: boolean;
hasStoredPassword: boolean;
}
@@ -45,6 +48,9 @@ const createEmptyFormState = (): VMwareConnectionFormState => ({
password: '',
insecureSkipVerify: false,
enabled: true,
+ monitorVms: true,
+ monitorHosts: true,
+ monitorDatastores: true,
hasStoredPassword: false,
});
@@ -56,6 +62,9 @@ const buildFormStateFromConnection = (connection: VMwareConnection): VMwareConne
password: '',
insecureSkipVerify: connection.insecureSkipVerify,
enabled: connection.enabled,
+ monitorVms: connection.monitorVms,
+ monitorHosts: connection.monitorHosts,
+ monitorDatastores: connection.monitorDatastores,
hasStoredPassword: isRedactedVMwareSecret(connection.password),
});
@@ -111,6 +120,9 @@ const buildConnectionInput = (form: VMwareConnectionFormState): VMwareConnection
password: form.password.trim() || (form.hasStoredPassword ? REDACTED_SECRET : ''),
insecureSkipVerify: form.insecureSkipVerify,
enabled: form.enabled,
+ monitorVms: form.monitorVms,
+ monitorHosts: form.monitorHosts,
+ monitorDatastores: form.monitorDatastores,
};
};
diff --git a/internal/api/connections_aggregator.go b/internal/api/connections_aggregator.go
index aa5070e186..d20b30fe24 100644
--- a/internal/api/connections_aggregator.go
+++ b/internal/api/connections_aggregator.go
@@ -169,6 +169,11 @@ func buildPMGConnection(inst config.PMGInstance, health map[string]monitoring.In
func buildVMwareConnection(inst config.VMwareVCenterInstance, health map[string]monitoring.InstanceHealth, now time.Time) Connection {
enabled := inst.Enabled
surfaces := []string{"vms", "hosts", "datastores"}
+ scope := map[string]bool{
+ "vms": inst.MonitorVMs,
+ "hosts": inst.MonitorHosts,
+ "datastores": inst.MonitorDatastores,
+ }
h := health["vmware::"+inst.ID]
state, reason, lastSeen, lastError := deriveConnectionState(enabled, h, now)
port := inst.Port
@@ -184,17 +189,22 @@ func buildVMwareConnection(inst config.VMwareVCenterInstance, health map[string]
StateReason: reason,
Enabled: enabled,
Surfaces: surfaces,
- Scope: map[string]bool{"vms": true, "hosts": true, "datastores": true},
+ Scope: scope,
LastSeen: lastSeen,
LastError: lastError,
Source: ConnectionSourceManual,
- Capabilities: ConnectionCapabilities{SupportsPause: true, SupportsScope: false, SupportsTest: true},
+ Capabilities: ConnectionCapabilities{SupportsPause: true, SupportsScope: true, SupportsTest: true},
}
}
func buildTrueNASConnection(inst config.TrueNASInstance, health map[string]monitoring.InstanceHealth, now time.Time) Connection {
enabled := inst.Enabled
surfaces := []string{"datasets", "pools", "replication"}
+ scope := map[string]bool{
+ "datasets": inst.MonitorDatasets,
+ "pools": inst.MonitorPools,
+ "replication": inst.MonitorReplication,
+ }
h := health["truenas::"+inst.ID]
state, reason, lastSeen, lastError := deriveConnectionState(enabled, h, now)
scheme := "https"
@@ -218,11 +228,11 @@ func buildTrueNASConnection(inst config.TrueNASInstance, health map[string]monit
StateReason: reason,
Enabled: enabled,
Surfaces: surfaces,
- Scope: map[string]bool{"datasets": true, "pools": true, "replication": true},
+ Scope: scope,
LastSeen: lastSeen,
LastError: lastError,
Source: ConnectionSourceManual,
- Capabilities: ConnectionCapabilities{SupportsPause: true, SupportsScope: false, SupportsTest: true},
+ Capabilities: ConnectionCapabilities{SupportsPause: true, SupportsScope: true, SupportsTest: true},
}
}
diff --git a/internal/api/connections_aggregator_test.go b/internal/api/connections_aggregator_test.go
index 32f2c2d41a..5b8c491112 100644
--- a/internal/api/connections_aggregator_test.go
+++ b/internal/api/connections_aggregator_test.go
@@ -166,9 +166,15 @@ func TestBuildConnections_AgentStateFromLastSeen(t *testing.T) {
func TestBuildConnections_VMwareAndTrueNASEnabledFlag(t *testing.T) {
in := aggregatorInputs{
- vmwareInstances: []config.VMwareVCenterInstance{{ID: "vc1", Name: "vc", Host: "vc.lan", Enabled: false}},
- truenasInstances: []config.TrueNASInstance{{ID: "tn1", Name: "tn", Host: "tn.lan", Enabled: true, UseHTTPS: true}},
- now: time.Now(),
+ vmwareInstances: []config.VMwareVCenterInstance{{
+ ID: "vc1", Name: "vc", Host: "vc.lan", Enabled: false,
+ MonitorVMs: true, MonitorHosts: true, MonitorDatastores: false,
+ }},
+ truenasInstances: []config.TrueNASInstance{{
+ ID: "tn1", Name: "tn", Host: "tn.lan", Enabled: true, UseHTTPS: true,
+ MonitorDatasets: true, MonitorPools: false, MonitorReplication: true,
+ }},
+ now: time.Now(),
}
got := buildConnections(in)
var vmw, tn Connection
@@ -183,12 +189,24 @@ func TestBuildConnections_VMwareAndTrueNASEnabledFlag(t *testing.T) {
if vmw.State != ConnectionStatePaused || vmw.Enabled {
t.Fatalf("vmware with Enabled=false should be paused, got state=%q enabled=%v", vmw.State, vmw.Enabled)
}
+ if !vmw.Capabilities.SupportsScope {
+ t.Fatal("vmware connections must advertise scope capability")
+ }
+ if vmw.Scope["datastores"] || !vmw.Scope["vms"] || !vmw.Scope["hosts"] {
+ t.Fatalf("vmware scope map should reflect Monitor* fields, got %+v", vmw.Scope)
+ }
if tn.State != ConnectionStatePending {
t.Fatalf("truenas with no health yet should be pending, got %q", tn.State)
}
if !tn.Enabled {
t.Fatal("truenas with Enabled=true should surface enabled=true")
}
+ if !tn.Capabilities.SupportsScope {
+ t.Fatal("truenas connections must advertise scope capability")
+ }
+ if tn.Scope["pools"] || !tn.Scope["datasets"] || !tn.Scope["replication"] {
+ t.Fatalf("truenas scope map should reflect Monitor* fields, got %+v", tn.Scope)
+ }
}
func TestBuildConnections_UsesHealthLookup(t *testing.T) {
diff --git a/internal/config/truenas.go b/internal/config/truenas.go
index be6858f35a..917e344c9a 100644
--- a/internal/config/truenas.go
+++ b/internal/config/truenas.go
@@ -30,15 +30,26 @@ type TrueNASInstance struct {
Fingerprint string `json:"fingerprint,omitempty"`
Enabled bool `json:"enabled"`
PollIntervalSecs int `json:"pollIntervalSeconds,omitempty"`
+
+ // Per-surface collection scope. Positive booleans. Existing records that
+ // predate these fields have all-zero Monitor* values — ApplyDefaults
+ // treats that as "legacy" and enables every surface so behavior doesn't
+ // silently change on upgrade.
+ MonitorDatasets bool `json:"monitorDatasets"`
+ MonitorPools bool `json:"monitorPools"`
+ MonitorReplication bool `json:"monitorReplication"`
}
// NewTrueNASInstance returns a new instance with generated ID and sane defaults.
func NewTrueNASInstance() TrueNASInstance {
return TrueNASInstance{
- ID: uuid.NewString(),
- UseHTTPS: true,
- Enabled: true,
- PollIntervalSecs: defaultTrueNASPollIntervalSecs,
+ ID: uuid.NewString(),
+ UseHTTPS: true,
+ Enabled: true,
+ PollIntervalSecs: defaultTrueNASPollIntervalSecs,
+ MonitorDatasets: true,
+ MonitorPools: true,
+ MonitorReplication: true,
}
}
@@ -61,6 +72,16 @@ func (t *TrueNASInstance) ApplyDefaults() {
if t.PollIntervalSecs <= 0 {
t.PollIntervalSecs = defaultTrueNASPollIntervalSecs
}
+ // Legacy records predate per-surface scope booleans. Zero-value false
+ // across all three means "never configured" — enable everything so
+ // existing users keep full visibility after upgrade. Users who
+ // deliberately disable a surface keep at least one other enabled, so
+ // the all-false state will not recur.
+ if !t.MonitorDatasets && !t.MonitorPools && !t.MonitorReplication {
+ t.MonitorDatasets = true
+ t.MonitorPools = true
+ t.MonitorReplication = true
+ }
}
// Validate performs required TrueNAS configuration checks.
diff --git a/internal/config/truenas_test.go b/internal/config/truenas_test.go
index bed7bcf054..c1b8b39fe3 100644
--- a/internal/config/truenas_test.go
+++ b/internal/config/truenas_test.go
@@ -25,6 +25,9 @@ func TestTrueNASNewInstanceDefaultsAndUniqueID(t *testing.T) {
require.True(t, first.UseHTTPS)
require.True(t, first.Enabled)
require.Equal(t, 60, first.PollIntervalSecs)
+ require.True(t, first.MonitorDatasets)
+ require.True(t, first.MonitorPools)
+ require.True(t, first.MonitorReplication)
}
func TestTrueNASEffectivePollIntervalAndApplyDefaults(t *testing.T) {
@@ -33,11 +36,25 @@ func TestTrueNASEffectivePollIntervalAndApplyDefaults(t *testing.T) {
instance.ApplyDefaults()
require.Equal(t, 60, instance.PollIntervalSecs)
+ // Legacy all-false Monitor* state migrates to all-true.
+ require.True(t, instance.MonitorDatasets)
+ require.True(t, instance.MonitorPools)
+ require.True(t, instance.MonitorReplication)
instance.PollIntervalSecs = 120
require.Equal(t, 120, instance.EffectivePollIntervalSecs())
}
+func TestTrueNASApplyDefaultsPreservesExplicitScope(t *testing.T) {
+ // User who has deliberately disabled a single surface keeps at least
+ // one other enabled, so the migration must not clobber their choice.
+ instance := TrueNASInstance{MonitorDatasets: true, MonitorPools: false, MonitorReplication: false}
+ instance.ApplyDefaults()
+ require.True(t, instance.MonitorDatasets)
+ require.False(t, instance.MonitorPools)
+ require.False(t, instance.MonitorReplication)
+}
+
func TestTrueNASValidate(t *testing.T) {
tests := []struct {
name string
diff --git a/internal/config/vmware.go b/internal/config/vmware.go
index d0ea3cecc1..69b43b0dc4 100644
--- a/internal/config/vmware.go
+++ b/internal/config/vmware.go
@@ -26,15 +26,26 @@ type VMwareVCenterInstance struct {
Password string `json:"password,omitempty"`
InsecureSkipVerify bool `json:"insecureSkipVerify,omitempty"`
Enabled bool `json:"enabled"`
+
+ // Per-surface collection scope. Positive booleans. Existing records
+ // that predate these fields have all-zero Monitor* values —
+ // ApplyDefaults treats that as "legacy" and enables every surface so
+ // behavior doesn't silently change on upgrade.
+ MonitorVMs bool `json:"monitorVms"`
+ MonitorHosts bool `json:"monitorHosts"`
+ MonitorDatastores bool `json:"monitorDatastores"`
}
// NewVMwareVCenterInstance returns a new instance with generated ID and sane
// defaults.
func NewVMwareVCenterInstance() VMwareVCenterInstance {
return VMwareVCenterInstance{
- ID: uuid.NewString(),
- Port: defaultVMwarePort,
- Enabled: true,
+ ID: uuid.NewString(),
+ Port: defaultVMwarePort,
+ Enabled: true,
+ MonitorVMs: true,
+ MonitorHosts: true,
+ MonitorDatastores: true,
}
}
@@ -47,6 +58,14 @@ func (v *VMwareVCenterInstance) ApplyDefaults() {
if v.Port <= 0 {
v.Port = defaultVMwarePort
}
+ // Legacy records predate per-surface scope booleans. Zero-value false
+ // across all three means "never configured" — enable everything so
+ // existing users keep full visibility after upgrade.
+ if !v.MonitorVMs && !v.MonitorHosts && !v.MonitorDatastores {
+ v.MonitorVMs = true
+ v.MonitorHosts = true
+ v.MonitorDatastores = true
+ }
}
// Validate performs required VMware configuration checks.
diff --git a/internal/config/vmware_test.go b/internal/config/vmware_test.go
new file mode 100644
index 0000000000..d0dfd4879e
--- /dev/null
+++ b/internal/config/vmware_test.go
@@ -0,0 +1,50 @@
+package config
+
+import (
+ "testing"
+
+ "github.com/stretchr/testify/require"
+)
+
+func TestVMwareNewInstanceDefaults(t *testing.T) {
+ inst := NewVMwareVCenterInstance()
+ require.NotEmpty(t, inst.ID)
+ require.Equal(t, defaultVMwarePort, inst.Port)
+ require.True(t, inst.Enabled)
+ require.True(t, inst.MonitorVMs)
+ require.True(t, inst.MonitorHosts)
+ require.True(t, inst.MonitorDatastores)
+}
+
+func TestVMwareApplyDefaultsLegacyScopeMigration(t *testing.T) {
+ // A record saved before Monitor* fields existed decodes with
+ // zero-value false across the board. ApplyDefaults must treat that
+ // as "never configured" and enable every surface so the upgrade
+ // doesn't silently stop collecting.
+ inst := VMwareVCenterInstance{}
+ inst.ApplyDefaults()
+ require.Equal(t, defaultVMwarePort, inst.Port)
+ require.True(t, inst.MonitorVMs)
+ require.True(t, inst.MonitorHosts)
+ require.True(t, inst.MonitorDatastores)
+}
+
+func TestVMwareApplyDefaultsPreservesExplicitScope(t *testing.T) {
+ inst := VMwareVCenterInstance{MonitorVMs: true, MonitorHosts: false, MonitorDatastores: false}
+ inst.ApplyDefaults()
+ require.True(t, inst.MonitorVMs)
+ require.False(t, inst.MonitorHosts)
+ require.False(t, inst.MonitorDatastores)
+}
+
+func TestVMwareRedactedPreservesMonitorFields(t *testing.T) {
+ inst := VMwareVCenterInstance{
+ Name: "vc", Host: "vc.lan", Password: "secret",
+ MonitorVMs: true, MonitorHosts: false, MonitorDatastores: true,
+ }
+ redacted := inst.Redacted()
+ require.Equal(t, vmwareSensitiveMask, redacted.Password)
+ require.True(t, redacted.MonitorVMs)
+ require.False(t, redacted.MonitorHosts)
+ require.True(t, redacted.MonitorDatastores)
+}