]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/OSDMonitor: add mon_fake_pool_delete option
authorSage Weil <sage@redhat.com>
Tue, 18 Apr 2017 19:53:50 +0000 (15:53 -0400)
committerSage Weil <sage@redhat.com>
Fri, 5 May 2017 17:39:13 +0000 (13:39 -0400)
Instead of deleting a pool, add a .NNN.DELETED suffix to the end.  This
keeps the data around long enough for it to be scrubbed later (in the
case of a teuthology job cleanup).

If you really want to delete the pool, then instead of the usual force
flag option you can pass --yes-i-really-really-mean-it-not-faking.  :)

Signed-off-by: Sage Weil <sage@redhat.com>
src/common/config_opts.h
src/mon/MonCommands.h
src/mon/OSDMonitor.cc
src/mon/OSDMonitor.h
src/test/librados/test.cc

index 976f06418dc8a0df8b0211ecc37e8f2e4576c6b5..56a74eec0df78f716c26a133809b31df25a27509 100644 (file)
@@ -321,6 +321,7 @@ OPTION(mon_osd_full_ratio, OPT_FLOAT, .95) // what % full makes an OSD "full"
 OPTION(mon_osd_backfillfull_ratio, OPT_FLOAT, .90) // what % full makes an OSD backfill full (backfill halted)
 OPTION(mon_osd_nearfull_ratio, OPT_FLOAT, .85) // what % full makes an OSD near full
 OPTION(mon_allow_pool_delete, OPT_BOOL, false) // allow pool deletion
+OPTION(mon_fake_pool_delete, OPT_BOOL, false)  // fake pool deletion (add _DELETED suffix)
 OPTION(mon_globalid_prealloc, OPT_U32, 10000)   // how many globalids to prealloc
 OPTION(mon_osd_report_timeout, OPT_INT, 900)    // grace period before declaring unresponsive OSDs dead
 OPTION(mon_force_standby_active, OPT_BOOL, true) // should mons force standby-replay mds to be active
