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 E0177B6C3 for ; Fri, 29 Apr 2022 16:17:27 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id D57A9BC83 for ; Fri, 29 Apr 2022 16:16:57 +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 A2C42BC75 for ; Fri, 29 Apr 2022 16:16:56 +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 7C36B43061 for ; Fri, 29 Apr 2022 16:16:56 +0200 (CEST) From: Aaron Lauterer To: pve-devel@lists.proxmox.com Date: Fri, 29 Apr 2022 16:16:52 +0200 Message-Id: <20220429141655.2884387-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.004 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 Subject: [pve-devel] [PATCH manager 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: Fri, 29 Apr 2022 14:17:27 -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 --- PVE/Ceph/Tools.pm | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/PVE/Ceph/Tools.pm b/PVE/Ceph/Tools.pm index 7bd3eedc..65589820 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,16 @@ 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) { + 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 +251,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 +277,12 @@ sub get_pool_properties { return $rados->mon_command($command); } +sub get_pool_type { + my ($pool, $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