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 <noreply@anthropic.com>
This commit is contained in:
Kevin Adams 2026-05-23 21:52:41 -04:00
parent 132875a5c5
commit 9c85fdb6e9
2 changed files with 14 additions and 8 deletions

View File

@ -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;

View File

@ -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,
},
];