index 5857db47a4a872f9bce3adf4ae7051403a735a53..8a0cb5f24c6db5ad135b513b0ed83419012d9292 100644 (file)
@@ -727,7 +727,7 @@ COMMAND("osd pool delete " \
 COMMAND("osd pool rm " \
        "name=pool,type=CephPoolname " \
        "name=pool2,type=CephPoolname,req=false " \
-       "name=sure,type=CephChoices,strings=--yes-i-really-really-mean-it,req=false", \
+       "name=sure,type=CephString,req=false", \
        "remove pool", \
        "osd", "rw", "cli,rest")
 COMMAND("osd pool rename " \
index 379e229b1fe93f2d7321a77013f04fc6c2beff36..855b9eecc6996358f676c9f5b55ed76437b88f24 100644 (file)
@@ -8308,14 +8308,16 @@ done:
       goto reply;
     }
 
-    if (poolstr2 != poolstr || sure != "--yes-i-really-really-mean-it") {
+    bool force_no_fake = sure == "--yes-i-really-really-mean-it-not-faking";
+    if (poolstr2 != poolstr ||
+       (sure != "--yes-i-really-really-mean-it" && !force_no_fake)) {
       ss << "WARNING: this will *PERMANENTLY DESTROY* all data stored in pool " << poolstr
         << ".  If you are *ABSOLUTELY CERTAIN* that is what you want, pass the pool name *twice*, "
         << "followed by --yes-i-really-really-mean-it.";
       err = -EPERM;
       goto reply;
     }
-    err = _prepare_remove_pool(pool, &ss);
+    err = _prepare_remove_pool(pool, &ss, force_no_fake);
     if (err == -EAGAIN) {
       wait_for_finished_proposal(op, new C_RetryMessage(this, op));
       return true;
@@ -9379,7 +9381,8 @@ bool OSDMonitor::_check_remove_tier(
   return true;
 }
 
-int OSDMonitor::_prepare_remove_pool(int64_t pool, ostream *ss)
+int OSDMonitor::_prepare_remove_pool(
+  int64_t pool, ostream *ss, bool no_fake)
 {
   dout(10) << "_prepare_remove_pool " << pool << dendl;
   const pg_pool_t *p = osdmap.get_pg_pool(pool);
@@ -9403,6 +9406,15 @@ int OSDMonitor::_prepare_remove_pool(int64_t pool, ostream *ss)
     return 0;
   }
 
+  if (g_conf->mon_fake_pool_delete && !no_fake) {
+    string old_name = osdmap.get_pool_name(pool);
+    string new_name = old_name + "." + stringify(pool) + ".DELETED";
+    dout(1) << __func__ << " faking pool deletion: renaming " << pool << " "
+           << old_name << " -> " << new_name << dendl;
+    pending_inc.new_pool_names[pool] = new_name;
+    return 0;
+  }
+
   // remove
   pending_inc.old_pools.insert(pool);
 
@@ -9452,7 +9464,7 @@ bool OSDMonitor::prepare_pool_op_delete(MonOpRequestRef op)
   op->mark_osdmon_event(__func__);
   MPoolOp *m = static_cast<MPoolOp*>(op->get_req());
   ostringstream ss;
-  int ret = _prepare_remove_pool(m->pool, &ss);
+  int ret = _prepare_remove_pool(m->pool, &ss, false);
   if (ret == -EAGAIN) {
     wait_for_finished_proposal(op, new C_RetryMessage(this, op));
     return true;
index c6735e365682715c262d674c3265b8a02679144e..44f013f27f756c15221ffb47c2c570ca9a592900 100644 (file)
@@ -299,7 +299,7 @@ private:
       int64_t base_pool_id, const pg_pool_t *base_pool, const pg_pool_t *tier_pool,
       int *err, ostream *ss) const;
 
-  int _prepare_remove_pool(int64_t pool, ostream *ss);
+  int _prepare_remove_pool(int64_t pool, ostream *ss, bool no_fake);
   int _prepare_rename_pool(int64_t pool, string newname);
 
   bool preprocess_pool_op (MonOpRequestRef op);
index afb855f3eed6b17194c3d1769d4c37727dacd799..af34c3ac284f469e895fbfed6d7f3986ca1498eb 100644 (file)
@@ -9,6 +9,8 @@
 #include "common/Formatter.h"
 #include "json_spirit/json_spirit.h"
 #include "common/errno.h"
+#include "common/ceph_context.h"
+#include "common/config.h"
 
 #include <errno.h>
 #include <sstream>
@@ -447,11 +449,14 @@ int destroy_one_ec_pool(const std::string &pool_name, rados_t *cluster)
     return ret;
   }
 
-  std::ostringstream oss;
-  ret = destroy_ec_profile_and_ruleset(cluster, pool_name, oss);
-  if (ret) {
-    rados_shutdown(*cluster);
-    return ret;
+  CephContext *cct = static_cast<CephContext*>(rados_cct(*cluster));
+  if (!cct->_conf->mon_fake_pool_delete) { // hope this is in [global]
+    std::ostringstream oss;
+    ret = destroy_ec_profile_and_ruleset(cluster, pool_name, oss);
+    if (ret) {
+      rados_shutdown(*cluster);
+      return ret;
+    }
   }
 
   rados_wait_for_latest_osdmap(*cluster);
@@ -478,11 +483,14 @@ int destroy_one_ec_pool_pp(const std::string &pool_name, Rados &cluster)
     return ret;
   }
 
-  std::ostringstream oss;
-  ret = destroy_ec_profile_and_ruleset_pp(cluster, pool_name, oss);
-  if (ret) {
-    cluster.shutdown();
-    return ret;
+  CephContext *cct = static_cast<CephContext*>(cluster.cct());
+  if (!cct->_conf->mon_fake_pool_delete) { // hope this is in [global]
+    std::ostringstream oss;
+    ret = destroy_ec_profile_and_ruleset_pp(cluster, pool_name, oss);
+    if (ret) {
+      cluster.shutdown();
+      return ret;
+    }
   }
 
   cluster.wait_for_latest_osdmap();