fix #5010: ceph: pool set only changed properties

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

For example, if one configures the "nosizechange" property on a pool,
to prevent accidental 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>
This commit is contained in:
Aaron Lauterer 2024-07-09 13:41:16 +02:00 committed by Thomas Lamprecht
parent d69d4ed8cb
commit 76ed490012

View File

@ -285,9 +285,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";