From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <d.csapak@proxmox.com>
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 5FD42BBAD
 for <pve-devel@lists.proxmox.com>; Mon,  2 May 2022 09:10:09 +0200 (CEST)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
 by firstgate.proxmox.com (Proxmox) with ESMTP id 53E0A24A00
 for <pve-devel@lists.proxmox.com>; Mon,  2 May 2022 09:10:09 +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 50BC0249F5
 for <pve-devel@lists.proxmox.com>; Mon,  2 May 2022 09:10:08 +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 1EEC942610;
 Mon,  2 May 2022 09:10:08 +0200 (CEST)
Message-ID: <15242dcb-0af7-e34a-47d4-d8219c348077@proxmox.com>
Date: Mon, 2 May 2022 09:10:07 +0200
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:100.0) Gecko/20100101
 Thunderbird/100.0
Content-Language: en-US
To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>,
 Aaron Lauterer <a.lauterer@proxmox.com>
References: <20220429141655.2884387-1-a.lauterer@proxmox.com>
From: Dominik Csapak <d.csapak@proxmox.com>
In-Reply-To: <20220429141655.2884387-1-a.lauterer@proxmox.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-SPAM-LEVEL: Spam detection results:  0
 AWL 1.097 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           -1.943 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
 T_SCC_BODY_TEXT_LINE    -0.01 -
Subject: Re: [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 <pve-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/>
List-Post: <mailto:pve-devel@lists.proxmox.com>
List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe>
X-List-Received-Date: Mon, 02 May 2022 07:10:09 -0000

one minor nit inline

On 4/29/22 16:16, Aaron Lauterer wrote:
> Erasure code pools cannot change certain settings after creation.
> Trying to set them will cause errors on Cephs side.
> 
> Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
> ---
>   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";

i'd only print that line if there was actually a value there, else
every one gets those warnings even if they did not attempt to set e.g.
the size

> +	    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);