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.

Harden TrueNAS inventory ownership

rcourtman141269e31eff
diff --git a/frontend-modern/src/features/truenas/__tests__/truenasPageModel.test.ts b/frontend-modern/src/features/truenas/__tests__/truenasPageModel.test.ts
index c732ed7b76..012a95ef09 100644
--- a/frontend-modern/src/features/truenas/__tests__/truenasPageModel.test.ts
+++ b/frontend-modern/src/features/truenas/__tests__/truenasPageModel.test.ts
@@ -223,6 +223,49 @@ describe('truenasPageModel', () => {
});
});
+ it('counts unparented TrueNAS inventory in mixed single-system snapshots', () => {
+ const system = makeResource({
+ id: 'system-primary',
+ type: 'agent',
+ truenas: { services: [{ id: '1', service: 'smb', enabled: true, state: 'RUNNING' }] },
+ });
+ const pool = makeResource({
+ id: 'pool-tank',
+ type: 'storage',
+ parentId: system.id,
+ storage: { topology: 'pool', platform: 'truenas' },
+ });
+ const dataset = makeResource({
+ id: 'dataset-media',
+ type: 'storage',
+ parentId: pool.id,
+ storage: { topology: 'dataset', platform: 'truenas' },
+ });
+
+ const counts = buildTrueNASSystemChildCounts(
+ [
+ system,
+ pool,
+ dataset,
+ makeResource({ id: 'share-media', type: 'network-share' }),
+ makeResource({ id: 'disk-sda', type: 'physical_disk' }),
+ makeResource({ id: 'vm-windows', type: 'vm' }),
+ makeResource({ id: 'app-nextcloud', type: 'app-container' }),
+ ],
+ [system],
+ );
+
+ expect(counts.get(system.id)).toEqual({
+ pools: 1,
+ datasets: 1,
+ shares: 1,
+ vms: 1,
+ apps: 1,
+ disks: 1,
+ services: 1,
+ });
+ });
+
it('builds and filters native TrueNAS service rows from system metadata', () => {
const system = makeResource({
id: 'system-primary',
diff --git a/frontend-modern/src/features/truenas/truenasPageModel.ts b/frontend-modern/src/features/truenas/truenasPageModel.ts
index 221f7208b0..430152b8c0 100644
--- a/frontend-modern/src/features/truenas/truenasPageModel.ts
+++ b/frontend-modern/src/features/truenas/truenasPageModel.ts
@@ -194,16 +194,9 @@ export function buildTrueNASSystemChildCounts(
const systemIds = new Set(systems.map((system) => system.id));
const resourceById = new Map(resources.map((resource) => [resource.id, resource]));
- const hasParentSignals = resources.some((resource) =>
- Boolean(asTrimmedString(resource.parentId)),
- );
-
- const fallbackSystemId =
- systems.length === 1 && !hasParentSignals ? asTrimmedString(systems[0]?.id) : '';
+ const fallbackSystemId = systems.length === 1 ? asTrimmedString(systems[0]?.id) : '';
const owningSystemId = (resource: Resource): string => {
- if (fallbackSystemId && resource.id !== fallbackSystemId) return fallbackSystemId;
-
let parentId = asTrimmedString(resource.parentId);
const visited = new Set<string>();
while (parentId && !visited.has(parentId)) {
@@ -211,7 +204,7 @@ export function buildTrueNASSystemChildCounts(
visited.add(parentId);
parentId = asTrimmedString(resourceById.get(parentId)?.parentId);
}
- return '';
+ return fallbackSystemId && resource.id !== fallbackSystemId ? fallbackSystemId : '';
};
for (const resource of resources) {