]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/OSDMonitor: accept 'autoscale_mode' argument to 'osd pool create'
authorSage Weil <sage@redhat.com>
Wed, 5 Feb 2020 22:54:00 +0000 (16:54 -0600)
committerSage Weil <sage@redhat.com>
Thu, 6 Feb 2020 13:04:00 +0000 (07:04 -0600)
Allow the autoscale mode to be set atomically with pool creation.

Fixes: https://tracker.ceph.com/issues/42638
Signed-off-by: Sage Weil <sage@redhat.com>
qa/workunits/cephtool/test.sh
src/mon/MonCommands.h
src/mon/OSDMonitor.cc
src/mon/OSDMonitor.h

index 4828e198f23496551a4feca115cbf6255686f6ee..9a3a98b8dca16b9a190274febd1626ad1383fbb6 100755 (executable)
@@ -1945,6 +1945,16 @@ function test_mon_osd_pool()
   ceph osd crush rule rm foo
   ceph osd erasure-code-profile rm foo
 
+  # autoscale mode
+  ceph osd pool create modeon --autoscale-mode=on
+  ceph osd dump | grep modeon | grep 'autoscale_mode on'
+  ceph osd pool create modewarn --autoscale-mode=warn
+  ceph osd dump | grep modewarn | grep 'autoscale_mode warn'
+  ceph osd pool create modeoff --autoscale-mode=off
+  ceph osd dump | grep modeoff | grep 'autoscale_mode off'
+  ceph osd pool delete modeon modeon --yes-i-really-really-mean-it
+  ceph osd pool delete modewarn modewarn --yes-i-really-really-mean-it
+  ceph osd pool delete modeoff modeoff --yes-i-really-really-mean-it
 }
 
 function test_mon_osd_pool_quota()
index b05253339896e0c65f8451528e5c6b72936e89e1..4f2ffa9324018473934ecf3c20cad0596a12dfbd 100644 (file)
@@ -999,6 +999,7 @@ COMMAND("osd pool create "
         "name=expected_num_objects,type=CephInt,range=0,req=false "
         "name=size,type=CephInt,range=0,req=false "
        "name=pg_num_min,type=CephInt,range=0,req=false "
+       "name=autoscale_mode,type=CephChoices,strings=on|off|warn,req=false "
        "name=target_size_bytes,type=CephInt,range=0,req=false "
        "name=target_size_ratio,type=CephFloat,range=0|1,req=false",\
        "create pool", "osd", "rw")
index 25c8fa2bc5938ee00a6eeeb653428ad063f98748..8761d77a9b045ddb20976f6d30157779dc8f02f0 100644 (file)
@@ -7100,7 +7100,8 @@ int OSDMonitor::prepare_new_pool(MonOpRequestRef op)
   ret = prepare_new_pool(m->name, m->crush_rule, rule_name,
                         0, 0, 0, 0, 0, 0.0,
                         erasure_code_profile,
-                        pg_pool_t::TYPE_REPLICATED, 0, FAST_READ_OFF, &ss);
+                        pg_pool_t::TYPE_REPLICATED, 0, FAST_READ_OFF, {},
+                        &ss);
 
   if (ret < 0) {
     dout(10) << __func__ << " got " << ret << " " << ss.str() << dendl;
@@ -7632,6 +7633,7 @@ int OSDMonitor::prepare_new_pool(string& name,
                                  const unsigned pool_type,
                                  const uint64_t expected_num_objects,
                                  FastReadType fast_read,
+                                const string& pg_autoscale_mode,
                                 ostream *ss)
 {
   if (name.length() == 0)
@@ -7781,6 +7783,10 @@ int OSDMonitor::prepare_new_pool(string& name,
       pg_num_min) {
     pi->opts.set(pool_opts_t::PG_NUM_MIN, static_cast<int64_t>(pg_num_min));
   }
+  if (auto m = pg_pool_t::get_pg_autoscale_mode_by_name(
+       pg_autoscale_mode); m != pg_pool_t::pg_autoscale_mode_t::UNKNOWN) {
+    pi->pg_autoscale_mode = m;
+  }
 
   pi->last_change = pending_inc.epoch;
   pi->auid = 0;
@@ -12538,6 +12544,9 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op,
     cmd_getval(cmdmap, "target_size_bytes", target_size_bytes);
     cmd_getval(cmdmap, "target_size_ratio", target_size_ratio);
 
+    string pg_autoscale_mode;
+    cmd_getval(cmdmap, "autoscale_mode", pg_autoscale_mode);
+
     err = prepare_new_pool(poolstr,
                           -1, // default crush rule
                           rule_name,
@@ -12546,6 +12555,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op,
                           erasure_code_profile, pool_type,
                            (uint64_t)expected_num_objects,
                            fast_read,
+                          pg_autoscale_mode,
                           &ss);
     if (err < 0) {
       switch(err) {
index 14cf446de0244b7c68456d338126a89d8ab4c8c8..2b3a47bfc1b1866baaacea822fe4c32fb7e07631 100644 (file)
@@ -531,6 +531,7 @@ private:
                        const unsigned pool_type,
                        const uint64_t expected_num_objects,
                        FastReadType fast_read,
+                      const string& pg_autoscale_mode,
                       ostream *ss);
   int prepare_new_pool(MonOpRequestRef op);