From: Sage Weil Date: Tue, 18 Apr 2017 19:53:50 +0000 (-0400) Subject: mon/OSDMonitor: add mon_fake_pool_delete option X-Git-Tag: v12.0.3~28^2~12 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c378f14030b6e004fbb101f5c491fc7df7783270;p=ceph.git mon/OSDMonitor: add mon_fake_pool_delete option 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 --- diff --git a/src/common/config_opts.h b/src/common/config_opts.h index 976f06418dc8..56a74eec0df7 100644 --- a/src/common/config_opts.h +++ b/src/common/config_opts.h @@ -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 diff --git a/src/mon/MonCommands.h b/src/mon/MonCommands.h index 5857db47a4a8..8a0cb5f24c6d 100644 --- a/src/mon/MonCommands.h +++ b/src/mon/MonCommands.h @@ -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 " \ diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 379e229b1fe9..855b9eecc699 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -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(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; diff --git a/src/mon/OSDMonitor.h b/src/mon/OSDMonitor.h index c6735e365682..44f013f27f75 100644 --- a/src/mon/OSDMonitor.h +++ b/src/mon/OSDMonitor.h @@ -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); diff --git a/src/test/librados/test.cc b/src/test/librados/test.cc index afb855f3eed6..af34c3ac284f 100644 --- a/src/test/librados/test.cc +++ b/src/test/librados/test.cc @@ -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 #include @@ -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(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(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();