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 4337DBCE8 for ; Mon, 2 May 2022 10:09:33 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 339A525257 for ; Mon, 2 May 2022 10:09:33 +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 AE5AA251EE for ; Mon, 2 May 2022 10:09:30 +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 E6B644293E for ; Mon, 2 May 2022 10:09:29 +0200 (CEST) From: Aaron Lauterer To: pve-devel@lists.proxmox.com Date: Mon, 2 May 2022 10:09:25 +0200 Message-Id: <20220502080928.886800-1-a.lauterer@proxmox.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.002 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 SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - Subject: [pve-devel] [PATCH manager v2 1/4] ceph tools: set_pools: filter settings for erasure code pools 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, 02 May 2022 08:09:33 -0000 Erasure code pools cannot change certain settings after creation. Trying to set them will cause errors on Cephs side. Signed-off-by: Aaron Lauterer --- changes since v1: * check if setting is present in params before removing them * create new rados object if needed in get_pool_type PVE/Ceph/Tools.pm | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/PVE/Ceph/Tools.pm b/PVE/Ceph/Tools.pm index 7bd3eedc..a1458b40 100644 --- a/PVE/Ceph/Tools.pm +++ b/PVE/Ceph/Tools.pm @@ -205,7 +205,7 @@ sub check_ceph_enabled { } my $set_pool_setting = sub { - my ($pool, $setting, $value) = @_; + my ($pool, $setting, $value, $rados) = @_; my $command; if ($setting eq 'application') { @@ -224,7 +224,7 @@ my $set_pool_setting = sub { }; } - my $rados = PVE::RADOS->new(); + $rados = PVE::RADOS->new() if !$rados; eval { $rados->mon_command($command); }; return $@ ? $@ : undef; }; @@ -232,6 +232,18 @@ my $set_pool_setting = sub { sub set_pool { my ($pool, $param) = @_; + my $rados = PVE::RADOS->new(); + + if (get_pool_type($pool, $rados) eq 'erasure') { + #remove parameters that cannot be changed for erasure coded pools + my $ignore_params = ['size', 'crush_rule']; + for my $setting (@$ignore_params) { + if ($param->{$setting}) { + print "cannot set '${setting}' for erasure coded pool\n"; + delete $param->{$setting}; + } + } + } # by default, pool size always resets min_size, so set it as first item # https://tracker.ceph.com/issues/44862 my $keys = [ grep { $_ ne 'size' } sort keys %$param ]; @@ -241,7 +253,7 @@ sub set_pool { my $value = $param->{$setting}; print "pool $pool: applying $setting = $value\n"; - if (my $err = $set_pool_setting->($pool, $setting, $value)) { + if (my $err = $set_pool_setting->($pool, $setting, $value, $rados)) { print "$err"; } else { delete $param->{$setting}; @@ -267,6 +279,13 @@ sub get_pool_properties { return $rados->mon_command($command); } +sub get_pool_type { + my ($pool, $rados) = @_; + $rados = PVE::RADOS->new() if !defined($rados); + return 'erasure' if get_pool_properties($pool, $rados)->{erasure_code_profile}; + return 'replicated'; +} + sub create_pool { my ($pool, $param, $rados) = @_; $rados = PVE::RADOS->new() if !defined($rados); -- 2.30.2