public inbox for pve-devel@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:05:03 +0100	[thread overview]
Message-ID: <4e09708f-4259-4784-99c8-7e8115a0eb56@proxmox.com> (raw)
In-Reply-To: <f9ed9a3f-d8d5-441a-bd16-f8a65157e1dd@proxmox.com>



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.




  reply	other threads:[~2023-11-15 10:05 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 [this message]
2023-11-15 10:09         ` Thomas Lamprecht
2023-11-15 10:40           ` Philipp Hufnagl
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=4e09708f-4259-4784-99c8-7e8115a0eb56@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal