all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Philipp Hufnagl <p.hufnagl@proxmox.com>
To: Thomas Lamprecht <t.lamprecht@proxmox.com>,
	Proxmox VE development discussion <pve-devel@lists.proxmox.com>,
	Fiona Ebner <f.ebner@proxmox.com>
Subject: Re: [pve-devel] [PATCH storage] fix #5008: prevent adding pbs storage with invalid namespace
Date: Wed, 15 Nov 2023 11:40:26 +0100	[thread overview]
Message-ID: <63532d84-0ded-42cf-a286-c515e6f33ebc@proxmox.com> (raw)
In-Reply-To: <b0758df6-5eed-4862-90d2-3cd547ffa966@proxmox.com>



On 11/15/23 11:09, Thomas Lamprecht wrote:
> Am 15/11/2023 um 11:05 schrieb Philipp Hufnagl:
>>
>>
>> On 11/15/23 10:52, Thomas Lamprecht wrote:
>>> Am 15/11/2023 um 10:37 schrieb Philipp Hufnagl:
>>>> On 11/15/23 09:31, Fiona Ebner wrote:
>>>>> Am 14.11.23 um 15:27 schrieb Philipp Hufnagl:
>>>>>> diff --git a/src/PVE/Storage/PBSPlugin.pm b/src/PVE/Storage/PBSPlugin.pm
>>>>>> index 4320974..aceb2c4 100644
>>>>>> --- a/src/PVE/Storage/PBSPlugin.pm
>>>>>> +++ b/src/PVE/Storage/PBSPlugin.pm
>>>>>> @@ -817,6 +817,17 @@ sub scan_datastores {
>>>>>>      return $response;
>>>>>>  }
>>>>>>  
>>>>>> +sub scan_namespaces {
>>>>>> +    my ($scfg, $datastore, $password) = @_;
>>>>>> +
>>>>>> +    my $conn = pbs_api_connect($scfg, $password);
>>>>>
>>>>> Not super important, but would be nice to have a way to re-use the same
>>>>> connection in scan_datastores() and here, since activate_storage() will
>>>>> call both of them.
>>>>
>>>> scan_datastores() seem to be called somewhere else as well. I see if I
>>>> can find a way to reuse the connection but not break the code there.
>>>
>>>
>>> In the long run it maybe could be better to have an explicit check_availability
>>> hook, but IMO it's a bit late in the release cycle for that as this needs a bit
>>> extra care, especially w.r.t. external plugins and our ABI compat.
>>>
>>> Anyhow, as workaround we might be able to do this check in the on_add_hook and
>>> on_update_hook methods for now.
>>
>> I am planning on introducing a function called "connect_if_none" that
>> checks if it gets passed a connection and if so, return it. If it gets
>> passed undef, it will establish a connection and return that one.
>>
>> That way a user can simply write something like
>>
>>   my $conn = connect_if_none($scfg, $password, $conn);
>>
>> and not worry about it.
> 
> 
> not sure how above fits to my comment at all...
> Connection re-use is not the real issue here, doing it senslessy on every
> activate is..
> 
> And connect_if_none is a rather generic/undescriptive name and still would
> not solve re-use if done in different method calls, so a rather for only
> a very limited use case where one can just pass $conn around directly.

I can rename it.

I am not certain if I understand correctly. Aren't those hooks
trigered after adding a storage? The issue I am resolving here is
before the storage is actually added.




  reply	other threads:[~2023-11-15 10:40 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-14 14:27 Philipp Hufnagl
2023-11-15  8:31 ` Fiona Ebner
2023-11-15  9:37   ` Philipp Hufnagl
2023-11-15  9:52     ` Thomas Lamprecht
2023-11-15 10:05       ` Philipp Hufnagl
2023-11-15 10:09         ` Thomas Lamprecht
2023-11-15 10:40           ` Philipp Hufnagl [this message]
2023-11-15 10:01     ` Fiona Ebner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=63532d84-0ded-42cf-a286-c515e6f33ebc@proxmox.com \
    --to=p.hufnagl@proxmox.com \
    --cc=f.ebner@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    --cc=t.lamprecht@proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal