From: Alwin Antreich <a.antreich@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH manager v2 8/8] fix: ceph: always set pool size first
Date: Tue, 24 Nov 2020 11:58:11 +0100 [thread overview]
Message-ID: <20201124105811.1416723-9-a.antreich@proxmox.com> (raw)
In-Reply-To: <20201124105811.1416723-1-a.antreich@proxmox.com>
Since Ceph Nautilus 14.2.10 and Octopus 15.2.2 the min_size of a pool is
calculated by the size (round(size / 2)). When size is applied after
min_size to the pool, the manual specified min_size will be overwritten.
With that a race condition can occur if the setting was set but is not
active yet. Run an extra rados command to verify the current setting.
Signed-off-by: Alwin Antreich <a.antreich@proxmox.com>
---
PVE/Ceph/Tools.pm | 49 +++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 47 insertions(+), 2 deletions(-)
diff --git a/PVE/Ceph/Tools.pm b/PVE/Ceph/Tools.pm
index d95e8676..9505f0bf 100644
--- a/PVE/Ceph/Tools.pm
+++ b/PVE/Ceph/Tools.pm
@@ -203,16 +203,51 @@ sub check_ceph_enabled {
sub set_pool {
my ($pool, $param) = @_;
+ # by default pool size always sets min_size
+ # https://tracker.ceph.com/issues/44862
+ my $rados = PVE::RADOS->new();
+ if ($param->{size}) {
+ my $value = $param->{size};
+ eval { $rados->mon_command({
+ prefix => "osd pool set",
+ pool => "$pool",
+ var => "size",
+ val => "$value",
+ format => 'plain',
+ });
+ };
+ if ($@) {
+ print "$@";
+ } else {
+ my $result;
+ eval { $result = $rados->mon_command({
+ prefix => "osd pool get",
+ pool => "$pool",
+ var => "size",
+ });
+ };
+ if (!$@ && $result->{size} eq $value) {
+ delete $param->{size};
+ }
+ }
+ }
+
foreach my $setting (keys %$param) {
my $value = $param->{$setting};
+ next if $setting eq 'size';
my $command;
+ my $verify;
if ($setting eq 'application') {
$command = {
prefix => "osd pool application enable",
pool => "$pool",
app => "$value",
};
+ $verify = {
+ prefix => "osd pool application get",
+ pool => "$pool",
+ };
} else {
$command = {
prefix => "osd pool set",
@@ -221,14 +256,24 @@ sub set_pool {
val => "$value",
format => 'plain',
};
+
+ $verify = {
+ prefix => "osd pool get",
+ pool => "$pool",
+ var => "$setting",
+ };
}
- my $rados = PVE::RADOS->new();
+ $rados = PVE::RADOS->new();
eval { $rados->mon_command($command); };
if ($@) {
print "$@";
} else {
- delete $param->{$setting};
+ my $result;
+ eval { $result = $rados->mon_command($verify); };
+ if (!$@ && $result->{$setting} eq $value) {
+ delete $param->{$setting};
+ }
}
}
--
2.27.0
next prev parent reply other threads:[~2020-11-24 10:58 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-24 10:58 [pve-devel] [PATCH manager v2 0/8] ceph: allow pools settings to be changed Alwin Antreich
2020-11-24 10:58 ` [pve-devel] [PATCH manager v2 1/8] api: ceph: subclass pools Alwin Antreich
2020-11-24 13:53 ` Dominik Csapak
2020-11-24 10:58 ` [pve-devel] [PATCH manager v2 2/8] ceph: add get api call for single pool Alwin Antreich
2020-11-24 13:53 ` Dominik Csapak
2020-11-24 10:58 ` [pve-devel] [PATCH manager v2 3/8] ceph: add autoscale_status to api calls Alwin Antreich
2020-11-24 13:53 ` Dominik Csapak
2020-11-24 10:58 ` [pve-devel] [PATCH manager v2 4/8] ceph: gui: add autoscale & flatten pool view Alwin Antreich
2020-11-24 13:53 ` Dominik Csapak
2020-11-24 10:58 ` [pve-devel] [PATCH manager v2 5/8] ceph: gui: rework pool input panel Alwin Antreich
2020-11-24 13:53 ` Dominik Csapak
2020-11-24 10:58 ` [pve-devel] [PATCH manager v2 6/8] ceph: schema: change min. required PG count Alwin Antreich
2020-11-24 10:58 ` [pve-devel] [PATCH manager v2 7/8] ceph: remove the pg_autoscale_mode default Alwin Antreich
2020-11-24 10:58 ` Alwin Antreich [this message]
2020-11-24 13:53 ` [pve-devel] [PATCH manager v2 0/8] ceph: allow pools settings to be changed Dominik Csapak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201124105811.1416723-9-a.antreich@proxmox.com \
--to=a.antreich@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.