* [pve-devel] [PATCH manager 1/2] ceph: split out pool set into own method
@ 2020-10-14 14:03 Alwin Antreich
2020-10-14 14:03 ` [pve-devel] [PATCH manager 2/2] ceph: add option pg_autoscale_mode on pool create Alwin Antreich
2020-10-15 9:49 ` [pve-devel] [PATCH manager 3/3] ceph: gui: add pg_autoscale_mode to pool creation Alwin Antreich
0 siblings, 2 replies; 3+ messages in thread
From: Alwin Antreich @ 2020-10-14 14:03 UTC (permalink / raw)
To: pve-devel
to reduce code duplication and make it easier to add more options for
pool commands.
Signed-off-by: Alwin Antreich <a.antreich@proxmox.com>
---
PVE/API2/Ceph.pm | 17 +++++++----
PVE/Ceph/Tools.pm | 74 +++++++++++++++++++++++++----------------------
2 files changed, 52 insertions(+), 39 deletions(-)
diff --git a/PVE/API2/Ceph.pm b/PVE/API2/Ceph.pm
index d7e5892c..48d0484f 100644
--- a/PVE/API2/Ceph.pm
+++ b/PVE/API2/Ceph.pm
@@ -751,14 +751,21 @@ __PACKAGE__->register_method ({
if !PVE::JSONSchema::parse_storage_id($pool);
}
- my $pg_num = $param->{pg_num} || 128;
- my $size = $param->{size} || 3;
- my $min_size = $param->{min_size} || 2;
- my $application = $param->{application} // 'rbd';
+ my $ceph_param = \%$param;
+ for my $item ('add_storages', 'name', 'node') {
+ # not ceph parameters
+ delete $ceph_param->{$item};
+ }
+
+ # pool defaults
+ $ceph_param->{pg_num} //= 128;
+ $ceph_param->{size} //= 3;
+ $ceph_param->{min_size} //= 2;
+ $ceph_param->{application} //= 'rbd';
my $worker = sub {
- PVE::Ceph::Tools::create_pool($pool, $param);
+ PVE::Ceph::Tools::create_pool($pool, $ceph_param);
if ($param->{add_storages}) {
my $err;
diff --git a/PVE/Ceph/Tools.pm b/PVE/Ceph/Tools.pm
index 2d8a4c1d..cc4238c9 100644
--- a/PVE/Ceph/Tools.pm
+++ b/PVE/Ceph/Tools.pm
@@ -202,6 +202,45 @@ sub check_ceph_enabled {
return 1;
}
+sub set_pool {
+ my ($pool, $param) = @_;
+
+ foreach my $setting (keys %$param) {
+ my $value = $param->{$setting};
+
+ my $command;
+ if ($setting eq 'application') {
+ $command = {
+ prefix => "osd pool application enable",
+ pool => "$pool",
+ app => "$value",
+ };
+ } else {
+ $command = {
+ prefix => "osd pool set",
+ pool => "$pool",
+ var => "$setting",
+ val => "$value",
+ format => 'plain',
+ };
+ }
+
+ my $rados = PVE::RADOS->new();
+ eval { $rados->mon_command($command); };
+ if ($@) {
+ print "$@";
+ } else {
+ delete $param->{$setting};
+ }
+ }
+
+ if ((keys %$param) > 0) {
+ my @missing = join(', ', keys %$param );
+ die "Could not set: @missing\n";
+ }
+
+}
+
sub create_pool {
my ($pool, $param, $rados) = @_;
@@ -210,9 +249,6 @@ sub create_pool {
}
my $pg_num = $param->{pg_num} || 128;
- my $size = $param->{size} || 3;
- my $min_size = $param->{min_size} || 2;
- my $application = $param->{application} // 'rbd';
$rados->mon_command({
prefix => "osd pool create",
@@ -221,37 +257,7 @@ sub create_pool {
format => 'plain',
});
- $rados->mon_command({
- prefix => "osd pool set",
- pool => $pool,
- var => 'min_size',
- val => "$min_size",
- format => 'plain',
- });
-
- $rados->mon_command({
- prefix => "osd pool set",
- pool => $pool,
- var => 'size',
- val => "$size",
- format => 'plain',
- });
-
- if (defined($param->{crush_rule})) {
- $rados->mon_command({
- prefix => "osd pool set",
- pool => $pool,
- var => 'crush_rule',
- val => $param->{crush_rule},
- format => 'plain',
- });
- }
-
- $rados->mon_command({
- prefix => "osd pool application enable",
- pool => $pool,
- app => $application,
- });
+ set_pool($pool, $param);
}
--
2.27.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* [pve-devel] [PATCH manager 2/2] ceph: add option pg_autoscale_mode on pool create
2020-10-14 14:03 [pve-devel] [PATCH manager 1/2] ceph: split out pool set into own method Alwin Antreich
@ 2020-10-14 14:03 ` Alwin Antreich
2020-10-15 9:49 ` [pve-devel] [PATCH manager 3/3] ceph: gui: add pg_autoscale_mode to pool creation Alwin Antreich
1 sibling, 0 replies; 3+ messages in thread
From: Alwin Antreich @ 2020-10-14 14:03 UTC (permalink / raw)
To: pve-devel
Different defaults for nautilus (warn) and octopus (on), more
conservative setting used.
Signed-off-by: Alwin Antreich <a.antreich@proxmox.com>
---
PVE/API2/Ceph.pm | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/PVE/API2/Ceph.pm b/PVE/API2/Ceph.pm
index 48d0484f..f8b1b22f 100644
--- a/PVE/API2/Ceph.pm
+++ b/PVE/API2/Ceph.pm
@@ -732,6 +732,13 @@ __PACKAGE__->register_method ({
type => 'boolean',
optional => 1,
},
+ pg_autoscale_mode => {
+ description => "The automatic PG scaling mode of the pool.",
+ type => 'string',
+ enum => ['on', 'off', 'warn'],
+ default => 'warn',
+ optional => 1,
+ },
},
},
returns => { type => 'string' },
@@ -762,6 +769,7 @@ __PACKAGE__->register_method ({
$ceph_param->{size} //= 3;
$ceph_param->{min_size} //= 2;
$ceph_param->{application} //= 'rbd';
+ $ceph_param->{pg_autoscale_mode} //= 'warn';
my $worker = sub {
--
2.27.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* [pve-devel] [PATCH manager 3/3] ceph: gui: add pg_autoscale_mode to pool creation
2020-10-14 14:03 [pve-devel] [PATCH manager 1/2] ceph: split out pool set into own method Alwin Antreich
2020-10-14 14:03 ` [pve-devel] [PATCH manager 2/2] ceph: add option pg_autoscale_mode on pool create Alwin Antreich
@ 2020-10-15 9:49 ` Alwin Antreich
1 sibling, 0 replies; 3+ messages in thread
From: Alwin Antreich @ 2020-10-15 9:49 UTC (permalink / raw)
To: pve-devel
Signed-off-by: Alwin Antreich <a.antreich@proxmox.com>
---
Note: I forgot to include the patch on the first send-email
www/manager6/ceph/Pool.js | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/www/manager6/ceph/Pool.js b/www/manager6/ceph/Pool.js
index 19eb01e9..11bcf9d5 100644
--- a/www/manager6/ceph/Pool.js
+++ b/www/manager6/ceph/Pool.js
@@ -39,6 +39,19 @@ Ext.define('PVE.CephCreatePool', {
name: 'crush_rule',
allowBlank: false
},
+ {
+ xtype: 'proxmoxKVComboBox',
+ fieldLabel: 'PG Autoscale Mode', // do not localize
+ name: 'pg_autoscale_mode',
+ comboItems: [
+ ['warn', 'warn'],
+ ['on', 'on'],
+ ['off', 'off'],
+ ],
+ value: 'warn',
+ allowBlank: false,
+ autoSelect: false,
+ },
{
xtype: 'proxmoxintegerfield',
fieldLabel: 'pg_num',
--
2.27.0
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-10-15 9:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-14 14:03 [pve-devel] [PATCH manager 1/2] ceph: split out pool set into own method Alwin Antreich
2020-10-14 14:03 ` [pve-devel] [PATCH manager 2/2] ceph: add option pg_autoscale_mode on pool create Alwin Antreich
2020-10-15 9:49 ` [pve-devel] [PATCH manager 3/3] ceph: gui: add pg_autoscale_mode to pool creation Alwin Antreich
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.