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 boot and replication health classification

rcourtmand7793a255dbc
diff --git a/docs/release-control/v6/internal/subsystems/monitoring.md b/docs/release-control/v6/internal/subsystems/monitoring.md
index 99c6d475d5..5099813769 100644
--- a/docs/release-control/v6/internal/subsystems/monitoring.md
+++ b/docs/release-control/v6/internal/subsystems/monitoring.md
@@ -402,6 +402,19 @@ resource health.
the canonical pool resource when `alert.list` does not already provide a
warning or critical pool alert for that same pool, so pool degradation does
not depend on the TrueNAS appliance's own email or alert-delivery setup.
+ Boot-pool inventory follows the separate `boot.get_state` contract because
+ `pool.query` is not a reliable boot-topology source across supported CORE
+ and SCALE releases. The client must merge that state into the
+ connection-local pool list, preserve the boot-pool role, and derive
+ path-only leaf devices without matching pool or disk identities across
+ configured appliances.
+ Read-only dataset health must retain replication intent from
+ `replication.query`: `SET` and `REQUIRE` target roots may normalize
+ receive-side read-only datasets and descendants only after the poller maps a
+ local/PULL task or uniquely matches a remote PUSH target host to one
+ configured connection. Missing or ambiguous remote identity fails closed,
+ `IGNORE` never normalizes read-only state, and locked, unmounted, pool
+ failure, disk failure, or unavailable state remains fault-bearing.
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
@@ -1556,6 +1569,18 @@ null, empty, missing, unknown, or unavailable SMART telemetry to canonical
`UNKNOWN` health with no replacement-required risk. Explicit SMART failure and
native failure states such as `FAULTED`, `FAILED`, `OFFLINE`, `REMOVED`, and
`UNAVAIL` must continue to produce canonical disk-health risk.
+That same boundary owns boot-pool and replication-target storage posture.
+`internal/truenas/client.go` must collect `boot.get_state` with the legacy REST
+bridge as compatibility fallback, merge it only within the current configured
+connection, and use its vdev leaves to enrich boot-disk pool membership and
+native ZFS state. `internal/monitoring/truenas_poller.go` must correlate
+`replication.query` intent across providers within the same organization using
+local/PULL ownership or a unique configured/observed target-host match for
+remote PUSH tasks. The resulting `SET`/`REQUIRE` receive-side read-only posture
+is healthy, while ordinary read-only datasets remain warning and locked or
+unmounted datasets remain offline. Correlation must fail closed when target
+identity is absent or ambiguous, and common pool or dataset names on another
+connection are never sufficient identity.
That same boundary now also owns recent aggregate TrueNAS disk temperature
history. `internal/truenas/client.go` must ingest `disk.temperature_agg`, and
`internal/truenas/provider.go` must project the returned min/avg/max readings
diff --git a/frontend-modern/src/features/truenas/__tests__/truenasPageModel.test.ts b/frontend-modern/src/features/truenas/__tests__/truenasPageModel.test.ts
index 3f1d9a30a8..4147d7103a 100644
--- a/frontend-modern/src/features/truenas/__tests__/truenasPageModel.test.ts
+++ b/frontend-modern/src/features/truenas/__tests__/truenasPageModel.test.ts
@@ -582,6 +582,22 @@ describe('truenasPageModel', () => {
expect(mapTrueNASStorageStatus(healthyByState)).toBe('healthy');
});
+ it('renders expected receive-side replication readonly posture as healthy', () => {
+ const replicatedDataset = makeResource({
+ id: 'dataset-replica',
+ type: 'storage',
+ name: 'backup/replicas',
+ status: 'online',
+ tags: ['truenas', 'dataset', 'zfs', 'state:replication-readonly'],
+ storage: { topology: 'dataset', platform: 'truenas' },
+ });
+
+ expect(mapTrueNASStorageStatus(replicatedDataset)).toBe('healthy');
+ const row = buildTrueNASStorageTopologyRows([replicatedDataset])[0];
+ expect(row?.kind).toBe('dataset');
+ expect(row && mapTrueNASStorageStatus(row.resource)).toBe('healthy');
+ });
+
it('filters apps using native TrueNAS app.query metadata', () => {
const nextcloud = makeResource({
id: 'app-nextcloud',
diff --git a/internal/monitoring/truenas_poller.go b/internal/monitoring/truenas_poller.go
index 1c537bf9a9..14e95abf9e 100644
--- a/internal/monitoring/truenas_poller.go
+++ b/internal/monitoring/truenas_poller.go
@@ -99,6 +99,12 @@ type trueNASPollerProviderEntry struct {
provider *truenas.Provider
}
+type trueNASReplicationConnection struct {
+ connectionID string
+ configuredHost string
+ snapshot *truenas.FixtureSnapshot
+}
+
// NewTrueNASPoller builds a new TrueNAS poller with the provided poll interval.
func NewTrueNASPoller(multiTenant *config.MultiTenantPersistence, interval time.Duration, recoveryManager *recoverymanager.Manager) *TrueNASPoller {
explicitInterval := interval > 0
@@ -461,6 +467,7 @@ func (p *TrueNASPoller) pollAll(ctx context.Context) {
p.mu.Unlock()
pm := getPollMetrics()
+ refreshedOrgs := make(map[string]struct{})
for _, entry := range entries {
if entry.provider == nil {
@@ -503,26 +510,206 @@ func (p *TrueNASPoller) pollAll(ctx context.Context) {
p.mu.Lock()
p.recordConnectionSuccessLocked(entry.orgID, entry.id, entry.config, end, snapshot)
p.mu.Unlock()
+ refreshedOrgs[entry.orgID] = struct{}{}
+ p.ingestRecoveryPoints(ctx, entry.orgID, entry.id, entry.provider)
+ }
- records := entry.provider.Records()
- if len(records) == 0 {
- p.mu.Lock()
- if p.cachedRecordsByOrg[entry.orgID] == nil {
- p.cachedRecordsByOrg[entry.orgID] = make(map[string][]unifiedresources.IngestRecord)
+ for orgID := range refreshedOrgs {
+ p.rebuildCachedRecordsForOrg(orgID)
+ }
+}
+
+func (p *TrueNASPoller) rebuildCachedRecordsForOrg(orgID string) {
+ if p == nil {
+ return
+ }
+
+ p.mu.Lock()
+ providers := p.providersByOrg[orgID]
+ type providerSelection struct {
+ connectionID string
+ configuredHost string
+ provider *truenas.Provider
+ }
+ selections := make([]providerSelection, 0, len(providers))
+ providersByConnection := make(map[string]*truenas.Provider, len(providers))
+ for connectionID, provider := range providers {
+ if provider == nil {
+ continue
+ }
+ instance := p.configsByOrg[orgID][connectionID]
+ selections = append(selections, providerSelection{
+ connectionID: connectionID,
+ configuredHost: instance.Host,
+ provider: provider,
+ })
+ providersByConnection[connectionID] = provider
+ }
+ p.mu.Unlock()
+
+ connections := make([]trueNASReplicationConnection, 0, len(selections))
+ for _, selection := range selections {
+ connections = append(connections, trueNASReplicationConnection{
+ connectionID: selection.connectionID,
+ configuredHost: selection.configuredHost,
+ snapshot: selection.provider.Snapshot(),
+ })
+ }
+
+ targetsByConnection := expectedTrueNASReplicationReadOnlyTargets(connections)
+ recordsByConnection := make(map[string][]unifiedresources.IngestRecord, len(connections))
+ for _, connection := range connections {
+ provider := providersByConnection[connection.connectionID]
+ classified := applyTrueNASReplicationReadOnlyTargets(
+ connection.snapshot,
+ targetsByConnection[connection.connectionID],
+ )
+ recordsByConnection[connection.connectionID] = provider.RecordsFromSnapshot(classified)
+ }
+
+ p.mu.Lock()
+ if p.cachedRecordsByOrg[orgID] == nil {
+ p.cachedRecordsByOrg[orgID] = make(map[string][]unifiedresources.IngestRecord)
+ }
+ for connectionID, records := range recordsByConnection {
+ // A concurrent settings update may have replaced or removed a
+ // provider while snapshots were classified outside the lock.
+ if p.providersByOrg[orgID][connectionID] != providersByConnection[connectionID] {
+ continue
+ }
+ p.cachedRecordsByOrg[orgID][connectionID] = cloneIngestRecords(records)
+ }
+ p.mu.Unlock()
+}
+
+func expectedTrueNASReplicationReadOnlyTargets(connections []trueNASReplicationConnection) map[string][]string {
+ aliases := make(map[string][]string)
+ for _, connection := range connections {
+ for _, alias := range dedupeTrueNASStrings([]string{
+ normalizeTrueNASHost(connection.configuredHost),
+ normalizeTrueNASHost(snapshotTrueNASHostname(connection.snapshot)),
+ }) {
+ aliases[alias] = append(aliases[alias], connection.connectionID)
+ }
+ }
+
+ targetSets := make(map[string]map[string]struct{})
+ addTarget := func(connectionID, dataset string) {
+ connectionID = strings.TrimSpace(connectionID)
+ dataset = strings.Trim(strings.TrimSpace(dataset), "/")
+ if connectionID == "" || dataset == "" {
+ return
+ }
+ if targetSets[connectionID] == nil {
+ targetSets[connectionID] = make(map[string]struct{})
+ }
+ targetSets[connectionID][dataset] = struct{}{}
+ }
+
+ for _, connection := range connections {
+ if connection.snapshot == nil {
+ continue
+ }
+ for _, task := range connection.snapshot.ReplicationTasks {
+ switch strings.ToUpper(strings.TrimSpace(task.ReadOnlyMode)) {
+ case "SET", "REQUIRE":
+ default:
+ continue
}
- p.cachedRecordsByOrg[entry.orgID][entry.id] = nil
- p.mu.Unlock()
+
+ direction := strings.ToUpper(strings.TrimSpace(task.Direction))
+ transport := strings.ToUpper(strings.TrimSpace(task.Transport))
+ switch {
+ case direction == "PULL" || transport == "LOCAL":
+ addTarget(connection.connectionID, task.TargetDataset)
+ case direction == "PUSH":
+ targetHost := normalizeTrueNASHost(task.TargetHost)
+ candidates := dedupeTrueNASStrings(aliases[targetHost])
+ if targetHost == "" || len(candidates) != 1 {
+ continue
+ }
+ addTarget(candidates[0], task.TargetDataset)
+ }
+ }
+ }
+
+ targets := make(map[string][]string, len(targetSets))
+ for connectionID, set := range targetSets {
+ for dataset := range set {
+ targets[connectionID] = append(targets[connectionID], dataset)
+ }
+ sort.Strings(targets[connectionID])
+ }
+ return targets
+}
+
+func applyTrueNASReplicationReadOnlyTargets(snapshot *truenas.FixtureSnapshot, targets []string) *truenas.FixtureSnapshot {
+ if snapshot == nil {
+ return nil
+ }
+ classified := *snapshot
+ classified.Datasets = append([]truenas.Dataset(nil), snapshot.Datasets...)
+ for i := range classified.Datasets {
+ if !classified.Datasets[i].ReadOnly {
continue
}
- p.mu.Lock()
- if p.cachedRecordsByOrg[entry.orgID] == nil {
- p.cachedRecordsByOrg[entry.orgID] = make(map[string][]unifiedresources.IngestRecord)
+ dataset := strings.Trim(strings.TrimSpace(classified.Datasets[i].Name), "/")
+ for _, target := range targets {
+ target = strings.Trim(strings.TrimSpace(target), "/")
+ if target != "" && (dataset == target || strings.HasPrefix(dataset, target+"/")) {
+ classified.Datasets[i].ReadOnlyReason = truenas.DatasetReadOnlyReplicationTarget
+ break
+ }
}
- p.cachedRecordsByOrg[entry.orgID][entry.id] = cloneIngestRecords(records)
- p.mu.Unlock()
+ }
+ return &classified
+}
- p.ingestRecoveryPoints(ctx, entry.orgID, entry.id, entry.provider)
+func snapshotTrueNASHostname(snapshot *truenas.FixtureSnapshot) string {
+ if snapshot == nil {
+ return ""
}
+ return snapshot.System.Hostname
+}
+
+func normalizeTrueNASHost(raw string) string {
+ raw = strings.TrimSpace(raw)
+ if raw == "" {
+ return ""
+ }
+ candidate := raw
+ if !strings.Contains(candidate, "://") {
+ candidate = "//" + candidate
+ }
+ if parsed, err := url.Parse(candidate); err == nil {
+ if hostname := parsed.Hostname(); hostname != "" {
+ return strings.TrimSuffix(strings.ToLower(hostname), ".")
+ }
+ }
+ if host, _, err := net.SplitHostPort(raw); err == nil {
+ raw = host
+ }
+ return strings.TrimSuffix(strings.ToLower(strings.Trim(raw, "[]")), ".")
+}
+
+func dedupeTrueNASStrings(values []string) []string {
+ if len(values) == 0 {
+ return nil
+ }
+ seen := make(map[string]struct{}, len(values))
+ out := make([]string, 0, len(values))
+ for _, value := range values {
+ value = strings.TrimSpace(value)
+ if value == "" {
+ continue
+ }
+ if _, exists := seen[value]; exists {
+ continue
+ }
+ seen[value] = struct{}{}
+ out = append(out, value)
+ }
+ return out
}
type trueNASConnectionRuntimeSnapshot struct {
@@ -1113,13 +1300,7 @@ func (p *TrueNASPoller) ControlApp(ctx context.Context, orgID, host, appID, acti
return nil, err
}
- records := entry.provider.Records()
- p.mu.Lock()
- if p.cachedRecordsByOrg[orgID] == nil {
- p.cachedRecordsByOrg[orgID] = make(map[string][]unifiedresources.IngestRecord)
- }
- p.cachedRecordsByOrg[orgID][entry.connectionID] = cloneIngestRecords(records)
- p.mu.Unlock()
+ p.rebuildCachedRecordsForOrg(orgID)
p.ingestRecoveryPoints(ctx, orgID, entry.connectionID, entry.provider)
if updatedApp, ok := findTrueNASAppSnapshot(nextSnapshot, host, appID); ok {
diff --git a/internal/monitoring/truenas_poller_test.go b/internal/monitoring/truenas_poller_test.go
index 044e3b9e9f..76df5eac79 100644
--- a/internal/monitoring/truenas_poller_test.go
+++ b/internal/monitoring/truenas_poller_test.go
@@ -700,6 +700,193 @@ func TestTrueNASPollerControlAppRefreshesCachedRecords(t *testing.T) {
}
}
+func TestExpectedTrueNASReplicationReadOnlyTargetsAreConnectionScoped(t *testing.T) {
+ connections := []trueNASReplicationConnection{
+ {
+ connectionID: "sender",
+ configuredHost: "https://sender.example.test",
+ snapshot: &truenas.FixtureSnapshot{
+ System: truenas.SystemInfo{Hostname: "sender"},
+ ReplicationTasks: []truenas.ReplicationTask{{
+ ID: "7",
+ Direction: "PUSH",
+ Transport: "SSH",
+ ReadOnlyMode: "SET",
+ TargetHost: "backup.example.test",
+ SourceDatasets: []string{"tank/apps", "tank/vms"},
+ TargetDataset: "backup/replicas",
+ }},
+ },
+ },
+ {
+ connectionID: "receiver",
+ configuredHost: "https://backup.example.test:443",
+ snapshot: &truenas.FixtureSnapshot{
+ System: truenas.SystemInfo{Hostname: "backup"},
+ Datasets: []truenas.Dataset{
+ {Name: "backup/replicas", Mounted: true, ReadOnly: true},
+ {Name: "backup/replicas/apps", Mounted: true, ReadOnly: true},
+ },
+ },
+ },
+ {
+ connectionID: "same-dataset-name-on-another-system",
+ configuredHost: "https://unrelated.example.test",
+ snapshot: &truenas.FixtureSnapshot{
+ System: truenas.SystemInfo{Hostname: "unrelated"},
+ Datasets: []truenas.Dataset{
+ {Name: "backup/replicas", Mounted: true, ReadOnly: true},
+ },
+ },
+ },
+ }
+
+ targets := expectedTrueNASReplicationReadOnlyTargets(connections)
+ if got := targets["receiver"]; len(got) != 1 || got[0] != "backup/replicas" {
+ t.Fatalf("expected receiver target root, got %#v", targets)
+ }
+ if got := targets["same-dataset-name-on-another-system"]; len(got) != 0 {
+ t.Fatalf("dataset names must not correlate across unmatched connections, got %#v", targets)
+ }
+}
+
+func TestExpectedTrueNASReplicationReadOnlyTargetsFailClosed(t *testing.T) {
+ connections := []trueNASReplicationConnection{
+ {
+ connectionID: "sender",
+ configuredHost: "https://sender.example.test",
+ snapshot: &truenas.FixtureSnapshot{
+ ReplicationTasks: []truenas.ReplicationTask{
+ {ID: "set-without-host", Direction: "PUSH", Transport: "SSH", ReadOnlyMode: "SET", TargetDataset: "backup/a"},
+ {ID: "set-ambiguous-host", Direction: "PUSH", Transport: "SSH", ReadOnlyMode: "SET", TargetHost: "backup.example.test", TargetDataset: "backup/a"},
+ {ID: "ignored", Direction: "PUSH", Transport: "SSH", ReadOnlyMode: "IGNORE", TargetHost: "backup.example.test", TargetDataset: "backup/b"},
+ },
+ },
+ },
+ {connectionID: "receiver-a", configuredHost: "https://backup.example.test", snapshot: &truenas.FixtureSnapshot{}},
+ {connectionID: "receiver-b", configuredHost: "https://backup.example.test:443", snapshot: &truenas.FixtureSnapshot{}},
+ }
+
+ if targets := expectedTrueNASReplicationReadOnlyTargets(connections); len(targets) != 0 {
+ t.Fatalf("ambiguous, hostless, and IGNORE tasks must fail closed, got %#v", targets)
+ }
+}
+
+func TestExpectedTrueNASReplicationReadOnlyTargetsSupportLocalAndPullTasks(t *testing.T) {
+ connections := []trueNASReplicationConnection{{
+ connectionID: "nas",
+ configuredHost: "https://nas.example.test",
+ snapshot: &truenas.FixtureSnapshot{
+ ReplicationTasks: []truenas.ReplicationTask{
+ {ID: "pull", Direction: "PULL", Transport: "SSH", ReadOnlyMode: "REQUIRE", TargetDataset: "tank/pull-replica"},
+ {ID: "local", Direction: "PUSH", Transport: "LOCAL", ReadOnlyMode: "SET", TargetDataset: "tank/local-replica"},
+ },
+ },
+ }}
+
+ targets := expectedTrueNASReplicationReadOnlyTargets(connections)
+ got := targets["nas"]
+ if len(got) != 2 || got[0] != "tank/local-replica" || got[1] != "tank/pull-replica" {
+ t.Fatalf("expected sorted local targets, got %#v", targets)
+ }
+}
+
+func TestApplyTrueNASReplicationReadOnlyTargetsPreservesFaultStates(t *testing.T) {
+ snapshot := &truenas.FixtureSnapshot{
+ Datasets: []truenas.Dataset{
+ {Name: "backup/replicas", Mounted: true, ReadOnly: true},
+ {Name: "backup/replicas/apps", Mounted: true, ReadOnly: true},
+ {Name: "backup/replicas/locked", Mounted: false, Locked: true, ReadOnly: true},
+ {Name: "backup/unrelated", Mounted: true, ReadOnly: true},
+ },
+ }
+
+ classified := applyTrueNASReplicationReadOnlyTargets(snapshot, []string{"backup/replicas"})
+ if classified.Datasets[0].ReadOnlyReason != truenas.DatasetReadOnlyReplicationTarget ||
+ classified.Datasets[1].ReadOnlyReason != truenas.DatasetReadOnlyReplicationTarget {
+ t.Fatalf("expected root and descendants to carry replication posture: %+v", classified.Datasets)
+ }
+ if classified.Datasets[2].ReadOnlyReason != truenas.DatasetReadOnlyReplicationTarget || !classified.Datasets[2].Locked {
+ t.Fatalf("expected lock state to survive classification: %+v", classified.Datasets[2])
+ }
+ if classified.Datasets[3].ReadOnlyReason != truenas.DatasetReadOnlyUnspecified {
+ t.Fatalf("unexpected unrelated dataset classification: %+v", classified.Datasets[3])
+ }
+}
+
+func TestTrueNASPollerRebuildProjectsReplicationReadonlyOnlyOnMatchedReceiver(t *testing.T) {
+ previous := truenas.IsFeatureEnabled()
+ truenas.SetFeatureEnabled(true)
+ t.Cleanup(func() { truenas.SetFeatureEnabled(previous) })
+
+ newProvider := func(connectionID string, snapshot truenas.FixtureSnapshot) *truenas.Provider {
+ t.Helper()
+ provider := truenas.NewLiveProviderForConnection(&truenas.FixtureFetcher{Snapshot: snapshot}, connectionID)
+ if err := provider.Refresh(context.Background()); err != nil {
+ t.Fatalf("Refresh(%s) error = %v", connectionID, err)
+ }
+ return provider
+ }
+
+ sender := newProvider("sender", truenas.FixtureSnapshot{
+ System: truenas.SystemInfo{Hostname: "sender", Healthy: true},
+ ReplicationTasks: []truenas.ReplicationTask{{
+ ID: "7",
+ Direction: "PUSH",
+ Transport: "SSH",
+ ReadOnlyMode: "SET",
+ TargetHost: "backup.example.test",
+ TargetDataset: "backup/replicas",
+ }},
+ })
+ receiver := newProvider("receiver", truenas.FixtureSnapshot{
+ System: truenas.SystemInfo{Hostname: "backup", Healthy: true},
+ Pools: []truenas.Pool{{Name: "backup", Status: "ONLINE"}},
+ Datasets: []truenas.Dataset{{Name: "backup/replicas", Pool: "backup", Mounted: true, ReadOnly: true}},
+ })
+ unrelated := newProvider("unrelated", truenas.FixtureSnapshot{
+ System: truenas.SystemInfo{Hostname: "unrelated", Healthy: true},
+ Pools: []truenas.Pool{{Name: "backup", Status: "ONLINE"}},
+ Datasets: []truenas.Dataset{{Name: "backup/replicas", Pool: "backup", Mounted: true, ReadOnly: true}},
+ })
+
+ poller := NewTrueNASPoller(nil, time.Minute, nil)
+ poller.providersByOrg["default"] = map[string]*truenas.Provider{
+ "sender": sender,
+ "receiver": receiver,
+ "unrelated": unrelated,
+ }
+ poller.configsByOrg["default"] = map[string]config.TrueNASInstance{
+ "sender": {ID: "sender", Host: "sender.example.test"},
+ "receiver": {ID: "receiver", Host: "backup.example.test"},
+ "unrelated": {ID: "unrelated", Host: "unrelated.example.test"},
+ }
+
+ poller.rebuildCachedRecordsForOrg("default")
+
+ assertDataset := func(connectionID string, wantStatus unifiedresources.ResourceStatus, wantTag string) {
+ t.Helper()
+ for _, record := range poller.cachedRecordsByOrg["default"][connectionID] {
+ if record.Resource.Name != "backup/replicas" {
+ continue
+ }
+ if record.Resource.Status != wantStatus {
+ t.Fatalf("%s dataset status = %q, want %q", connectionID, record.Resource.Status, wantStatus)
+ }
+ for _, tag := range record.Resource.Tags {
+ if tag == wantTag {
+ return
+ }
+ }
+ t.Fatalf("%s dataset tags = %v, want %q", connectionID, record.Resource.Tags, wantTag)
+ }
+ t.Fatalf("%s dataset record not found", connectionID)
+ }
+
+ assertDataset("receiver", unifiedresources.StatusOnline, "state:replication-readonly")
+ assertDataset("unrelated", unifiedresources.StatusWarning, "state:readonly")
+}
+
func TestTrueNASPollerReadAppLogsUsesTenantScopedProvider(t *testing.T) {
previous := truenas.IsFeatureEnabled()
truenas.SetFeatureEnabled(true)
diff --git a/internal/truenas/client.go b/internal/truenas/client.go
index 1da4036b5d..9a868b21b2 100644
--- a/internal/truenas/client.go
+++ b/internal/truenas/client.go
@@ -279,6 +279,110 @@ func (c *Client) getPoolsRPC(ctx context.Context) ([]Pool, error) {
return pools, nil
}
+// GetBootPool returns the boot pool from boot.get_state. The endpoint is
+// separate from pool.query on supported CORE and SCALE releases.
+func (c *Client) GetBootPool(ctx context.Context) (*Pool, error) {
+ var response map[string]any
+ rpcErr := c.callRPC(ctx, "boot.get_state", []any{}, &response)
+ if rpcErr == nil {
+ if pool, ok := parseBootPoolState(response); ok {
+ return &pool, nil
+ }
+ rpcErr = fmt.Errorf("boot.get_state returned no boot pool identity")
+ }
+
+ response = nil
+ if restErr := c.getJSON(ctx, http.MethodGet, "/boot/get_state", &response); restErr != nil {
+ return nil, fmt.Errorf("fetch truenas boot pool via rpc and rest: rpc=%w rest=%v", rpcErr, restErr)
+ }
+ if pool, ok := parseBootPoolState(response); ok {
+ return &pool, nil
+ }
+ return nil, fmt.Errorf("boot/get_state returned no boot pool identity")
+}
+
+func parseBootPoolState(item map[string]any) (Pool, bool) {
+ if len(item) == 0 {
+ return Pool{}, false
+ }
+ name := strings.TrimSpace(readStringAny(item, "name", "id"))
+ id := strings.TrimSpace(readStringAny(item, "id", "name"))
+ if name == "" {
+ name = id
+ }
+ if id == "" || id == "0" {
+ id = name
+ }
+ if name == "" {
+ return Pool{}, false
+ }
+
+ status := strings.TrimSpace(readStringAny(item, "status", "state"))
+ if status == "" && readBoolAny(item, "healthy") {
+ status = "ONLINE"
+ }
+ properties := readMapAny(item, "properties")
+ topology := item["topology"]
+ if topology == nil {
+ topology = item["groups"]
+ }
+
+ pool := Pool{
+ ID: id,
+ Name: name,
+ Status: status,
+ TotalBytes: readInt64Any(item, "size", "total", "total_bytes", "totalBytes"),
+ UsedBytes: readInt64Any(item, "allocated", "used", "used_bytes", "usedBytes"),
+ FreeBytes: readInt64Any(item, "free", "free_bytes", "freeBytes", "available"),
+ IsBoot: true,
+ DiskMembers: poolDiskMembersFromTopology(topology),
+ }
+ if pool.TotalBytes == 0 {
+ pool.TotalBytes = readInt64Any(properties, "size", "total", "total_bytes", "totalBytes")
+ }
+ if pool.UsedBytes == 0 {
+ pool.UsedBytes = readInt64Any(properties, "allocated", "used", "used_bytes", "usedBytes")
+ }
+ if pool.FreeBytes == 0 {
+ pool.FreeBytes = readInt64Any(properties, "free", "free_bytes", "freeBytes", "available")
+ }
+ return pool, true
+}
+
+func mergeBootPool(pools []Pool, boot Pool) []Pool {
+ bootID := strings.TrimSpace(boot.ID)
+ bootName := strings.TrimSpace(boot.Name)
+ for i := range pools {
+ poolID := strings.TrimSpace(pools[i].ID)
+ poolName := strings.TrimSpace(pools[i].Name)
+ if (bootID == "" || poolID == "" || bootID != poolID) &&
+ (bootName == "" || poolName == "" || bootName != poolName) {
+ continue
+ }
+ pools[i].IsBoot = true
+ if boot.Status != "" {
+ pools[i].Status = boot.Status
+ }
+ if boot.TotalBytes > 0 {
+ pools[i].TotalBytes = boot.TotalBytes
+ pools[i].UsedBytes = boot.UsedBytes
+ pools[i].FreeBytes = boot.FreeBytes
+ } else {
+ if boot.UsedBytes > 0 {
+ pools[i].UsedBytes = boot.UsedBytes
+ }
+ if boot.FreeBytes > 0 {
+ pools[i].FreeBytes = boot.FreeBytes
+ }
+ }
+ if len(boot.DiskMembers) > 0 {
+ pools[i].DiskMembers = append([]PoolDiskMember(nil), boot.DiskMembers...)
+ }
+ return pools
+ }
+ return append(pools, boot)
+}
+
// poolDiskMembersFromTopology collects the leaf disks of a pool.query
// topology object across every vdev group, including detached/unavailable
// members that only appear through their unavail_disk datastore row.
@@ -307,6 +411,9 @@ func poolDiskMembersFromTopology(topology any) []PoolDiskMember {
Device: strings.TrimSpace(readStringAny(vdev, "device")),
Status: strings.TrimSpace(readStringAny(vdev, "status")),
}
+ if member.Device == "" {
+ member.Device = strings.TrimPrefix(strings.TrimSpace(readStringAny(vdev, "path")), "/dev/")
+ }
if member.Disk == "" {
// A missing/faulted member's device path no longer resolves;
// middleware then attaches the disk's datastore row instead.
@@ -314,6 +421,9 @@ func poolDiskMembersFromTopology(topology any) []PoolDiskMember {
member.Disk = strings.TrimSpace(readStringAny(unavail, "devname", "name"))
}
}
+ if member.Disk == "" {
+ member.Disk = wholeDiskFromDevice(member.Device)
+ }
if member.Disk == "" && member.Device == "" {
return
}
@@ -332,6 +442,49 @@ func poolDiskMembersFromTopology(topology any) []PoolDiskMember {
return members
}
+func wholeDiskFromDevice(device string) string {
+ device = strings.TrimPrefix(strings.TrimSpace(device), "/dev/")
+ if device == "" || strings.Contains(device, "/") {
+ return ""
+ }
+
+ if partition := strings.LastIndex(device, "p"); partition > 0 && partition < len(device)-1 {
+ suffix := device[partition+1:]
+ if allASCIIBytes(suffix, func(value byte) bool { return value >= '0' && value <= '9' }) {
+ return device[:partition]
+ }
+ }
+
+ // Linux sd/vd/hd/xvd partitions conventionally append digits without a
+ // separator. Do not apply this to CORE names such as ada4/da9 or whole
+ // NVMe names such as nvme0n1, where the trailing digit is the disk.
+ end := len(device)
+ for end > 0 && device[end-1] >= '0' && device[end-1] <= '9' {
+ end--
+ }
+ prefix := device[:end]
+ if end > 0 && end < len(device) &&
+ (strings.HasPrefix(prefix, "sd") ||
+ strings.HasPrefix(prefix, "vd") ||
+ strings.HasPrefix(prefix, "hd") ||
+ strings.HasPrefix(prefix, "xvd")) {
+ return device[:end]
+ }
+ return device
+}
+
+func allASCIIBytes(value string, accept func(byte) bool) bool {
+ if value == "" {
+ return false
+ }
+ for i := 0; i < len(value); i++ {
+ if !accept(value[i]) {
+ return false
+ }
+ }
+ return true
+}
+
func (c *Client) getPoolsREST(ctx context.Context) ([]Pool, error) {
var response []poolResponse
if err := c.getJSON(ctx, http.MethodGet, "/pool", &response); err != nil {
@@ -398,6 +551,7 @@ func (c *Client) getDatasetsRPC(ctx context.Context) ([]Dataset, error) {
used := readInt64Any(item, "used", "used_bytes", "usedBytes")
available := readInt64Any(item, "available", "avail", "avail_bytes", "available_bytes", "availableBytes")
+ locked := readBoolAny(item, "locked")
datasets = append(datasets, Dataset{
ID: id,
Name: name,
@@ -411,7 +565,8 @@ func (c *Client) getDatasetsRPC(ctx context.Context) ([]Dataset, error) {
// lists is treated as mounted unless it is locked (encrypted
// with the key unloaded), the one unmounted state the API does
// report. An explicit "mounted" value still wins when present.
- Mounted: readBoolAnyDefault(item, true, "mounted") && !readBoolAny(item, "locked"),
+ Mounted: readBoolAnyDefault(item, true, "mounted") && !locked,
+ Locked: locked,
ReadOnly: readBoolAny(item, "readonly", "read_only", "readOnly"),
})
}
@@ -465,6 +620,7 @@ func (c *Client) getDatasetsREST(ctx context.Context) ([]Dataset, error) {
UsedBytes: used,
AvailBytes: available,
Mounted: mounted,
+ Locked: item.Locked,
ReadOnly: readOnly,
})
}
@@ -1367,6 +1523,14 @@ func parseReplicationTasks(response []map[string]any) []ReplicationTask {
name := readStringAny(item, "name")
direction := readStringAny(item, "direction")
targetDataset := readStringAny(item, "target_dataset", "targetDataset", "target")
+ transport := readStringAny(item, "transport")
+ readOnlyMode := readStringAny(item, "readonly", "read_only", "readOnly")
+ targetHost := ""
+ if credentials := readMapAny(item, "ssh_credentials", "sshCredentials"); credentials != nil {
+ if attributes := readMapAny(credentials, "attributes"); attributes != nil {
+ targetHost = readStringAny(attributes, "host", "hostname")
+ }
+ }
sourceDatasets := readStringSliceAny(item, "source_datasets", "sourceDatasets", "sources", "source")
@@ -1400,6 +1564,9 @@ func parseReplicationTasks(response []map[string]any) []ReplicationTask {
SourceDatasets: dedupeStrings(sourceDatasets),
TargetDataset: strings.TrimSpace(targetDataset),
Direction: strings.TrimSpace(direction),
+ Transport: strings.TrimSpace(transport),
+ ReadOnlyMode: strings.TrimSpace(readOnlyMode),
+ TargetHost: strings.TrimSpace(targetHost),
LastRun: lastRun,
LastState: strings.TrimSpace(lastState),
LastError: strings.TrimSpace(lastError),
@@ -1424,6 +1591,12 @@ func (c *Client) FetchSnapshot(ctx context.Context) (*FixtureSnapshot, error) {
if err != nil {
return nil, fmt.Errorf("fetch truenas pools: %w", err)
}
+ // boot.get_state is best-effort because older/minimally privileged API
+ // keys may not expose it. When available it supplies the only boot-pool
+ // topology and per-member ZFS state.
+ if bootPool, bootErr := c.GetBootPool(ctx); bootErr == nil && bootPool != nil {
+ pools = mergeBootPool(pools, *bootPool)
+ }
datasets, err := c.GetDatasets(ctx)
if err != nil {
diff --git a/internal/truenas/client_api_shapes_test.go b/internal/truenas/client_api_shapes_test.go
index 2e05594813..035f936d8b 100644
--- a/internal/truenas/client_api_shapes_test.go
+++ b/internal/truenas/client_api_shapes_test.go
@@ -125,11 +125,14 @@ func TestPoolDiskMembersFromTopology(t *testing.T) {
"spare": []any{
map[string]any{"type": "DISK", "status": "AVAIL", "device": "da9p1", "disk": "da9", "children": []any{}},
},
+ "log": []any{
+ map[string]any{"type": "DISK", "status": "ONLINE", "path": "/dev/nvme0n1p3", "children": []any{}},
+ },
}
members := poolDiskMembersFromTopology(topology)
- if len(members) != 3 {
- t.Fatalf("expected 3 members, got %#v", members)
+ if len(members) != 4 {
+ t.Fatalf("expected 4 members, got %#v", members)
}
byDisk := map[string]PoolDiskMember{}
for _, member := range members {
@@ -148,6 +151,135 @@ func TestPoolDiskMembersFromTopology(t *testing.T) {
if byDisk["da9"].Status != "AVAIL" {
t.Fatalf("expected spare da9 AVAIL, got %#v", byDisk["da9"])
}
+ if byDisk["nvme0n1"].Device != "nvme0n1p3" || byDisk["nvme0n1"].Status != "ONLINE" {
+ t.Fatalf("expected path-only nvme0n1 ONLINE, got %#v", byDisk["nvme0n1"])
+ }
+}
+
+func TestParseBootPoolStateSupportsCOREGroupsShape(t *testing.T) {
+ item := map[string]any{
+ "id": "freenas-boot",
+ "name": "freenas-boot",
+ "status": "ONLINE",
+ "healthy": true,
+ "properties": map[string]any{
+ "size": map[string]any{"parsed": int64(255060803584)},
+ "allocated": map[string]any{"parsed": int64(16224641024)},
+ "free": map[string]any{"parsed": int64(238836162560)},
+ },
+ "groups": map[string]any{
+ "data": []any{
+ map[string]any{
+ "type": "MIRROR",
+ "status": "ONLINE",
+ "children": []any{
+ map[string]any{"type": "DISK", "status": "ONLINE", "path": "/dev/ada4p2", "children": []any{}},
+ map[string]any{"type": "DISK", "status": "ONLINE", "path": "/dev/ada5p2", "children": []any{}},
+ },
+ },
+ },
+ },
+ }
+
+ pool, ok := parseBootPoolState(item)
+ if !ok {
+ t.Fatal("expected CORE boot.get_state payload to parse")
+ }
+ if !pool.IsBoot || pool.Name != "freenas-boot" || pool.Status != "ONLINE" {
+ t.Fatalf("unexpected boot pool identity/state: %+v", pool)
+ }
+ if pool.TotalBytes != 255060803584 || pool.UsedBytes != 16224641024 || pool.FreeBytes != 238836162560 {
+ t.Fatalf("unexpected boot pool capacity: %+v", pool)
+ }
+ if len(pool.DiskMembers) != 2 || pool.DiskMembers[0].Disk != "ada4" || pool.DiskMembers[1].Disk != "ada5" {
+ t.Fatalf("unexpected boot pool members: %+v", pool.DiskMembers)
+ }
+}
+
+func TestGetBootPoolFallsBackToCORERESTShape(t *testing.T) {
+ sawREST := false
+ server := newMockServer(t, map[string]apiResponse{
+ "/api/v2.0/boot/get_state": {
+ body: `{
+ "id":"freenas-boot",
+ "name":"freenas-boot",
+ "status":"ONLINE",
+ "healthy":true,
+ "properties":{
+ "size":{"parsed":255060803584},
+ "allocated":{"parsed":16224641024},
+ "free":{"parsed":238836162560}
+ },
+ "groups":{"data":[{"type":"MIRROR","status":"ONLINE","children":[
+ {"type":"DISK","status":"ONLINE","path":"/dev/ada4p2","children":[]},
+ {"type":"DISK","status":"ONLINE","path":"/dev/ada5p2","children":[]}
+ ]}]}
+ }`,
+ },
+ }, func(t *testing.T, request *http.Request) {
+ if request.URL.Path == "/api/v2.0/boot/get_state" {
+ sawREST = true
+ if request.Method != http.MethodGet {
+ t.Fatalf("boot/get_state must be requested via GET, got %s", request.Method)
+ }
+ }
+ })
+ t.Cleanup(server.Close)
+
+ client := mustClientForServer(t, server.URL, ClientConfig{APIKey: "api-key"})
+ pool, err := client.GetBootPool(context.Background())
+ if err != nil {
+ t.Fatalf("GetBootPool() error = %v", err)
+ }
+ if !sawREST {
+ t.Fatal("expected REST boot/get_state fallback")
+ }
+ if pool == nil || !pool.IsBoot || pool.Status != "ONLINE" || len(pool.DiskMembers) != 2 {
+ t.Fatalf("unexpected boot pool: %+v", pool)
+ }
+}
+
+func TestWholeDiskFromDevicePreservesWholeDiskNames(t *testing.T) {
+ tests := map[string]string{
+ "ada4p2": "ada4",
+ "nvme0n1p3": "nvme0n1",
+ "sda3": "sda",
+ "ada4": "ada4",
+ "da9": "da9",
+ "nvme0n1": "nvme0n1",
+ }
+ for device, want := range tests {
+ if got := wholeDiskFromDevice(device); got != want {
+ t.Fatalf("wholeDiskFromDevice(%q) = %q, want %q", device, got, want)
+ }
+ }
+}
+
+func TestMergeBootPoolDoesNotDuplicatePoolQueryIdentity(t *testing.T) {
+ pools := []Pool{{
+ ID: "freenas-boot",
+ Name: "freenas-boot",
+ Status: "",
+ TotalBytes: 100,
+ }}
+ boot := Pool{
+ ID: "freenas-boot",
+ Name: "freenas-boot",
+ Status: "ONLINE",
+ TotalBytes: 100,
+ UsedBytes: 40,
+ FreeBytes: 60,
+ IsBoot: true,
+ DiskMembers: []PoolDiskMember{{Disk: "ada4", Device: "ada4p2", Status: "ONLINE"}},
+ }
+
+ merged := mergeBootPool(pools, boot)
+ if len(merged) != 1 {
+ t.Fatalf("expected one connection-local pool identity, got %+v", merged)
+ }
+ if !merged[0].IsBoot || merged[0].Status != "ONLINE" || len(merged[0].DiskMembers) != 1 {
+ t.Fatalf("expected boot state to enrich pool.query record, got %+v", merged[0])
+ }
}
func TestEnrichDisksFromPoolTopology(t *testing.T) {
diff --git a/internal/truenas/client_test.go b/internal/truenas/client_test.go
index 54dd3dbba7..aca1a5aa86 100644
--- a/internal/truenas/client_test.go
+++ b/internal/truenas/client_test.go
@@ -765,8 +765,18 @@ func TestGetReplicationTasksUsesNativeReplicationQueryShape(t *testing.T) {
"id": 7,
"name": "Offsite apps",
"direction": "PUSH",
+ "transport": "SSH",
+ "readonly": "SET",
"source_datasets": []string{"tank/apps"},
"target_dataset": "backup/apps",
+ "ssh_credentials": map[string]any{
+ "id": 3,
+ "name": "backup-nas",
+ "attributes": map[string]any{
+ "host": "backup.example.test",
+ "port": 22,
+ },
+ },
"state": map[string]any{
"state": "SUCCESS",
"datetime": "2026-03-31T06:30:00Z",
@@ -791,6 +801,9 @@ func TestGetReplicationTasksUsesNativeReplicationQueryShape(t *testing.T) {
if len(task.SourceDatasets) != 1 || task.SourceDatasets[0] != "tank/apps" || task.TargetDataset != "backup/apps" {
t.Fatalf("unexpected replication datasets: %+v", task)
}
+ if task.Transport != "SSH" || task.ReadOnlyMode != "SET" || task.TargetHost != "backup.example.test" {
+ t.Fatalf("unexpected replication target posture: %+v", task)
+ }
if task.LastState != "SUCCESS" || task.LastSnapshot != "tank/apps@auto-20260331-0600" {
t.Fatalf("unexpected replication state: %+v", task)
}
diff --git a/internal/truenas/provider.go b/internal/truenas/provider.go
index 9e3e145e61..e8e16bbe1c 100644
--- a/internal/truenas/provider.go
+++ b/internal/truenas/provider.go
@@ -450,6 +450,15 @@ func (p *Provider) Records() []unifiedresources.IngestRecord {
return truenasRecordsFromSnapshot(p.Snapshot(), p.connectionID, p.now)
}
+// RecordsFromSnapshot projects an already-classified defensive snapshot using
+// the provider's connection-scoped identity.
+func (p *Provider) RecordsFromSnapshot(snapshot *FixtureSnapshot) []unifiedresources.IngestRecord {
+ if p == nil || !IsFeatureEnabled() {
+ return nil
+ }
+ return truenasRecordsFromSnapshot(snapshot, p.connectionID, p.now)
+}
+
func truenasRecordsFromSnapshot(snapshot *FixtureSnapshot, connectionID string, now func() time.Time) []unifiedresources.IngestRecord {
if snapshot == nil {
return nil
@@ -575,12 +584,7 @@ func truenasRecordsFromSnapshot(snapshot *FixtureSnapshot, connectionID string,
Risk: risk,
ZFSPoolState: strings.ToUpper(strings.TrimSpace(pool.Status)),
},
- Tags: []string{
- "truenas",
- "pool",
- "zfs",
- "health:" + strings.ToLower(strings.TrimSpace(pool.Status)),
- },
+ Tags: poolTags(pool),
Incidents: incidents,
},
Identity: unifiedresources.ResourceIdentity{
@@ -1359,20 +1363,42 @@ func statusFromPool(pool Pool) unifiedresources.ResourceStatus {
}
}
+func poolTags(pool Pool) []string {
+ tags := []string{
+ "truenas",
+ "pool",
+ "zfs",
+ "health:" + strings.ToLower(strings.TrimSpace(pool.Status)),
+ }
+ if pool.IsBoot {
+ tags = append(tags, "boot-pool")
+ }
+ return tags
+}
+
func statusFromDataset(dataset Dataset) unifiedresources.ResourceStatus {
+ if dataset.Locked {
+ return unifiedresources.StatusOffline
+ }
if !dataset.Mounted {
return unifiedresources.StatusOffline
}
- if dataset.ReadOnly {
+ if dataset.ReadOnly && dataset.ReadOnlyReason != DatasetReadOnlyReplicationTarget {
return unifiedresources.StatusWarning
}
return unifiedresources.StatusOnline
}
func datasetStateTag(dataset Dataset) string {
+ if dataset.Locked {
+ return "state:locked"
+ }
if !dataset.Mounted {
return "state:unmounted"
}
+ if dataset.ReadOnly && dataset.ReadOnlyReason == DatasetReadOnlyReplicationTarget {
+ return "state:replication-readonly"
+ }
if dataset.ReadOnly {
return "state:readonly"
}
diff --git a/internal/truenas/provider_health_test.go b/internal/truenas/provider_health_test.go
index cc191e48d3..40afe0e318 100644
--- a/internal/truenas/provider_health_test.go
+++ b/internal/truenas/provider_health_test.go
@@ -40,6 +40,12 @@ func TestStatusFromPoolExhaustiveZFSStates(t *testing.T) {
}
}
+func TestBootPoolTagPreservesPoolRole(t *testing.T) {
+ if tags := poolTags(Pool{Status: "ONLINE", IsBoot: true}); !hasTag(tags, "boot-pool") {
+ t.Fatalf("expected boot-pool tag, got %v", tags)
+ }
+}
+
func TestStatusFromDatasetStates(t *testing.T) {
tests := []struct {
name string
@@ -48,6 +54,8 @@ func TestStatusFromDatasetStates(t *testing.T) {
}{
{"mounted writable", Dataset{Mounted: true, ReadOnly: false}, unifiedresources.StatusOnline},
{"mounted readonly", Dataset{Mounted: true, ReadOnly: true}, unifiedresources.StatusWarning},
+ {"replication readonly", Dataset{Mounted: true, ReadOnly: true, ReadOnlyReason: DatasetReadOnlyReplicationTarget}, unifiedresources.StatusOnline},
+ {"locked replication readonly", Dataset{Mounted: false, Locked: true, ReadOnly: true, ReadOnlyReason: DatasetReadOnlyReplicationTarget}, unifiedresources.StatusOffline},
{"unmounted", Dataset{Mounted: false}, unifiedresources.StatusOffline},
}
@@ -185,6 +193,8 @@ func TestDatasetStateTag(t *testing.T) {
}{
{"mounted writable", Dataset{Mounted: true, ReadOnly: false}, "state:mounted"},
{"mounted readonly", Dataset{Mounted: true, ReadOnly: true}, "state:readonly"},
+ {"replication readonly", Dataset{Mounted: true, ReadOnly: true, ReadOnlyReason: DatasetReadOnlyReplicationTarget}, "state:replication-readonly"},
+ {"locked replication readonly", Dataset{Mounted: false, Locked: true, ReadOnly: true, ReadOnlyReason: DatasetReadOnlyReplicationTarget}, "state:locked"},
{"unmounted", Dataset{Mounted: false}, "state:unmounted"},
}
diff --git a/internal/truenas/types.go b/internal/truenas/types.go
index 544bfe8b5e..bf943e7ba7 100644
--- a/internal/truenas/types.go
+++ b/internal/truenas/types.go
@@ -47,12 +47,16 @@ type Pool struct {
TotalBytes int64
UsedBytes int64
FreeBytes int64
+ // IsBoot distinguishes the boot pool collected from boot.get_state from
+ // data pools. Identity remains connection-scoped at projection time.
+ IsBoot bool
// DiskMembers are the leaf disks of the pool's vdev topology with their
- // per-member ZFS state. pool.query attaches topology unconditionally on
- // both CORE and SCALE, which makes it the only API source for disk→pool
- // membership and per-disk health: disk.query carries neither a status
- // nor a SMART field, and only reports pool membership behind an extra
- // option the REST bridge cannot pass (#1573).
+ // per-member ZFS state. pool.query attaches topology for data pools and
+ // boot.get_state supplies the separate boot-pool topology. Together they
+ // are the API sources for disk→pool membership and per-disk health:
+ // disk.query carries neither a status nor a SMART field, and only reports
+ // pool membership behind an extra option the REST bridge cannot pass
+ // (#1573, #1609).
DiskMembers []PoolDiskMember
}
@@ -67,15 +71,26 @@ type PoolDiskMember struct {
Status string
}
+// DatasetReadOnlyReason describes why a dataset is read-only when the API
+// reports readonly=on. An unspecified reason remains operator-actionable.
+type DatasetReadOnlyReason string
+
+const (
+ DatasetReadOnlyUnspecified DatasetReadOnlyReason = ""
+ DatasetReadOnlyReplicationTarget DatasetReadOnlyReason = "replication-target"
+)
+
// Dataset mirrors the subset of TrueNAS dataset fields needed for unified mapping.
type Dataset struct {
- ID string
- Name string
- Pool string
- UsedBytes int64
- AvailBytes int64
- Mounted bool
- ReadOnly bool
+ ID string
+ Name string
+ Pool string
+ UsedBytes int64
+ AvailBytes int64
+ Mounted bool
+ Locked bool
+ ReadOnly bool
+ ReadOnlyReason DatasetReadOnlyReason
}
// Disk mirrors a TrueNAS disk listing entry.
@@ -329,6 +344,11 @@ type ReplicationTask struct {
SourceDatasets []string
TargetDataset string
Direction string
+ Transport string
+ ReadOnlyMode string
+ // TargetHost is the configured SSH credential host for remote PUSH
+ // replication. It is intentionally absent for unexpanded credentials.
+ TargetHost string
LastRun *time.Time
LastState string // SUCCESS / FAILED / RUNNING / etc, best-effort