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.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Infer TrueNAS storage topology ownership
rcourtman51f79efe7234
diff --git a/frontend-modern/src/features/truenas/__tests__/truenasPageModel.test.ts b/frontend-modern/src/features/truenas/__tests__/truenasPageModel.test.tsindex 012a95ef09..5a69e7aded 100644--- a/frontend-modern/src/features/truenas/__tests__/truenasPageModel.test.ts+++ b/frontend-modern/src/features/truenas/__tests__/truenasPageModel.test.ts@@ -354,6 +354,67 @@ describe('truenasPageModel', () => {expect(rows[2]?.parentRowId).toBe('pool:pool-tank');});+ it('infers TrueNAS storage topology ownership from native pool and dataset labels', () => {+ const archivePool = makeResource({+ id: 'pool-archive',+ type: 'storage',+ name: 'archive',+ storage: { topology: 'pool', platform: 'truenas', zfsPoolState: 'ONLINE' },+ });+ const tankPool = makeResource({+ id: 'pool-tank',+ type: 'storage',+ name: 'tank',+ storage: { topology: 'pool', platform: 'truenas', zfsPoolState: 'ONLINE' },+ });+ const dataset = makeResource({+ id: 'dataset-media',+ type: 'storage',+ name: 'tank/media',+ storage: { topology: 'dataset', platform: 'truenas', path: '/mnt/tank/media' },+ });+ const share = makeResource({+ id: 'share-media',+ type: 'network-share',+ truenas: {+ share: {+ id: 'smb-1',+ name: 'Media',+ protocol: 'SMB',+ path: '/mnt/tank/media',+ dataset: 'tank/media',+ },+ },+ });+ const disk = makeResource({+ id: 'disk-sda',+ type: 'physical_disk',+ name: 'sda',+ physicalDisk: {+ storageGroup: 'tank',+ devPath: '/dev/sda',+ serial: 'serial-123',+ health: 'PASSED',+ },+ });++ const resources = [archivePool, tankPool, dataset, share, disk];+ const counts = buildTrueNASStorageChildCounts(resources);+ const rows = buildTrueNASStorageTopologyRows(resources);++ expect(counts.get(archivePool.id)).toEqual({ datasets: 0, shares: 0, disks: 0 });+ expect(counts.get(tankPool.id)).toEqual({ datasets: 1, shares: 1, disks: 1 });+ expect(counts.get(dataset.id)).toEqual({ datasets: 0, shares: 1, disks: 0 });+ expect(rows.map((row) => row.id)).toEqual([+ 'pool:pool-archive',+ 'pool:pool-tank',+ 'dataset:dataset-media',+ 'disk:disk-sda',+ ]);+ expect(rows[2]?.parentRowId).toBe('pool:pool-tank');+ expect(rows[3]?.parentRowId).toBe('pool:pool-tank');+ });+it('keeps pool ancestors visible when filtering matching storage children', () => {const pool = makeResource({id: 'pool-tank',diff --git a/frontend-modern/src/features/truenas/truenasPageModel.ts b/frontend-modern/src/features/truenas/truenasPageModel.tsindex 430152b8c0..36650587b2 100644--- a/frontend-modern/src/features/truenas/truenasPageModel.ts+++ b/frontend-modern/src/features/truenas/truenasPageModel.ts@@ -182,6 +182,65 @@ const isTrueNASPoolResource = (resource: Resource): boolean =>const isTrueNASDatasetResource = (resource: Resource): boolean =>resource.type === 'dataset' || resource.storage?.topology === 'dataset';+const normalizeTrueNASStoragePath = (value?: string | null): string => {+ const trimmed = asTrimmedString(value);+ if (!trimmed) return '';+ return trimmed+ .replace(/^\/mnt\//i, '')+ .replace(/^\/+/, '')+ .replace(/\/+$/, '')+ .toLowerCase();+};++const firstTrueNASStoragePathSegment = (value?: string | null): string => {+ const normalized = normalizeTrueNASStoragePath(value);+ return normalized.split('/').filter(Boolean)[0] ?? '';+};++const trueNASPoolAliases = (resource: Resource): Set<string> =>+ new Set(+ [+ normalizeTrueNASStoragePath(resource.storage?.pool),+ normalizeTrueNASStoragePath(resource.storage?.path),+ normalizeTrueNASStoragePath(resource.name),+ normalizeTrueNASStoragePath(resource.displayName),+ ].filter(Boolean),+ );++const trueNASDatasetAliases = (resource: Resource): Set<string> =>+ new Set(+ [+ normalizeTrueNASStoragePath(resource.storage?.path),+ normalizeTrueNASStoragePath(resource.name),+ normalizeTrueNASStoragePath(resource.displayName),+ ].filter(Boolean),+ );++const trueNASResourceDatasetAliases = (resource: Resource): Set<string> =>+ new Set(+ [+ normalizeTrueNASStoragePath(resource.truenas?.share?.dataset),+ normalizeTrueNASStoragePath(resource.truenas?.share?.path),+ normalizeTrueNASStoragePath(resource.storage?.path),+ normalizeTrueNASStoragePath(resource.name),+ normalizeTrueNASStoragePath(resource.displayName),+ ].filter(Boolean),+ );++const inferTrueNASPoolName = (resource: Resource): string =>+ normalizeTrueNASStoragePath(resource.physicalDisk?.storageGroup) ||+ firstTrueNASStoragePathSegment(resource.truenas?.share?.dataset) ||+ firstTrueNASStoragePathSegment(resource.truenas?.share?.path) ||+ normalizeTrueNASStoragePath(resource.storage?.pool) ||+ firstTrueNASStoragePathSegment(resource.storage?.path) ||+ firstTrueNASStoragePathSegment(resource.name) ||+ firstTrueNASStoragePathSegment(resource.displayName);++const pathContainsOrDescendsFrom = (candidate: string, ancestor: string): boolean =>+ Boolean(+ candidate && ancestor && (candidate === ancestor || candidate.startsWith(`${ancestor}/`)),+ );+export function buildTrueNASSystemChildCounts(resources: Resource[],systems: Resource[],@@ -263,11 +322,32 @@ export function buildTrueNASStorageChildCounts(return false;};+ const hasInferredStorageRelationship = (resource: Resource, storage: Resource): boolean => {+ if (isTrueNASPoolResource(storage)) {+ const poolName = inferTrueNASPoolName(resource);+ return poolName ? trueNASPoolAliases(storage).has(poolName) : false;+ }+ if (!isTrueNASDatasetResource(storage)) return false;+ const datasetAliases = trueNASDatasetAliases(storage);+ const resourceAliases = trueNASResourceDatasetAliases(resource);+ for (const datasetAlias of datasetAliases) {+ for (const resourceAlias of resourceAliases) {+ if (pathContainsOrDescendsFrom(resourceAlias, datasetAlias)) return true;+ }+ }+ return false;+ };+for (const storage of storageResources) {const counts = countsByStorage.get(storage.id);if (!counts) continue;for (const resource of trueNasResources) {- if (resource.id === storage.id || !hasAncestor(resource, storage.id)) continue;+ if (+ resource.id === storage.id ||+ (!hasAncestor(resource, storage.id) && !hasInferredStorageRelationship(resource, storage))+ ) {+ continue;+ }if (isTrueNASDatasetResource(resource)) {counts.datasets += 1;} else if (resource.type === 'network-share') {@@ -308,6 +388,12 @@ export function buildTrueNASStorageTopologyRows(visited.add(parentId);parentId = asTrimmedString(parent?.parentId);}+ const poolName = inferTrueNASPoolName(resource);+ if (poolName) {+ const inferredPool = pools.find((pool) => trueNASPoolAliases(pool).has(poolName));+ if (inferredPool) return inferredPool.id;+ }+ if (pools.length === 1 && !isTrueNASPoolResource(resource)) return pools[0]?.id ?? '';return '';};