[pbs-devel] [PATCH proxmox-backup v2 2/2] web: disallow datastore in root, add reuse-datastore flag

Gabriel Goller g.goller at proxmox.com
Tue Jul 30 11:10:24 CEST 2024


On 22.07.2024 08:45, Thomas Lamprecht wrote:
>Am 12/06/2024 um 15:22 schrieb Gabriel Goller:
>> Disallows creating a datastore in root on the frontend side, by
>> filtering the '/' path. Add reuse-flag to permit us to open existing
>> datastores.
>>
>> Signed-off-by: Gabriel Goller <g.goller at proxmox.com>
>> ---
>>  www/window/DataStoreEdit.js | 11 +++++++++++
>>  1 file changed, 11 insertions(+)
>>
>> diff --git a/www/window/DataStoreEdit.js b/www/window/DataStoreEdit.js
>> index b6115460..2565688e 100644
>> --- a/www/window/DataStoreEdit.js
>> +++ b/www/window/DataStoreEdit.js
>> @@ -61,6 +61,17 @@ Ext.define('PBS.DataStoreEdit', {
>>  			allowBlank: false,
>>  			fieldLabel: gettext('Backing Path'),
>>  			emptyText: gettext('An absolute path'),
>> +			validator: function(val) {
>> +			    if (val.trim() === '/') {
>> +				return false;
>> +			    }
>> +			    return true;
>
>above could be reduced to:
>
>validator: val => val?.trim() !== '/',
>
>
>Note also the null check, not 100% sure from top of my head, but when
>going from some value to deleting the field content (CTRL + A; DEL)
>the validator might be called with a null/undefined value, or did you
>check and ensure that it's then always an empty string?

Hmm I could not reproduce this, probably because we have the `allowBlank:
false` above? Either way, your line is cleaner, so I will update it :).

>Besides that, this seems quite unrelated to the "allow re-adding an
>existing datastore" part and should be its own patch, which could
>be applied up-front.
>Oh, and does the backend disallow this already, or is this intended
>as "unsafe" frontend only check for pure UX reason (can be fine, but
>I would at least note that explicitly in the commit message).

This is checked on the backend as well.
(src/api2/config/datastore.rs:77, with this series applied.)

Yes, the series started out as "disallow datastore creation in root" and
now transformed into "allow opening a existing datastore" (with all the
correct checks). I could factor out the "root-path-check" (frontend and
backend) and submit a separate series for that though?

>
>
>> +			},
>> +		    },
>> +		    {
>> +			xtype: 'checkbox',
>> +			name: 'reuse-datastore',
>> +			fieldLabel: gettext('Reuse existing datastore'),
>
>hmm, not sure w.r.t. always showing a checkbox for some relatively niche
>use case by default.
>Maybe this is better split-off into either an advanced section or by
>opening the dialogue through some new button (e.g. by adding a top bar
>in the all-datastore summary page and add an "Add Datastore" split-
>button there with the "Re-Add Existing Datastore" as menu button there
>(like the shutdown + reboot/stop for guests in PVE).

I'd agree with an "Advanced" button to toggle this option. Will include
it in the next version!

A split button in the datastore overview is IMO a bit hard to find, I
don't think the overview is used that much. 




More information about the pbs-devel mailing list