public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH manager] fix #5010: ceph: pool set only changed properties
@ 2024-07-09 11:41 Aaron Lauterer
  2024-07-10 12:10 ` Christoph Heiss
  2024-07-22 17:02 ` [pve-devel] applied: " Thomas Lamprecht
  0 siblings, 2 replies; 5+ messages in thread
From: Aaron Lauterer @ 2024-07-09 11:41 UTC (permalink / raw)
  To: pve-devel

By only setting propterties that have changed, we can avoid potential
errors in the task.

For example, if one configures the "nosizechange" property on a pool, to
prevent accidential size changes, the task will now only error if the
user is actually trying to change the size.

Prior to this patch, we would always try to set all parameters, even if
they were the same value. In the above example, this would result in the
task ending in error state, as we are not allowed to change the size.

To disable size changing you can run the following command:
ceph osd pool set {pool} nosizechange 1

Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
---

I am not sure if we want to log every property that is skipped. It makes
visible what is done, but is also a bit noisy.

 PVE/Ceph/Tools.pm | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/PVE/Ceph/Tools.pm b/PVE/Ceph/Tools.pm
index 9b97171e..dd27e7ce 100644
--- a/PVE/Ceph/Tools.pm
+++ b/PVE/Ceph/Tools.pm
@@ -262,9 +262,17 @@ sub set_pool {
     my $keys = [ grep { $_ ne 'size' } sort keys %$param ];
     unshift @$keys, 'size' if exists $param->{size};
 
+    my $current_properties = get_pool_properties($pool, $rados);
+
     for my $setting (@$keys) {
 	my $value = $param->{$setting};
 
+	if (defined($current_properties->{$setting}) && $value eq $current_properties->{$setting}) {
+	    print "skipping '${setting}', did not change\n";
+	    delete $param->{$setting};
+	    next;
+	}
+
 	print "pool $pool: applying $setting = $value\n";
 	if (my $err = $set_pool_setting->($pool, $setting, $value, $rados)) {
 	    print "$err";
-- 
2.39.2



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [pve-devel] [PATCH manager] fix #5010: ceph: pool set only changed properties
  2024-07-09 11:41 [pve-devel] [PATCH manager] fix #5010: ceph: pool set only changed properties Aaron Lauterer
@ 2024-07-10 12:10 ` Christoph Heiss
  2024-07-22 17:02 ` [pve-devel] applied: " Thomas Lamprecht
  1 sibling, 0 replies; 5+ messages in thread
From: Christoph Heiss @ 2024-07-10 12:10 UTC (permalink / raw)
  To: Aaron Lauterer; +Cc: Proxmox VE development discussion

Tested it on a simple 3-node cluster - first without setting
`nosizechange` on a pool, then w/ the patch applied. Does what it says
on the tin, avoids a task error while allowing setting other properties
when `nosizechange` is active.

On Tue, Jul 09, 2024 at 01:41:16PM GMT, Aaron Lauterer wrote:
> By only setting propterties that have changed, we can avoid potential
> errors in the task.
>
> For example, if one configures the "nosizechange" property on a pool, to
> prevent accidential size changes, the task will now only error if the
> user is actually trying to change the size.
>
> Prior to this patch, we would always try to set all parameters, even if
> they were the same value. In the above example, this would result in the
> task ending in error state, as we are not allowed to change the size.
>
> To disable size changing you can run the following command:
> ceph osd pool set {pool} nosizechange 1
>
> Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>

Reviewed-by: Christoph Heiss <c.heiss@proxmox.com>
Tested-by: Christoph Heiss <c.heiss@proxmox.com>

> ---
>
> I am not sure if we want to log every property that is skipped. It makes
> visible what is done, but is also a bit noisy.

I didn't really perceive them as annoying or such, as the task log is
only a few lines anyway in both cases. We do not log such things anywhere
else AFAIK, so would be fine without these messages too. But not really
worth sending a v2 IMO.

>
>  PVE/Ceph/Tools.pm | 8 ++++++++
>  1 file changed, 8 insertions(+)
>
> diff --git a/PVE/Ceph/Tools.pm b/PVE/Ceph/Tools.pm
> index 9b97171e..dd27e7ce 100644
> --- a/PVE/Ceph/Tools.pm
> +++ b/PVE/Ceph/Tools.pm
> @@ -262,9 +262,17 @@ sub set_pool {
>      my $keys = [ grep { $_ ne 'size' } sort keys %$param ];
>      unshift @$keys, 'size' if exists $param->{size};
>
> +    my $current_properties = get_pool_properties($pool, $rados);
> +
>      for my $setting (@$keys) {
>  	my $value = $param->{$setting};
>
> +	if (defined($current_properties->{$setting}) && $value eq $current_properties->{$setting}) {
> +	    print "skipping '${setting}', did not change\n";
> +	    delete $param->{$setting};
> +	    next;
> +	}
> +
>  	print "pool $pool: applying $setting = $value\n";
>  	if (my $err = $set_pool_setting->($pool, $setting, $value, $rados)) {
>  	    print "$err";
> --
> 2.39.2
>
>
>
> _______________________________________________
> pve-devel mailing list
> pve-devel@lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
>
>


_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [pve-devel] applied: [PATCH manager] fix #5010: ceph: pool set only changed properties
  2024-07-09 11:41 [pve-devel] [PATCH manager] fix #5010: ceph: pool set only changed properties Aaron Lauterer
  2024-07-10 12:10 ` Christoph Heiss
@ 2024-07-22 17:02 ` Thomas Lamprecht
  2024-07-23  7:50   ` Aaron Lauterer
  1 sibling, 1 reply; 5+ messages in thread
From: Thomas Lamprecht @ 2024-07-22 17:02 UTC (permalink / raw)
  To: Proxmox VE development discussion, Aaron Lauterer

Am 09/07/2024 um 13:41 schrieb Aaron Lauterer:
> By only setting propterties that have changed, we can avoid potential
> errors in the task.
> 
> For example, if one configures the "nosizechange" property on a pool, to
> prevent accidential size changes, the task will now only error if the
> user is actually trying to change the size.
> 
> Prior to this patch, we would always try to set all parameters, even if
> they were the same value. In the above example, this would result in the
> task ending in error state, as we are not allowed to change the size.
> 
> To disable size changing you can run the following command:
> ceph osd pool set {pool} nosizechange 1
> 
> Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
> ---
> 
> I am not sure if we want to log every property that is skipped. It makes
> visible what is done, but is also a bit noisy.
> 
>  PVE/Ceph/Tools.pm | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 


applied, thanks, one question still inline though.


> +	if (defined($current_properties->{$setting}) && $value eq $current_properties->{$setting}) {

hmm, might this cause trouble (or at least noisy warnings) with properties
that are defined as integers in the schema (if we even convert those, not
sure from top of my head) or is this always in string form here?

> +	    print "skipping '${setting}', did not change\n";
> +	    delete $param->{$setting};
> +	    next;
> +	}
> +
>  	print "pool $pool: applying $setting = $value\n";
>  	if (my $err = $set_pool_setting->($pool, $setting, $value, $rados)) {
>  	    print "$err";



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [pve-devel] applied: [PATCH manager] fix #5010: ceph: pool set only changed properties
  2024-07-22 17:02 ` [pve-devel] applied: " Thomas Lamprecht
@ 2024-07-23  7:50   ` Aaron Lauterer
  2024-07-23  7:54     ` Thomas Lamprecht
  0 siblings, 1 reply; 5+ messages in thread
From: Aaron Lauterer @ 2024-07-23  7:50 UTC (permalink / raw)
  To: Thomas Lamprecht, Proxmox VE development discussion



On  2024-07-22  19:02, Thomas Lamprecht wrote:
> 
> applied, thanks, one question still inline though.
> 
> 
>> +	if (defined($current_properties->{$setting}) && $value eq $current_properties->{$setting}) {
> hmm, might this cause trouble (or at least noisy warnings) with properties
> that are defined as integers in the schema (if we even convert those, not
> sure from top of my head) or is this always in string form here?

I might be missing some Perl intricacies here, but in all my tests it 
worked fine.

The following test also works:

perl -e 'use strict; use warnings; my $a = "1"; my $b = 1; if ($a eq $b) 
{ print "YAY" };'

Even if I set `$b = 1.0`


_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [pve-devel] applied: [PATCH manager] fix #5010: ceph: pool set only changed properties
  2024-07-23  7:50   ` Aaron Lauterer
@ 2024-07-23  7:54     ` Thomas Lamprecht
  0 siblings, 0 replies; 5+ messages in thread
From: Thomas Lamprecht @ 2024-07-23  7:54 UTC (permalink / raw)
  To: Aaron Lauterer, Proxmox VE development discussion

Am 23/07/2024 um 09:50 schrieb Aaron Lauterer:
> 
> 
> On  2024-07-22  19:02, Thomas Lamprecht wrote:
>>
>> applied, thanks, one question still inline though.
>>
>>
>>> +	if (defined($current_properties->{$setting}) && $value eq $current_properties->{$setting}) {
>> hmm, might this cause trouble (or at least noisy warnings) with properties
>> that are defined as integers in the schema (if we even convert those, not
>> sure from top of my head) or is this always in string form here?
> 
> I might be missing some Perl intricacies here, but in all my tests it 
> worked fine.
> 
> The following test also works:
> 
> perl -e 'use strict; use warnings; my $a = "1"; my $b = 1; if ($a eq $b) 
> { print "YAY" };'
> 
> Even if I set `$b = 1.0`

ah yeah, sorry for the noise, just a problem if the values might be `undef`


_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-07-23  7:54 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-09 11:41 [pve-devel] [PATCH manager] fix #5010: ceph: pool set only changed properties Aaron Lauterer
2024-07-10 12:10 ` Christoph Heiss
2024-07-22 17:02 ` [pve-devel] applied: " Thomas Lamprecht
2024-07-23  7:50   ` Aaron Lauterer
2024-07-23  7:54     ` Thomas Lamprecht

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal