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 B86667248F for ; Mon, 12 Apr 2021 14:41:43 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id AF5071EBBE for ; Mon, 12 Apr 2021 14:41:13 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (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 2AF201EBB1 for ; Mon, 12 Apr 2021 14:41:13 +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 E6443420AC for ; Mon, 12 Apr 2021 14:41:12 +0200 (CEST) Message-ID: <7e901844-fdae-afee-470d-7dde232e8a10@proxmox.com> Date: Mon, 12 Apr 2021 14:41:12 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:88.0) Gecko/20100101 Thunderbird/88.0 Content-Language: en-US To: Proxmox VE development discussion , Aaron Lauterer References: <20210407142218.29156-1-a.lauterer@proxmox.com> <20210407142218.29156-3-a.lauterer@proxmox.com> From: Thomas Lamprecht In-Reply-To: <20210407142218.29156-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.043 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] applied: [PATCH v2 storage 2/3] rbd: fix #3286 add namespace support 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: Mon, 12 Apr 2021 12:41:43 -0000 On 07.04.21 16:22, Aaron Lauterer wrote: > This patch introduces support for Cephs RBD namespaces. > > A new storage config parameter 'namespace' defines the namespace to be > used for the RBD storage. > > The namespace must already exist in the Ceph cluster as it is not > automatically created. > > The main intention is to use this for external Ceph clusters. With > namespaces, each PVE cluster can get its own namespace and will not > conflict with other PVE clusters. > > Signed-off-by: Aaron Lauterer > > --- > v1 -> v2: > use `defined` to check if a namespace if configured instead of > evaluating the value which would wrongly evaluate to false if the pool > would be called '0'. Thx @Thomas for pointing this out. > > much less changes since the 'centralize rbd path concatenation' patch > took care of most instances. > > removed empty new lines that I did not catch in the previous version > > rvc -> v1: > add --namespace parameter centrally in sub $build_cmd. All commands > except one (rbd unmap) support it. To handle commands that don't support > it, a hash with them was introduced. > > In a few places paths (FS, Ceph hierarchy) are needed. These are the > places scattered throughout the plugin where the namespace is inserted > if it is configured. > > PVE/Storage/RBDPlugin.pm | 19 +++++++++++++++++++ > 1 file changed, 19 insertions(+) > applied, but addressed one little issue (see below). thanks! > diff --git a/PVE/Storage/RBDPlugin.pm b/PVE/Storage/RBDPlugin.pm > index 421539f..02950be 100644 > --- a/PVE/Storage/RBDPlugin.pm > +++ b/PVE/Storage/RBDPlugin.pm > @@ -25,6 +25,8 @@ my $get_parent_image_name = sub { > my $get_rbd_path = sub { > my ($scfg, $volume) = @_; > my $pool = $scfg->{pool} ? $scfg->{pool} : 'rbd'; > + > + return "${pool}/$scfg->{namespace}/${volume}" if defined($scfg->{namespace}); > return "${pool}/${volume}"; > }; > > @@ -36,6 +38,14 @@ my $build_cmd = sub { > > my $cmd = [$binary, '-p', $pool]; > > + # some subcommands will fail if the --namespace parameter is present > + my $no_namespace_parameter = { > + unmap => 1, > + }; > + > + push @$cmd, '--namespace', $scfg->{namespace} > + if ($scfg->{namespace} && !$no_namespace_parameter->{$op}); above check still failed for "falsy" namespace values, I fixed that in a follow-up > + > push @$cmd, '-c', $cmd_option->{ceph_conf} if ($cmd_option->{ceph_conf}); > push @$cmd, '-m', $cmd_option->{mon_host} if ($cmd_option->{mon_host}); > push @$cmd, '--auth_supported', $cmd_option->{auth_supported} if ($cmd_option->{auth_supported});