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.

Scope TrueNAS resources by appliance

rcourtman497390ff953d
diff --git a/docs/release-control/v6/internal/subsystems/monitoring.md b/docs/release-control/v6/internal/subsystems/monitoring.md
index 9bbe33c982..9ab06afd2a 100644
--- a/docs/release-control/v6/internal/subsystems/monitoring.md
+++ b/docs/release-control/v6/internal/subsystems/monitoring.md
@@ -116,6 +116,11 @@ truth for live infrastructure data.
through `TrueNASData.App` on the canonical `app-container` resource.
Monitoring must not rebuild a second Docker-only TrueNAS app inventory or
make the Docker fallback the source of truth for the TrueNAS platform page.
+ TrueNAS child source identities are appliance-local and must be scoped under
+ the owning system source key before unified-resource ingest, so common pool,
+ dataset, app, VM, share, and disk names from different appliances remain
+ distinct. Mock fixture metrics and seeded/live history must use the same
+ scoped source keys as the TrueNAS provider metrics targets.
TrueNAS VMs and network shares follow the same provider-owned inventory
boundary: `vm.query` data publishes native `TrueNASData.VM` on canonical
`vm` resources, while SMB/NFS share data from `sharing.smb.query` and
diff --git a/frontend-modern/src/features/truenas/TrueNASSystemsTable.tsx b/frontend-modern/src/features/truenas/TrueNASSystemsTable.tsx
index 8859de0135..7644e6a29c 100644
--- a/frontend-modern/src/features/truenas/TrueNASSystemsTable.tsx
+++ b/frontend-modern/src/features/truenas/TrueNASSystemsTable.tsx
@@ -34,6 +34,10 @@ import {
createPlatformResourceLabelResolver,
getPlatformResourceDetailRowClass,
} from '@/features/platformPage/PlatformResourceDetailTableRow';
+import {
+ buildTrueNASSystemChildCounts,
+ type TrueNASSystemChildCounts,
+} from '@/features/truenas/truenasPageModel';
import type { Resource } from '@/types/resource';
// TrueNAS systems are storage appliances, not generic compute hosts.
@@ -90,6 +94,14 @@ const metricFallback = () => (
</div>
);
+const EMPTY_COUNTS: TrueNASSystemChildCounts = {
+ pools: 0,
+ datasets: 0,
+ shares: 0,
+ apps: 0,
+ disks: 0,
+};
+
export const TrueNASSystemsTable: Component<{
systems: Resource[];
// Full TrueNAS resource scope so we can count pools / datasets / apps
@@ -108,23 +120,9 @@ export const TrueNASSystemsTable: Component<{
});
const drawer = createPlatformResourceDetailState({ idPrefix: 'truenas-system-drawer' });
const resolveResourceLabel = createPlatformResourceLabelResolver(() => props.scope);
-
- // Single-system canonical mock is the common case today; counts span
- // the full TrueNAS resource scope per row. When multi-system support
- // arrives, the canonical adapter should attach a parent system id to
- // child resources and we can filter by it.
- const counts = createMemo(() => {
- const pools = props.scope.filter(
- (r) => r.type === 'pool' || (r.type === 'storage' && r.storage?.topology === 'pool'),
- ).length;
- const datasets = props.scope.filter(
- (r) => r.type === 'dataset' || (r.type === 'storage' && r.storage?.topology === 'dataset'),
- ).length;
- const shares = props.scope.filter((r) => r.type === 'network-share').length;
- const apps = props.scope.filter((r) => r.type === 'app-container').length;
- const disks = props.scope.filter((r) => r.type === 'physical_disk').length;
- return { pools, datasets, shares, apps, disks };
- });
+ const countsBySystem = createMemo(() =>
+ buildTrueNASSystemChildCounts(props.scope, props.systems),
+ );
return (
<Show
@@ -250,7 +248,7 @@ export const TrueNASSystemsTable: Component<{
typeof system.disk?.total === 'number'
? `${formatBytes(system.disk.used)} / ${formatBytes(system.disk.total)}`
: formatPercent(storagePercent());
- const c = counts();
+ const c = () => countsBySystem().get(system.id) ?? EMPTY_COUNTS;
const metricsKey = () => buildMetricKeyForUnifiedResource(system);
const cpuPercent = () => finiteMetric(system.cpu?.current);
const memoryTotal = () => finiteMetric(system.memory?.total) ?? 0;
@@ -336,27 +334,27 @@ export const TrueNASSystemsTable: Component<{
<TableCell
class={`${getPlatformTableCellClassForKind('numeric-value')} hidden text-base-content tabular-nums md:table-cell`}
>
- {c.pools}
+ {c().pools}
</TableCell>
<TableCell
class={`${getPlatformTableCellClassForKind('numeric-value')} hidden text-base-content tabular-nums md:table-cell`}
>
- {c.datasets}
+ {c().datasets}
</TableCell>
<TableCell
class={`${getPlatformTableCellClassForKind('numeric-value')} hidden text-base-content tabular-nums md:table-cell`}
>
- {c.shares}
+ {c().shares}
</TableCell>
<TableCell
class={`${getPlatformTableCellClassForKind('numeric-value')} hidden text-base-content tabular-nums md:table-cell`}
>
- {c.disks}
+ {c().disks}
</TableCell>
<TableCell
class={`${getPlatformTableCellClassForKind('numeric-value')} hidden text-base-content tabular-nums md:table-cell`}
>
- {c.apps}
+ {c().apps}
</TableCell>
</TableRow>
<PlatformResourceDetailTableRow
diff --git a/frontend-modern/src/features/truenas/__tests__/truenasPageModel.test.ts b/frontend-modern/src/features/truenas/__tests__/truenasPageModel.test.ts
index 53fb487031..e490694a00 100644
--- a/frontend-modern/src/features/truenas/__tests__/truenasPageModel.test.ts
+++ b/frontend-modern/src/features/truenas/__tests__/truenasPageModel.test.ts
@@ -3,6 +3,7 @@ import type { Resource } from '@/types/resource';
import {
TRUENAS_TAB_SPECS,
buildTrueNASPageModel,
+ buildTrueNASSystemChildCounts,
filterTrueNASApps,
filterTrueNASIncidents,
filterTrueNASShares,
@@ -57,6 +58,95 @@ describe('truenasPageModel', () => {
);
});
+ it('counts overview inventory from each TrueNAS system hierarchy', () => {
+ const primary = makeResource({ id: 'system-primary', type: 'agent', name: 'nas-primary' });
+ const backup = makeResource({ id: 'system-backup', type: 'agent', name: 'nas-backup' });
+ const primaryPool = makeResource({
+ id: 'primary-pool-tank',
+ type: 'storage',
+ name: 'tank',
+ parentId: primary.id,
+ storage: { topology: 'pool', platform: 'truenas' },
+ });
+ const backupPool = makeResource({
+ id: 'backup-pool-tank',
+ type: 'storage',
+ name: 'tank',
+ parentId: backup.id,
+ storage: { topology: 'pool', platform: 'truenas' },
+ });
+ const primaryDataset = makeResource({
+ id: 'primary-dataset-media',
+ type: 'storage',
+ name: 'tank/media',
+ parentId: primaryPool.id,
+ storage: { topology: 'dataset', platform: 'truenas' },
+ });
+ const backupDataset = makeResource({
+ id: 'backup-dataset-media',
+ type: 'storage',
+ name: 'tank/media',
+ parentId: backupPool.id,
+ storage: { topology: 'dataset', platform: 'truenas' },
+ });
+
+ const counts = buildTrueNASSystemChildCounts(
+ [
+ primary,
+ backup,
+ primaryPool,
+ backupPool,
+ primaryDataset,
+ backupDataset,
+ makeResource({ id: 'primary-share', type: 'network-share', parentId: primaryDataset.id }),
+ makeResource({ id: 'backup-share', type: 'network-share', parentId: backupDataset.id }),
+ makeResource({ id: 'primary-disk', type: 'physical_disk', parentId: primaryPool.id }),
+ makeResource({ id: 'backup-disk', type: 'physical_disk', parentId: backupPool.id }),
+ makeResource({ id: 'primary-app', type: 'app-container', parentId: primary.id }),
+ makeResource({ id: 'backup-app', type: 'app-container', parentId: backup.id }),
+ ],
+ [primary, backup],
+ );
+
+ expect(counts.get(primary.id)).toEqual({
+ pools: 1,
+ datasets: 1,
+ shares: 1,
+ apps: 1,
+ disks: 1,
+ });
+ expect(counts.get(backup.id)).toEqual({
+ pools: 1,
+ datasets: 1,
+ shares: 1,
+ apps: 1,
+ disks: 1,
+ });
+ });
+
+ it('keeps the single-system inventory fallback for older unparented TrueNAS resources', () => {
+ const system = makeResource({ id: 'system-primary', type: 'agent' });
+ const counts = buildTrueNASSystemChildCounts(
+ [
+ system,
+ makeResource({ id: 'pool-tank', type: 'storage', storage: { topology: 'pool' } }),
+ makeResource({ id: 'dataset-media', type: 'storage', storage: { topology: 'dataset' } }),
+ makeResource({ id: 'share-media', type: 'network-share' }),
+ makeResource({ id: 'disk-sda', type: 'physical_disk' }),
+ makeResource({ id: 'app-nextcloud', type: 'app-container' }),
+ ],
+ [system],
+ );
+
+ expect(counts.get(system.id)).toEqual({
+ pools: 1,
+ datasets: 1,
+ shares: 1,
+ apps: 1,
+ disks: 1,
+ });
+ });
+
it('filters apps using native TrueNAS app.query metadata', () => {
const nextcloud = makeResource({
id: 'app-nextcloud',
diff --git a/frontend-modern/src/features/truenas/truenasPageModel.ts b/frontend-modern/src/features/truenas/truenasPageModel.ts
index ae8cd0c4cc..c6f45d0e8c 100644
--- a/frontend-modern/src/features/truenas/truenasPageModel.ts
+++ b/frontend-modern/src/features/truenas/truenasPageModel.ts
@@ -65,6 +65,22 @@ export type TrueNASIncidentRow = {
priority: number;
};
+export type TrueNASSystemChildCounts = {
+ pools: number;
+ datasets: number;
+ shares: number;
+ apps: number;
+ disks: number;
+};
+
+const emptyTrueNASSystemChildCounts = (): TrueNASSystemChildCounts => ({
+ pools: 0,
+ datasets: 0,
+ shares: 0,
+ apps: 0,
+ disks: 0,
+});
+
export function buildTrueNASPageModel(resources: Resource[]): TrueNASPageModel {
const trueNasResources = resources.filter(
(resource) => isTrueNASPlatform(resource) && TRUENAS_RESOURCE_TYPES.has(resource.type),
@@ -84,6 +100,59 @@ export function buildTrueNASPageModel(resources: Resource[]): TrueNASPageModel {
};
}
+export function buildTrueNASSystemChildCounts(
+ resources: Resource[],
+ systems: Resource[],
+): Map<string, TrueNASSystemChildCounts> {
+ const countsBySystem = new Map<string, TrueNASSystemChildCounts>();
+ for (const system of systems) {
+ countsBySystem.set(system.id, emptyTrueNASSystemChildCounts());
+ }
+ if (systems.length === 0) return countsBySystem;
+
+ 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 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)) {
+ if (systemIds.has(parentId)) return parentId;
+ visited.add(parentId);
+ parentId = asTrimmedString(resourceById.get(parentId)?.parentId);
+ }
+ return '';
+ };
+
+ for (const resource of resources) {
+ if (resource.type === 'agent') continue;
+ const systemId = owningSystemId(resource);
+ if (!systemId) continue;
+ const counts = countsBySystem.get(systemId);
+ if (!counts) continue;
+
+ if (resource.type === 'pool' || resource.storage?.topology === 'pool') {
+ counts.pools += 1;
+ } else if (resource.type === 'dataset' || resource.storage?.topology === 'dataset') {
+ counts.datasets += 1;
+ } else if (resource.type === 'network-share') {
+ counts.shares += 1;
+ } else if (resource.type === 'app-container') {
+ counts.apps += 1;
+ } else if (resource.type === 'physical_disk') {
+ counts.disks += 1;
+ }
+ }
+
+ return countsBySystem;
+}
+
const normalize = (value: unknown): string =>
typeof value === 'string' ? value.trim().toLowerCase() : '';
diff --git a/internal/api/resources_test.go b/internal/api/resources_test.go
index 352a9000c1..bc2c0517f1 100644
--- a/internal/api/resources_test.go
+++ b/internal/api/resources_test.go
@@ -3414,8 +3414,8 @@ func TestResourceListIncludesTrueNASAppsAsAppContainers(t *testing.T) {
if nextcloud.Docker.Runtime != "docker" {
t.Fatalf("expected runtime docker, got %q", nextcloud.Docker.Runtime)
}
- if nextcloud.MetricsTarget == nil || nextcloud.MetricsTarget.ResourceType != "app-container" || nextcloud.MetricsTarget.ResourceID != "nextcloud" {
- t.Fatalf("expected canonical TrueNAS app metrics target nextcloud, got %+v", nextcloud.MetricsTarget)
+ if nextcloud.MetricsTarget == nil || nextcloud.MetricsTarget.ResourceType != "app-container" || nextcloud.MetricsTarget.ResourceID != "system:truenas-main/app:nextcloud" {
+ t.Fatalf("expected canonical TrueNAS app metrics target system:truenas-main/app:nextcloud, got %+v", nextcloud.MetricsTarget)
}
}
@@ -3474,8 +3474,8 @@ func TestResourceListIncludesTrueNASVMsAsCanonicalWorkloads(t *testing.T) {
if windows.TrueNAS.VM.ID != "42" || windows.TrueNAS.VM.VCPUs != 4 || windows.TrueNAS.VM.MemoryBytes != 8*1024*1024*1024 {
t.Fatalf("unexpected native TrueNAS VM payload: %+v", windows.TrueNAS.VM)
}
- if windows.MetricsTarget == nil || windows.MetricsTarget.ResourceType != "vm" || windows.MetricsTarget.ResourceID != "42" {
- t.Fatalf("expected canonical TrueNAS VM metrics target 42, got %+v", windows.MetricsTarget)
+ if windows.MetricsTarget == nil || windows.MetricsTarget.ResourceType != "vm" || windows.MetricsTarget.ResourceID != "system:truenas-main/vm:42" {
+ t.Fatalf("expected canonical TrueNAS VM metrics target system:truenas-main/vm:42, got %+v", windows.MetricsTarget)
}
}
diff --git a/internal/mock/metric_personas.go b/internal/mock/metric_personas.go
index a2c1133cde..49281e36f7 100644
--- a/internal/mock/metric_personas.go
+++ b/internal/mock/metric_personas.go
@@ -134,10 +134,10 @@ func buildMetricRoleRegistry(graph FixtureGraph) map[string]string {
truenasFixtures := graph.PlatformFixtures.TrueNAS
register("agent", truenasFixtures.System.Hostname, truenasFixtures.System.Hostname, "truenas", "storage")
for _, pool := range truenasFixtures.Pools {
- register("storage", "pool:"+pool.Name, pool.Name, "truenas", "pool", "storage")
+ register("storage", TrueNASPoolMetricID(truenasFixtures.System.Hostname, pool.Name), pool.Name, "truenas", "pool", "storage")
}
for _, dataset := range truenasFixtures.Datasets {
- register("storage", "dataset:"+dataset.Name, dataset.Name, "truenas", "dataset", "storage")
+ register("storage", TrueNASDatasetMetricID(truenasFixtures.System.Hostname, dataset.Name), dataset.Name, "truenas", "dataset", "storage")
}
for _, disk := range truenasFixtures.Disks {
register("disk", trueNASDiskMetricID(disk), disk.Name, disk.Model, disk.Serial, "storage", "disk")
@@ -152,7 +152,7 @@ func buildMetricRoleRegistry(graph FixtureGraph) map[string]string {
}
hints := []string{app.Name, app.ID}
hints = append(hints, app.Images...)
- register("dockerContainer", appID, hints...)
+ register("dockerContainer", TrueNASAppMetricID(truenasFixtures.System.Hostname, app), hints...)
}
vmwareFixtures := graph.PlatformFixtures.VMware
diff --git a/internal/mock/platform_fixtures.go b/internal/mock/platform_fixtures.go
index a2263c98ea..bdd1ea57ef 100644
--- a/internal/mock/platform_fixtures.go
+++ b/internal/mock/platform_fixtures.go
@@ -297,13 +297,13 @@ func refreshTrueNASPlatformFixture(snapshot truenas.FixtureSnapshot, at time.Tim
}
for i := range out.Pools {
- usage := SampleMetric("storage", "pool:"+strings.TrimSpace(out.Pools[i].Name), "usage", at)
+ usage := SampleMetric("storage", TrueNASPoolMetricID(out.System.Hostname, out.Pools[i].Name), "usage", at)
applyTrueNASCapacityUsage(&out.Pools[i].UsedBytes, &out.Pools[i].FreeBytes, out.Pools[i].TotalBytes, usage)
}
for i := range out.Datasets {
totalBytes := out.Datasets[i].UsedBytes + out.Datasets[i].AvailBytes
- usage := SampleMetric("storage", "dataset:"+strings.TrimSpace(out.Datasets[i].Name), "usage", at)
+ usage := SampleMetric("storage", TrueNASDatasetMetricID(out.System.Hostname, out.Datasets[i].Name), "usage", at)
usedBytes := bytesFromPercent(totalBytes, usage)
out.Datasets[i].UsedBytes = usedBytes
out.Datasets[i].AvailBytes = totalBytes - usedBytes
@@ -327,10 +327,7 @@ func refreshTrueNASPlatformFixture(snapshot truenas.FixtureSnapshot, at time.Tim
continue
}
- appID := strings.TrimSpace(out.Apps[i].ID)
- if appID == "" {
- appID = strings.TrimSpace(out.Apps[i].Name)
- }
+ appID := TrueNASAppMetricID(out.System.Hostname, out.Apps[i])
if appID == "" {
continue
}
diff --git a/internal/mock/platform_fixtures_test.go b/internal/mock/platform_fixtures_test.go
index 0232a8bf68..57360c5495 100644
--- a/internal/mock/platform_fixtures_test.go
+++ b/internal/mock/platform_fixtures_test.go
@@ -224,14 +224,28 @@ func TestBuildFixtureGraphRefreshesPlatformFixtureMetricsFromCanonicalModel(t *t
t.Fatalf("expected refreshed TrueNAS system cpu %.6f, got %.6f", want, got)
}
+ pool := graph.PlatformFixtures.TrueNAS.Pools[0]
+ poolID := TrueNASPoolMetricID(system.Hostname, pool.Name)
+ if got, want := pool.UsedBytes, bytesFromPercent(pool.TotalBytes, SampleMetric("storage", poolID, "usage", now)); got != want {
+ t.Fatalf("expected refreshed TrueNAS pool used bytes %d, got %d", want, got)
+ }
+
+ dataset := graph.PlatformFixtures.TrueNAS.Datasets[0]
+ datasetID := TrueNASDatasetMetricID(system.Hostname, dataset.Name)
+ datasetTotal := dataset.UsedBytes + dataset.AvailBytes
+ if got, want := dataset.UsedBytes, bytesFromPercent(datasetTotal, SampleMetric("storage", datasetID, "usage", now)); got != want {
+ t.Fatalf("expected refreshed TrueNAS dataset used bytes %d, got %d", want, got)
+ }
+
app := graph.PlatformFixtures.TrueNAS.Apps[1]
if app.Stats == nil {
t.Fatal("expected refreshed TrueNAS app stats")
}
- if got, want := app.Stats.CPUPercent, SampleMetric("dockerContainer", app.ID, "cpu", now); math.Abs(got-want) > 1e-9 {
+ appID := TrueNASAppMetricID(system.Hostname, app)
+ if got, want := app.Stats.CPUPercent, SampleMetric("dockerContainer", appID, "cpu", now); math.Abs(got-want) > 1e-9 {
t.Fatalf("expected refreshed TrueNAS app cpu %.6f, got %.6f", want, got)
}
- if got, want := app.Stats.MemoryBytes, bytesFromPercent(system.MemoryTotalBytes, SampleMetric("dockerContainer", app.ID, "memory", now)); got != want {
+ if got, want := app.Stats.MemoryBytes, bytesFromPercent(system.MemoryTotalBytes, SampleMetric("dockerContainer", appID, "memory", now)); got != want {
t.Fatalf("expected refreshed TrueNAS app memory bytes %d, got %d", want, got)
}
diff --git a/internal/mock/truenas_metrics_identity.go b/internal/mock/truenas_metrics_identity.go
index 87e5dea689..ba6ae9480a 100644
--- a/internal/mock/truenas_metrics_identity.go
+++ b/internal/mock/truenas_metrics_identity.go
@@ -6,6 +6,37 @@ import (
"github.com/rcourtman/pulse-go-rewrite/internal/truenas"
)
+func TrueNASPoolMetricID(hostname string, pool string) string {
+ return TrueNASScopedMetricID(hostname, "pool:"+strings.TrimSpace(pool))
+}
+
+func TrueNASDatasetMetricID(hostname string, dataset string) string {
+ return TrueNASScopedMetricID(hostname, "dataset:"+strings.TrimSpace(dataset))
+}
+
+func TrueNASAppMetricID(hostname string, app truenas.App) string {
+ appID := strings.TrimSpace(app.ID)
+ if appID == "" {
+ appID = strings.TrimSpace(app.Name)
+ }
+ if appID == "" {
+ return ""
+ }
+ return TrueNASScopedMetricID(hostname, "app:"+appID)
+}
+
+func TrueNASScopedMetricID(hostname string, sourceID string) string {
+ hostname = strings.TrimSpace(hostname)
+ sourceID = strings.TrimSpace(sourceID)
+ if hostname == "" {
+ return sourceID
+ }
+ if sourceID == "" {
+ return "system:" + hostname
+ }
+ return "system:" + hostname + "/" + sourceID
+}
+
func trueNASDiskMetricsResourceID(disk truenas.Disk) string {
resourceID := strings.TrimSpace(disk.Serial)
if resourceID == "" {
diff --git a/internal/monitoring/mock_metrics_history.go b/internal/monitoring/mock_metrics_history.go
index 67b95daae7..a001d8c3e4 100644
--- a/internal/monitoring/mock_metrics_history.go
+++ b/internal/monitoring/mock_metrics_history.go
@@ -793,7 +793,7 @@ func seedMockMetricsHistory(mh *MetricsHistory, ms *metrics.Store, graph mock.Fi
)
for _, pool := range trueNASFixtures.Pools {
- poolKey := "pool:" + pool.Name
+ poolKey := mock.TrueNASPoolMetricID(trueNASFixtures.System.Hostname, pool.Name)
diskSeries := canonicalMetricSeries("storage", poolKey, "usage", seedTimestamps)
for i := 0; i < numPoints; i++ {
ts := seedTimestamps[i]
@@ -803,7 +803,7 @@ func seedMockMetricsHistory(mh *MetricsHistory, ms *metrics.Store, graph mock.Fi
}
for _, dataset := range trueNASFixtures.Datasets {
- dsKey := "dataset:" + dataset.Name
+ dsKey := mock.TrueNASDatasetMetricID(trueNASFixtures.System.Hostname, dataset.Name)
totalBytes := dataset.UsedBytes + dataset.AvailBytes
diskSeries := canonicalMetricSeries("storage", dsKey, "usage", seedTimestamps)
for i := 0; i < numPoints; i++ {
@@ -840,11 +840,8 @@ func seedMockMetricsHistory(mh *MetricsHistory, ms *metrics.Store, graph mock.Fi
}
for _, app := range trueNASFixtures.Apps {
- appID := strings.TrimSpace(app.ID)
- if appID == "" {
- appID = strings.TrimSpace(app.Name)
- }
- if appID == "" {
+ appID := mock.TrueNASAppMetricID(trueNASFixtures.System.Hostname, app)
+ if strings.TrimSpace(appID) == "" {
continue
}
recordGuest(
@@ -951,7 +948,7 @@ func recordTrueNASFixturesMetrics(mh *MetricsHistory, ms *metrics.Store, fixture
for _, pool := range snapshot.Pools {
if pool.TotalBytes > 0 {
- poolKey := "pool:" + pool.Name
+ poolKey := mock.TrueNASPoolMetricID(snapshot.System.Hostname, pool.Name)
total := float64(pool.TotalBytes)
usage := clampFloat(mock.SampleMetric("storage", poolKey, "usage", ts), 0, 100)
used := total * (usage / 100.0)
@@ -962,7 +959,7 @@ func recordTrueNASFixturesMetrics(mh *MetricsHistory, ms *metrics.Store, fixture
mh.AddStorageMetric(poolKey, "avail", avail, ts)
mh.AddStorageMetric(poolKey, "total", total, ts)
if ms != nil {
- ms.Write("pool", pool.Name, "disk", usage, ts)
+ ms.Write("pool", poolKey, "disk", usage, ts)
ms.Write("storage", poolKey, "usage", usage, ts)
ms.Write("storage", poolKey, "used", used, ts)
ms.Write("storage", poolKey, "avail", avail, ts)
@@ -974,7 +971,7 @@ func recordTrueNASFixturesMetrics(mh *MetricsHistory, ms *metrics.Store, fixture
for _, dataset := range snapshot.Datasets {
totalBytes := dataset.UsedBytes + dataset.AvailBytes
if totalBytes > 0 {
- dsKey := "dataset:" + dataset.Name
+ dsKey := mock.TrueNASDatasetMetricID(snapshot.System.Hostname, dataset.Name)
total := float64(totalBytes)
usage := clampFloat(mock.SampleMetric("storage", dsKey, "usage", ts), 0, 100)
used := total * (usage / 100.0)
@@ -985,7 +982,7 @@ func recordTrueNASFixturesMetrics(mh *MetricsHistory, ms *metrics.Store, fixture
mh.AddStorageMetric(dsKey, "avail", avail, ts)
mh.AddStorageMetric(dsKey, "total", total, ts)
if ms != nil {
- ms.Write("dataset", dataset.Name, "disk", usage, ts)
+ ms.Write("dataset", dsKey, "disk", usage, ts)
ms.Write("storage", dsKey, "usage", usage, ts)
ms.Write("storage", dsKey, "used", used, ts)
ms.Write("storage", dsKey, "avail", avail, ts)
@@ -1020,11 +1017,8 @@ func recordTrueNASFixturesMetrics(mh *MetricsHistory, ms *metrics.Store, fixture
}
for _, app := range snapshot.Apps {
- appID := strings.TrimSpace(app.ID)
- if appID == "" {
- appID = strings.TrimSpace(app.Name)
- }
- if appID == "" {
+ appID := mock.TrueNASAppMetricID(snapshot.System.Hostname, app)
+ if strings.TrimSpace(appID) == "" {
continue
}
cpu := mock.SampleMetric("dockerContainer", appID, "cpu", ts)
diff --git a/internal/monitoring/mock_metrics_history_test.go b/internal/monitoring/mock_metrics_history_test.go
index 8101f96326..c2f88efd34 100644
--- a/internal/monitoring/mock_metrics_history_test.go
+++ b/internal/monitoring/mock_metrics_history_test.go
@@ -637,7 +637,8 @@ func TestSeedMockMetricsHistory_SeedsTrueNASMetricsStore(t *testing.T) {
t.Fatal("expected metrics store to have seeded canonical TrueNAS agent cpu points")
}
- datasetPoints, err := store.Query("storage", "dataset:"+fixtures.Datasets[0].Name, "usage", now.Add(-seedDuration), now, 3600)
+ datasetID := mock.TrueNASDatasetMetricID(fixtures.System.Hostname, fixtures.Datasets[0].Name)
+ datasetPoints, err := store.Query("storage", datasetID, "usage", now.Add(-seedDuration), now, 3600)
if err != nil {
t.Fatalf("failed to query canonical TrueNAS dataset usage metrics: %v", err)
}
@@ -645,11 +646,12 @@ func TestSeedMockMetricsHistory_SeedsTrueNASMetricsStore(t *testing.T) {
t.Fatal("expected metrics store to have seeded canonical TrueNAS dataset usage points")
}
lastDatasetPoint := datasetPoints[len(datasetPoints)-1]
- if got, want := lastDatasetPoint.Value, expectedCanonicalStoreBucketAverage(t, "storage", "dataset:"+fixtures.Datasets[0].Name, "usage", now, seedDuration, time.Minute, lastDatasetPoint.Timestamp, 3600); math.Abs(got-want) > 1e-9 {
+ if got, want := lastDatasetPoint.Value, expectedCanonicalStoreBucketAverage(t, "storage", datasetID, "usage", now, seedDuration, time.Minute, lastDatasetPoint.Timestamp, 3600); math.Abs(got-want) > 1e-9 {
t.Fatalf("expected TrueNAS dataset usage seed at %s to match canonical downsample bucket, got=%v want=%v", lastDatasetPoint.Timestamp.Format(time.RFC3339), got, want)
}
- poolUsedPoints, err := store.Query("storage", "pool:"+fixtures.Pools[0].Name, "used", now.Add(-seedDuration), now, 3600)
+ poolID := mock.TrueNASPoolMetricID(fixtures.System.Hostname, fixtures.Pools[0].Name)
+ poolUsedPoints, err := store.Query("storage", poolID, "used", now.Add(-seedDuration), now, 3600)
if err != nil {
t.Fatalf("failed to query TrueNAS pool used metrics: %v", err)
}
@@ -662,7 +664,8 @@ func TestSeedMockMetricsHistory_SeedsTrueNASMetricsStore(t *testing.T) {
t.Fatal("expected in-memory history to have seeded TrueNAS disk temperature points")
}
- appPoints, err := store.Query("dockerContainer", "nextcloud", "cpu", now.Add(-seedDuration), now, 3600)
+ appID := mock.TrueNASAppMetricID(fixtures.System.Hostname, fixtures.Apps[0])
+ appPoints, err := store.Query("dockerContainer", appID, "cpu", now.Add(-seedDuration), now, 3600)
if err != nil {
t.Fatalf("failed to query TrueNAS app cpu metrics: %v", err)
}
@@ -1484,10 +1487,7 @@ func TestSeedMockMetricsHistory_UsesCanonicalMetricModelForPlatformFixtures(t *t
if len(graph.PlatformFixtures.TrueNAS.Apps) == 0 {
t.Fatal("expected TrueNAS app fixtures")
}
- trueNASAppID := strings.TrimSpace(graph.PlatformFixtures.TrueNAS.Apps[0].ID)
- if trueNASAppID == "" {
- trueNASAppID = strings.TrimSpace(graph.PlatformFixtures.TrueNAS.Apps[0].Name)
- }
+ trueNASAppID := mock.TrueNASAppMetricID(trueNASHost, graph.PlatformFixtures.TrueNAS.Apps[0])
if trueNASAppID == "" {
t.Fatal("expected TrueNAS app identifier")
}
@@ -1715,7 +1715,7 @@ func TestRecordMockStateToMetricsHistory_UsesCanonicalMetricModelForPlatformFixt
if len(graph.PlatformFixtures.TrueNAS.Pools) == 0 {
t.Fatal("expected TrueNAS pool fixtures")
}
- trueNASPoolID := "pool:" + graph.PlatformFixtures.TrueNAS.Pools[0].Name
+ trueNASPoolID := mock.TrueNASPoolMetricID(trueNASHost, graph.PlatformFixtures.TrueNAS.Pools[0].Name)
trueNASPoolMetrics := mh.GetAllStorageMetrics(trueNASPoolID, lookback)
if got, want := trueNASPoolMetrics["usage"][0].Value, mock.SampleMetric("storage", trueNASPoolID, "usage", ts); math.Abs(got-want) > 1e-9 {
t.Fatalf("expected TrueNAS pool usage live tick to use canonical metric model: got=%f want=%f", got, want)
@@ -1724,10 +1724,7 @@ func TestRecordMockStateToMetricsHistory_UsesCanonicalMetricModelForPlatformFixt
if len(graph.PlatformFixtures.TrueNAS.Apps) == 0 {
t.Fatal("expected TrueNAS app fixtures")
}
- trueNASAppID := strings.TrimSpace(graph.PlatformFixtures.TrueNAS.Apps[0].ID)
- if trueNASAppID == "" {
- trueNASAppID = strings.TrimSpace(graph.PlatformFixtures.TrueNAS.Apps[0].Name)
- }
+ trueNASAppID := mock.TrueNASAppMetricID(trueNASHost, graph.PlatformFixtures.TrueNAS.Apps[0])
if trueNASAppID == "" {
t.Fatal("expected TrueNAS app identifier")
}
diff --git a/internal/monitoring/monitor_polling_test.go b/internal/monitoring/monitor_polling_test.go
index 60cd09a84e..b4d04c3e0f 100644
--- a/internal/monitoring/monitor_polling_test.go
+++ b/internal/monitoring/monitor_polling_test.go
@@ -574,11 +574,11 @@ func TestSyncUnifiedAppContainerMetricsRecordsTrueNASHistory(t *testing.T) {
}
target := resourceStore.MetricsTargetForResource(appResourceID)
- if target == nil || target.ResourceType != "app-container" || target.ResourceID != "nextcloud" {
+ if target == nil || target.ResourceType != "app-container" || target.ResourceID != "system:truenas-main/app:nextcloud" {
t.Fatalf("unexpected app-container metrics target %+v", target)
}
- inMemory := monitor.GetGuestMetrics("docker:nextcloud", time.Hour)
+ inMemory := monitor.GetGuestMetrics("docker:system:truenas-main/app:nextcloud", time.Hour)
if got := len(inMemory["cpu"]); got == 0 {
t.Fatalf("expected in-memory cpu history for nextcloud")
}
@@ -586,7 +586,7 @@ func TestSyncUnifiedAppContainerMetricsRecordsTrueNASHistory(t *testing.T) {
t.Fatalf("expected in-memory network history for nextcloud")
}
- storeBacked := monitor.GetGuestMetricsForChart("docker:nextcloud", "dockerContainer", "nextcloud", 7*24*time.Hour)
+ storeBacked := monitor.GetGuestMetricsForChart("docker:system:truenas-main/app:nextcloud", "dockerContainer", "system:truenas-main/app:nextcloud", 7*24*time.Hour)
if got := len(storeBacked["cpu"]); got == 0 {
t.Fatalf("expected persisted cpu history for nextcloud")
}
@@ -625,7 +625,7 @@ func TestSyncUnifiedAppContainerMetricsSkipsMockOwnedTrueNASHistoryWhenMockEnabl
monitor.syncUnifiedAppContainerMetrics(resourceStore)
- if got := len(monitor.GetGuestMetrics("docker:nextcloud", time.Hour)["cpu"]); got != 0 {
+ if got := len(monitor.GetGuestMetrics("docker:system:truenas-main/app:nextcloud", time.Hour)["cpu"]); got != 0 {
t.Fatalf("expected mock-owned TrueNAS app history to be skipped, got %d cpu points", got)
}
}
@@ -983,7 +983,7 @@ func TestSyncUnifiedStorageAndDiskMetricsSkipMockOwnedTrueNASHistoryWhenMockEnab
monitor.syncUnifiedStorageMetrics(resourceStore)
monitor.syncUnifiedPhysicalDiskMetrics(resourceStore)
- if got := len(monitor.GetStorageMetrics("pool:tank", time.Hour)["usage"]); got != 0 {
+ if got := len(monitor.GetStorageMetrics(mock.TrueNASPoolMetricID("truenas-main", "tank"), time.Hour)["usage"]); got != 0 {
t.Fatalf("expected mock-owned TrueNAS storage history to be skipped, got %d usage points", got)
}
diff --git a/internal/truenas/contract_test.go b/internal/truenas/contract_test.go
index f85c245a80..f07759ba3c 100644
--- a/internal/truenas/contract_test.go
+++ b/internal/truenas/contract_test.go
@@ -4,6 +4,7 @@ import (
"math"
"strings"
"testing"
+ "time"
"github.com/rcourtman/pulse-go-rewrite/internal/models"
"github.com/rcourtman/pulse-go-rewrite/internal/unifiedresources"
@@ -163,7 +164,7 @@ func TestRegistryIngestRecordsTreatsTrueNASAsGenericDataSource(t *testing.T) {
t.Fatalf("expected Nextcloud CPU metrics, got %+v", app.Metrics)
}
appTarget := registry.MetricsTarget(app.ID)
- if appTarget == nil || appTarget.ResourceType != "app-container" || appTarget.ResourceID != "nextcloud" {
+ if appTarget == nil || appTarget.ResourceType != "app-container" || appTarget.ResourceID != "system:truenas-main/app:nextcloud" {
t.Fatalf("expected canonical Nextcloud metrics target, got %+v", appTarget)
}
if app.Docker.NetInRate != 2_100_000 || app.Docker.NetOutRate != 1_250_000 {
@@ -251,7 +252,7 @@ func TestRegistryIngestRecordsTreatsTrueNASAsGenericDataSource(t *testing.T) {
}
found := false
for _, target := range targets {
- if target.Source == unifiedresources.SourceTrueNAS && target.SourceID == "dataset:tank/apps" {
+ if target.Source == unifiedresources.SourceTrueNAS && target.SourceID == "system:truenas-main/dataset:tank/apps" {
found = true
break
}
@@ -261,6 +262,76 @@ func TestRegistryIngestRecordsTreatsTrueNASAsGenericDataSource(t *testing.T) {
}
}
+func TestRegistryIngestRecordsScopesTrueNASChildrenPerSystem(t *testing.T) {
+ previous := IsFeatureEnabled()
+ SetFeatureEnabled(true)
+ t.Cleanup(func() {
+ SetFeatureEnabled(previous)
+ })
+
+ first := DefaultFixtures()
+ second := DefaultFixtures()
+ second.System.Hostname = "truenas-backup"
+ second.System.MachineID = "truenas-backup-machine-id"
+ second.System.CollectedAt = second.System.CollectedAt.Add(time.Minute)
+ second.CollectedAt = second.CollectedAt.Add(time.Minute)
+ for i := range second.Disks {
+ second.Disks[i].Serial = strings.TrimSpace(second.Disks[i].Serial) + "-backup"
+ }
+
+ records := append(NewProvider(first).Records(), NewProvider(second).Records()...)
+ registry := unifiedresources.NewRegistry(unifiedresources.NewMemoryStore())
+ registry.IngestRecords(unifiedresources.SourceTrueNAS, records)
+
+ resources := registry.List()
+ systems := resourcesByNameAndType(resources, unifiedresources.ResourceTypeAgent, "")
+ if len(systems) != 2 {
+ t.Fatalf("expected 2 TrueNAS systems, got %d from %+v", len(systems), systems)
+ }
+ if !hasNamedResource(systems, "truenas-main") || !hasNamedResource(systems, "truenas-backup") {
+ t.Fatalf("expected both TrueNAS system resources, got %+v", systems)
+ }
+
+ pools := resourcesByNameAndType(resources, unifiedresources.ResourceTypeStorage, "tank")
+ poolCount := 0
+ poolParents := map[string]struct{}{}
+ for _, pool := range pools {
+ if pool.Storage == nil || pool.Storage.Topology != "pool" {
+ continue
+ }
+ poolCount++
+ if pool.ParentName != "" {
+ poolParents[pool.ParentName] = struct{}{}
+ }
+ }
+ if poolCount != 2 {
+ t.Fatalf("expected duplicate pool names to remain per system, got %d from %+v", poolCount, pools)
+ }
+ if _, ok := poolParents["truenas-main"]; !ok {
+ t.Fatalf("expected tank pool parented to truenas-main, parents=%+v", poolParents)
+ }
+ if _, ok := poolParents["truenas-backup"]; !ok {
+ t.Fatalf("expected tank pool parented to truenas-backup, parents=%+v", poolParents)
+ }
+
+ apps := resourcesByNameAndType(resources, unifiedresources.ResourceTypeAppContainer, "Nextcloud")
+ if len(apps) != 2 {
+ t.Fatalf("expected duplicate app names to remain per system, got %d from %+v", len(apps), apps)
+ }
+ appParents := map[string]struct{}{}
+ for _, app := range apps {
+ if app.ParentName != "" {
+ appParents[app.ParentName] = struct{}{}
+ }
+ }
+ if _, ok := appParents["truenas-main"]; !ok {
+ t.Fatalf("expected Nextcloud app parented to truenas-main, parents=%+v", appParents)
+ }
+ if _, ok := appParents["truenas-backup"]; !ok {
+ t.Fatalf("expected Nextcloud app parented to truenas-backup, parents=%+v", appParents)
+ }
+}
+
func TestTrueNASResourcesFlowThroughUnifiedTypesWithoutSpecialCasing(t *testing.T) {
previous := IsFeatureEnabled()
SetFeatureEnabled(true)
@@ -427,6 +498,29 @@ func requireResource(t *testing.T, resources []unifiedresources.Resource, resour
return nil
}
+func resourcesByNameAndType(resources []unifiedresources.Resource, resourceType unifiedresources.ResourceType, name string) []unifiedresources.Resource {
+ out := make([]unifiedresources.Resource, 0)
+ for _, resource := range resources {
+ if resource.Type != resourceType {
+ continue
+ }
+ if name != "" && resource.Name != name {
+ continue
+ }
+ out = append(out, resource)
+ }
+ return out
+}
+
+func hasNamedResource(resources []unifiedresources.Resource, name string) bool {
+ for _, resource := range resources {
+ if resource.Name == name {
+ return true
+ }
+ }
+ return false
+}
+
func assertSourceTracking(t *testing.T, resource unifiedresources.Resource, source unifiedresources.DataSource) {
t.Helper()
if !containsSource(resource.Sources, source) {
diff --git a/internal/truenas/provider.go b/internal/truenas/provider.go
index 99ba1d2f83..7b086426da 100644
--- a/internal/truenas/provider.go
+++ b/internal/truenas/provider.go
@@ -502,8 +502,9 @@ func truenasRecordsFromSnapshot(snapshot *FixtureSnapshot, now func() time.Time)
assessment := assessPool(pool)
risk := unifiedresources.StorageRiskFromAssessment(assessment)
incidents := poolIncidents[strings.TrimSpace(pool.Name)]
+ poolSourceID := scopedPoolSourceID(systemSourceID, pool.Name)
records = append(records, unifiedresources.IngestRecord{
- SourceID: poolSourceID(pool.Name),
+ SourceID: poolSourceID,
ParentSourceID: systemSourceID,
Resource: unifiedresources.Resource{
Type: unifiedresources.ResourceTypeStorage,
@@ -547,8 +548,8 @@ func truenasRecordsFromSnapshot(snapshot *FixtureSnapshot, now func() time.Time)
}
totalBytes := dataset.UsedBytes + dataset.AvailBytes
records = append(records, unifiedresources.IngestRecord{
- SourceID: datasetSourceID(dataset.Name),
- ParentSourceID: poolSourceID(parentPool),
+ SourceID: scopedDatasetSourceID(systemSourceID, dataset.Name),
+ ParentSourceID: scopedPoolSourceID(systemSourceID, parentPool),
Resource: unifiedresources.Resource{
Type: unifiedresources.ResourceTypeStorage,
Name: dataset.Name,
@@ -614,7 +615,7 @@ func truenasRecordsFromSnapshot(snapshot *FixtureSnapshot, now func() time.Time)
}
records = append(records, unifiedresources.IngestRecord{
- SourceID: appSourceID(app.ID),
+ SourceID: scopedAppSourceID(systemSourceID, app),
ParentSourceID: systemSourceID,
Resource: unifiedresources.Resource{
Type: unifiedresources.ResourceTypeAppContainer,
@@ -640,7 +641,7 @@ func truenasRecordsFromSnapshot(snapshot *FixtureSnapshot, now func() time.Time)
for _, vm := range snapshot.VMs {
records = append(records, unifiedresources.IngestRecord{
- SourceID: virtualMachineSourceID(vm),
+ SourceID: scopedVirtualMachineSourceID(systemSourceID, vm),
ParentSourceID: systemSourceID,
Resource: unifiedresources.Resource{
Type: unifiedresources.ResourceTypeVM,
@@ -667,12 +668,12 @@ func truenasRecordsFromSnapshot(snapshot *FixtureSnapshot, now func() time.Time)
for _, share := range snapshot.Shares {
parentSourceID := systemSourceID
if dataset := strings.TrimSpace(share.Dataset); dataset != "" {
- parentSourceID = datasetSourceID(dataset)
+ parentSourceID = scopedDatasetSourceID(systemSourceID, dataset)
} else if pool := poolFromSharePath(share.Path); pool != "" {
- parentSourceID = poolSourceID(pool)
+ parentSourceID = scopedPoolSourceID(systemSourceID, pool)
}
records = append(records, unifiedresources.IngestRecord{
- SourceID: networkShareSourceID(share),
+ SourceID: scopedNetworkShareSourceID(systemSourceID, share),
ParentSourceID: parentSourceID,
Resource: unifiedresources.Resource{
Type: unifiedresources.ResourceTypeNetworkShare,
@@ -704,9 +705,13 @@ func truenasRecordsFromSnapshot(snapshot *FixtureSnapshot, now func() time.Time)
if disk.Serial != "" {
diskIdentity.MachineID = disk.Serial
}
+ parentSourceID := systemSourceID
+ if pool := strings.TrimSpace(disk.Pool); pool != "" {
+ parentSourceID = scopedPoolSourceID(systemSourceID, pool)
+ }
records = append(records, unifiedresources.IngestRecord{
- SourceID: diskSourceID(disk.Name),
- ParentSourceID: poolSourceID(disk.Pool),
+ SourceID: scopedDiskSourceID(systemSourceID, disk.Name),
+ ParentSourceID: parentSourceID,
Resource: unifiedresources.Resource{
Type: unifiedresources.ResourceTypePhysicalDisk,
Name: disk.Name,
@@ -1258,12 +1263,28 @@ func poolSourceID(pool string) string {
return "pool:" + strings.TrimSpace(pool)
}
+func scopedPoolSourceID(systemSourceID, pool string) string {
+ return scopedTrueNASSourceID(systemSourceID, poolSourceID(pool))
+}
+
func datasetSourceID(dataset string) string {
return "dataset:" + strings.TrimSpace(dataset)
}
-func appSourceID(id string) string {
- return "app:" + strings.TrimSpace(id)
+func scopedDatasetSourceID(systemSourceID, dataset string) string {
+ return scopedTrueNASSourceID(systemSourceID, datasetSourceID(dataset))
+}
+
+func appSourceID(app App) string {
+ id := strings.TrimSpace(app.ID)
+ if id == "" {
+ id = appDisplayName(app)
+ }
+ return "app:" + id
+}
+
+func scopedAppSourceID(systemSourceID string, app App) string {
+ return scopedTrueNASSourceID(systemSourceID, appSourceID(app))
}
func virtualMachineSourceID(vm VirtualMachine) string {
@@ -1273,6 +1294,10 @@ func virtualMachineSourceID(vm VirtualMachine) string {
return "vm:" + virtualMachineDisplayName(vm)
}
+func scopedVirtualMachineSourceID(systemSourceID string, vm VirtualMachine) string {
+ return scopedTrueNASSourceID(systemSourceID, virtualMachineSourceID(vm))
+}
+
func networkShareSourceID(share NetworkShare) string {
protocol := strings.ToLower(strings.TrimSpace(share.Protocol))
if protocol == "" {
@@ -1288,10 +1313,36 @@ func networkShareSourceID(share NetworkShare) string {
return "share:" + protocol + ":" + stable
}
+func scopedNetworkShareSourceID(systemSourceID string, share NetworkShare) string {
+ return scopedTrueNASSourceID(systemSourceID, networkShareSourceID(share))
+}
+
func diskSourceID(name string) string {
return "disk:" + strings.TrimSpace(name)
}
+func scopedDiskSourceID(systemSourceID, name string) string {
+ return scopedTrueNASSourceID(systemSourceID, diskSourceID(name))
+}
+
+// TrueNAS resource names are appliance-local. Scope child source IDs under the
+// system source key so common names such as "tank" and "nextcloud" do not merge
+// across configured TrueNAS appliances.
+func scopedTrueNASSourceID(systemSourceID, sourceID string) string {
+ systemSourceID = strings.TrimSpace(systemSourceID)
+ sourceID = strings.TrimSpace(sourceID)
+ if sourceID == "" {
+ return systemSourceID
+ }
+ if systemSourceID == "" {
+ return sourceID
+ }
+ if strings.HasPrefix(sourceID, systemSourceID+"/") {
+ return sourceID
+ }
+ return systemSourceID + "/" + sourceID
+}
+
func appDisplayName(app App) string {
if name := strings.TrimSpace(app.Name); name != "" {
return name
diff --git a/internal/truenas/provider_additional_test.go b/internal/truenas/provider_additional_test.go
index edb73f0ecf..99b5922bab 100644
--- a/internal/truenas/provider_additional_test.go
+++ b/internal/truenas/provider_additional_test.go
@@ -49,8 +49,8 @@ func TestRecordsParentPoolFallsBackToDatasetName(t *testing.T) {
if record.Resource.Name != "tank/apps" {
continue
}
- if record.ParentSourceID != "pool:tank" {
- t.Fatalf("expected dataset parent source id pool:tank, got %q", record.ParentSourceID)
+ if record.ParentSourceID != "system:truenas-main/pool:tank" {
+ t.Fatalf("expected dataset parent source id system:truenas-main/pool:tank, got %q", record.ParentSourceID)
}
return
}
diff --git a/internal/truenas/provider_test.go b/internal/truenas/provider_test.go
index 10611bee64..e368ee9bf2 100644
--- a/internal/truenas/provider_test.go
+++ b/internal/truenas/provider_test.go
@@ -584,8 +584,8 @@ func TestRecordsIncludeDiskResourcesWithCorrectParentChain(t *testing.T) {
t.Fatalf("expected to find disk records for sda, nvme0n1, and sdc")
}
- if sda.ParentSourceID != "pool:tank" {
- t.Fatalf("expected sda parent pool:tank, got %q", sda.ParentSourceID)
+ if sda.ParentSourceID != "system:truenas-main/pool:tank" {
+ t.Fatalf("expected sda parent system:truenas-main/pool:tank, got %q", sda.ParentSourceID)
}
if sda.Resource.PhysicalDisk == nil {
t.Fatal("expected sda PhysicalDiskMeta")
@@ -612,8 +612,8 @@ func TestRecordsIncludeDiskResourcesWithCorrectParentChain(t *testing.T) {
t.Fatalf("expected sda identity hostname [truenas-main], got %v", sda.Identity.Hostnames)
}
- if nvme0n1.ParentSourceID != "pool:fast" {
- t.Fatalf("expected nvme0n1 parent pool:fast, got %q", nvme0n1.ParentSourceID)
+ if nvme0n1.ParentSourceID != "system:truenas-main/pool:fast" {
+ t.Fatalf("expected nvme0n1 parent system:truenas-main/pool:fast, got %q", nvme0n1.ParentSourceID)
}
if nvme0n1.Resource.PhysicalDisk == nil {
t.Fatal("expected nvme0n1 PhysicalDiskMeta")