From 9c85fdb6e9e2f41f2bbed808c1c9baa84f1063f4 Mon Sep 17 00:00:00 2001 From: Kevin Adams Date: Sat, 23 May 2026 21:52:41 -0400 Subject: [PATCH] fix: extract pool name from path in status(); improve Pool/Dataset UX status() was comparing the full dataset path (e.g. tank/proxmox/vdisks) against TrueNAS /pool names which are top-level only (e.g. tank). Extract the first path component so pool stats resolve correctly. Rename Pool field label to 'Pool / Dataset Path' and update its hint to make clear it accepts the full ZFS path (matching v2.x 'pool' field). Rename Dataset to 'Sub-dataset' with a hint that discourages filling it unless you genuinely need an extra sub-level beyond what's in Pool. Co-Authored-By: Claude Sonnet 4.6 --- perl5/PVE/Storage/Custom/TrueNAS.pm | 14 ++++++++++---- ui/truenas-storage.js | 8 ++++---- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/perl5/PVE/Storage/Custom/TrueNAS.pm b/perl5/PVE/Storage/Custom/TrueNAS.pm index ec299cd..ae15871 100644 --- a/perl5/PVE/Storage/Custom/TrueNAS.pm +++ b/perl5/PVE/Storage/Custom/TrueNAS.pm @@ -66,11 +66,14 @@ sub properties { default => 0, }, truenas_pool => { - description => "ZFS pool name on TrueNAS (e.g. 'tank')", + description => "ZFS pool or dataset path where PVE volumes are created " + . "(e.g. 'tank' or 'tank/proxmox/vdisks'). " + . "Matches the 'pool' field from the v2.x plugin.", type => 'string', }, truenas_dataset => { - description => "Dataset path within the pool for volume storage (e.g. 'proxmox'). Optional.", + description => "Optional additional sub-dataset appended to Pool path. " + . "Leave blank — put the full path in Pool instead.", type => 'string', }, truenas_portal_ip => { @@ -347,9 +350,12 @@ sub _iscsi_ensure_session { sub status { my ($class, $storeid, $scfg, $cache) = @_; + # truenas_pool may be a full dataset path (e.g. tank/proxmox/vdisks). + # The /pool API matches on the top-level pool name only. + my $pool_name = (split m{/}, $scfg->{truenas_pool})[0]; my $pools = _api($scfg, 'GET', '/pool') // []; - my ($pool) = grep { $_->{name} eq $scfg->{truenas_pool} } @$pools; - die "Pool '$scfg->{truenas_pool}' not found on $scfg->{truenas_host}\n" unless $pool; + my ($pool) = grep { $_->{name} eq $pool_name } @$pools; + die "Pool '$pool_name' not found on $scfg->{truenas_host}\n" unless $pool; my $total = $pool->{size} // 0; my $free = $pool->{free} // 0; diff --git a/ui/truenas-storage.js b/ui/truenas-storage.js index 35fff11..adea92b 100644 --- a/ui/truenas-storage.js +++ b/ui/truenas-storage.js @@ -82,19 +82,19 @@ Ext.define('PVE.storage.TrueNASInputPanel', { }, { xtype: me.isCreate ? 'proxmoxtextfield' : 'displayfield', - fieldLabel: gettext('Pool'), + fieldLabel: gettext('Pool / Dataset Path'), name: 'truenas_pool', allowBlank: false, autoComplete: false, - emptyText: gettext('ZFS pool name (e.g. tank)'), + emptyText: gettext('ZFS path where volumes live (e.g. tank or tank/proxmox/vdisks)'), }, { xtype: 'proxmoxtextfield', - fieldLabel: gettext('Dataset'), + fieldLabel: gettext('Sub-dataset'), name: 'truenas_dataset', allowBlank: true, autoComplete: false, - emptyText: gettext('Optional (e.g. proxmox)'), + emptyText: gettext('Leave blank — extra sub-path below Pool if needed'), deleteEmpty: !me.isCreate, }, ];