From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id B7BB16A5D3 for ; Fri, 30 Jul 2021 15:35:56 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id A141E1205B for ; Fri, 30 Jul 2021 15:35:26 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 9D6EA12049 for ; Fri, 30 Jul 2021 15:35:25 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 6B47142C7D for ; Fri, 30 Jul 2021 15:35:25 +0200 (CEST) Message-ID: <71228b54-f525-283b-a773-f90929643e5c@proxmox.com> Date: Fri, 30 Jul 2021 15:35:23 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.0 Content-Language: en-GB To: Proxmox VE development discussion , Aaron Lauterer References: <20210721151326.391244-1-a.lauterer@proxmox.com> <20210721151326.391244-3-a.lauterer@proxmox.com> From: Thomas Lamprecht In-Reply-To: <20210721151326.391244-3-a.lauterer@proxmox.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.478 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment NICE_REPLY_A -0.202 Looks like a legit reply (A) SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [pvesm.pm, rbdplugin.pm, config.pm, cephfsplugin.pm] Subject: Re: [pve-devel] [PATCH storage 2/2] Ceph: add keyring parameter for external clusters X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 30 Jul 2021 13:35:56 -0000 On 21/07/2021 17:13, Aaron Lauterer wrote: > By adding the keyring for RBD storage or the secret for CephFS ones, it > is possible to add an external Ceph cluster with only one API call. > > Previously the keyring / secret file needed to be placed in > /etc/pve/priv/ceph/$storeID.{keyring,secret} manually. > > Signed-off-by: Aaron Lauterer > --- > PVE/API2/Storage/Config.pm | 2 +- > PVE/CLI/pvesm.pm | 12 ++++++++++-- > PVE/Storage/CephFSPlugin.pm | 20 ++++++++++++++------ > PVE/Storage/RBDPlugin.pm | 24 ++++++++++++++++++------ > 4 files changed, 43 insertions(+), 15 deletions(-) > > diff --git a/PVE/Storage/CephFSPlugin.pm b/PVE/Storage/CephFSPlugin.pm > index 2aaa450..ae02cb8 100644 > --- a/PVE/Storage/CephFSPlugin.pm > +++ b/PVE/Storage/CephFSPlugin.pm > @@ -163,20 +164,27 @@ sub check_config { > sub on_add_hook { > my ($class, $storeid, $scfg, %param) = @_; > > - return if defined($scfg->{monhost}); # nothing to do if not pve managed ceph > + my $secret = $param{keyring} if defined $param{keyring} // undef; > + PVE::CephConfig::ceph_create_keyfile($scfg->{type}, $storeid, $secret); > > - PVE::CephConfig::ceph_create_keyfile($scfg->{type}, $storeid); > + return; > +} > + > +sub on_update_hook { > + my ($class, $storeid, $scfg, %param) = @_; > + > + if (defined($param{keyring})) { > + PVE::CephConfig::ceph_create_keyfile($scfg->{type}, $storeid, $param{keyring}); > + } else { > + PVE::CephConfig::ceph_remove_keyfile($scfg->{type}, $storeid); > + } this is dangerous, you will always delete the key on any update that did not provided a new one. Please look in other plugins about how one must handle this, e.g., PBS if (exists($param{password})) { if (defined($param{password})) { pbs_set_password($scfg, $storeid, $param{password}); } else { pbs_delete_password($scfg, $storeid); } } iow, first check if the param is set and only then you can deduct that undefined means "must be deleted". > @@ -327,20 +332,27 @@ sub options { > sub on_add_hook { > my ($class, $storeid, $scfg, %param) = @_; > > - return if defined($scfg->{monhost}); # nothing to do if not pve managed ceph > + my $secret = $param{keyring} if defined $param{keyring} // undef; > + PVE::CephConfig::ceph_create_keyfile($scfg->{type}, $storeid, $secret); > + > + return; > +} > + > +sub on_update_hook { > + my ($class, $storeid, $scfg, %param) = @_; > > - PVE::CephConfig::ceph_create_keyfile($scfg->{type}, $storeid); > + if (defined($param{keyring})) { > + PVE::CephConfig::ceph_create_keyfile($scfg->{type}, $storeid, $param{keyring}); > + } else { > + PVE::CephConfig::ceph_remove_keyfile($scfg->{type}, $storeid); > + } same here.