From 904913b37f241a73aa6722a18151d3166c8c93dd Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 8 Dec 2016 20:06:37 -0600 Subject: [PATCH] mon/OSDMonitor: remove 'osd thrash' command This is a dev hack to generate a bunch of bogus osdmaps. The maps are all screwed up anyway (e.g., invalid addrs) and this is minimally useful. Signed-off-by: Sage Weil --- doc/man/8/ceph.rst | 6 -- qa/workunits/cephtool/test.sh | 2 - src/mon/MonCommands.h | 3 - src/mon/OSDMonitor.cc | 117 -------------------------- src/mon/OSDMonitor.h | 5 -- src/test/pybind/test_ceph_argparse.py | 3 - 6 files changed, 136 deletions(-) diff --git a/doc/man/8/ceph.rst b/doc/man/8/ceph.rst index 53915c81ff962..1e3be526a9304 100644 --- a/doc/man/8/ceph.rst +++ b/doc/man/8/ceph.rst @@ -963,12 +963,6 @@ Usage:: ceph osd stat -Subcommand ``thrash`` thrashes OSDs for . - -Usage:: - - ceph osd thrash - Subcommand ``tier`` is used for managing tiers. It uses some additional subcommands. diff --git a/qa/workunits/cephtool/test.sh b/qa/workunits/cephtool/test.sh index 60fd51e30ee04..cdea16609711f 100755 --- a/qa/workunits/cephtool/test.sh +++ b/qa/workunits/cephtool/test.sh @@ -1127,8 +1127,6 @@ function test_mon_osd() done ceph osd dump | grep 'osd.0 up' - ceph osd thrash 0 - ceph osd dump | grep 'osd.0 up' # ceph osd find expects the OsdName, so both ints and osd.n should work. ceph osd find 1 diff --git a/src/mon/MonCommands.h b/src/mon/MonCommands.h index 5fa2079eed8c6..de9c8def8edc3 100644 --- a/src/mon/MonCommands.h +++ b/src/mon/MonCommands.h @@ -790,9 +790,6 @@ COMMAND("osd test-reweight-by-pg " \ "name=pools,type=CephPoolname,n=N,req=false", \ "dry run of reweight OSDs by PG distribution [overload-percentage-for-consideration, default 120]", \ "osd", "rw", "cli,rest") -COMMAND("osd thrash " \ - "name=num_epochs,type=CephInt,range=0", \ - "thrash OSDs for ", "osd", "rw", "cli,rest") COMMAND("osd df " \ "name=output_method,type=CephChoices,strings=plain|tree,req=false", \ "show OSD utilization", "osd", "r", "cli,rest") diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 861cb6b6060e7..ee87f14e78b9c 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -80,7 +80,6 @@ OSDMonitor::OSDMonitor(CephContext *cct, Monitor *mn, Paxos *p, const string& se cct(cct), inc_osd_cache(g_conf->mon_osd_cache_size), full_osd_cache(g_conf->mon_osd_cache_size), - thrash_map(0), thrash_last_up_osd(-1), op_tracker(cct, true, 1) {} @@ -346,116 +345,10 @@ void OSDMonitor::update_msgr_features() } } -bool OSDMonitor::thrash() -{ - if (!thrash_map) - return false; - - thrash_map--; - int o; - - int osd_num = osdmap.get_num_osds(); - if (osd_num == 0) - return false; - - // mark a random osd up_thru.. - if (rand() % 4 == 0 || thrash_last_up_osd < 0) - o = rand() % osd_num; - else - o = thrash_last_up_osd; - if (osdmap.is_up(o)) { - dout(5) << "thrash_map osd." << o << " up_thru" << dendl; - pending_inc.new_up_thru[o] = osdmap.get_epoch(); - } - - // mark a random osd up/down - o = rand() % osd_num; - if (osdmap.is_up(o)) { - dout(5) << "thrash_map osd." << o << " down" << dendl; - pending_inc.new_state[o] = CEPH_OSD_UP; - } else if (osdmap.exists(o)) { - dout(5) << "thrash_map osd." << o << " up" << dendl; - pending_inc.new_state[o] = CEPH_OSD_UP; - pending_inc.new_up_client[o] = entity_addr_t(); - pending_inc.new_up_cluster[o] = entity_addr_t(); - pending_inc.new_hb_back_up[o] = entity_addr_t(); - pending_inc.new_weight[o] = CEPH_OSD_IN; - thrash_last_up_osd = o; - } - - // mark a random osd in - o = rand() % osd_num; - if (osdmap.exists(o)) { - dout(5) << "thrash_map osd." << o << " in" << dendl; - pending_inc.new_weight[o] = CEPH_OSD_IN; - } - - // mark a random osd out - o = rand() % osd_num; - if (osdmap.exists(o)) { - dout(5) << "thrash_map osd." << o << " out" << dendl; - pending_inc.new_weight[o] = CEPH_OSD_OUT; - } - - // generate some pg_temp entries. - // let's assume the ceph::unordered_map iterates in a random-ish order. - int pg_num = mon->pgmon()->pg_map.pg_stat.size(); - if (pg_num == 0) - return true; - int n = rand() % pg_num; - ceph::unordered_map::iterator p = mon->pgmon()->pg_map.pg_stat.begin(); - ceph::unordered_map::iterator e = mon->pgmon()->pg_map.pg_stat.end(); - while (n--) - ++p; - - for (int i = std::min(pg_num, 50); i > 0; i--) { - unsigned size = osdmap.get_pg_size(p->first); - vector v; - bool have_real_osd = false; - for (int j=0; j < (int)size; j++) { - o = rand() % osd_num; - if (osdmap.exists(o) && std::find(v.begin(), v.end(), o) == v.end()) { - have_real_osd = true; - v.push_back(o); - } - } - for (vector::iterator q = p->second.acting.begin(); - q != p->second.acting.end() && v.size() < size; - ++q) { - if (std::find(v.begin(), v.end(), *q) == v.end()) { - if (*q != CRUSH_ITEM_NONE) - have_real_osd = true; - v.push_back(*q); - } - } - if (osdmap.pg_is_ec(p->first)) { - while (v.size() < size) - v.push_back(CRUSH_ITEM_NONE); - } - if (!v.empty() && have_real_osd) - pending_inc.new_pg_temp[p->first] = v; - dout(5) << "thrash_map pg " << p->first << " pg_temp remapped to " << v << dendl; - - ++p; - if (p == e) - p = mon->pgmon()->pg_map.pg_stat.begin(); - } - return true; -} - void OSDMonitor::on_active() { update_logger(); - if (thrash_map) { - if (mon->is_leader()) { - if (thrash()) - propose_pending(); - } else { - thrash_map = 0; - } - } - if (mon->is_leader()) mon->clog->info() << "osdmap " << osdmap << "\n"; @@ -7946,16 +7839,6 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, new Monitor::C_Command(mon, op, 0, rs, rdata, get_last_committed() + 1)); return true; } - } else if (prefix == "osd thrash") { - int64_t num_epochs; - cmd_getval(g_ceph_context, cmdmap, "num_epochs", num_epochs, int64_t(0)); - // thrash_map is a member var - thrash_map = num_epochs; - ss << "will thrash map for " << thrash_map << " epochs"; - ret = thrash(); - err = 0; - if (ret) - goto update; } else { err = -EINVAL; } diff --git a/src/mon/OSDMonitor.h b/src/mon/OSDMonitor.h index 103806175242a..17e504f4ee271 100644 --- a/src/mon/OSDMonitor.h +++ b/src/mon/OSDMonitor.h @@ -131,11 +131,6 @@ class OSDMonitor : public PaxosService { bool check_failure(utime_t now, int target_osd, failure_info_t& fi); void force_failure(utime_t now, int target_osd); - // map thrashing - int thrash_map; - int thrash_last_up_osd; - bool thrash(); - bool _have_pending_crush(); CrushWrapper &_get_stable_crush(); void _get_pending_crush(CrushWrapper& newcrush); diff --git a/src/test/pybind/test_ceph_argparse.py b/src/test/pybind/test_ceph_argparse.py index c34e0ea3acd38..f3bd7ee56334e 100755 --- a/src/test/pybind/test_ceph_argparse.py +++ b/src/test/pybind/test_ceph_argparse.py @@ -1121,9 +1121,6 @@ def test_reweight_by_utilization(self): '100', 'toomany'])) - def test_thrash(self): - self.check_1_natural_arg('osd', 'thrash') - def test_tier_op(self): for op in ('add', 'remove', 'set-overlay'): self.assert_valid_command(['osd', 'tier', op,