Skip to content

Commit

Permalink
mon/OSDMonitor: remove 'osd thrash' command
Browse files Browse the repository at this point in the history
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 <sage@redhat.com>
  • Loading branch information
liewegas committed Dec 19, 2016
1 parent e293d40 commit 904913b
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 136 deletions.
6 changes: 0 additions & 6 deletions doc/man/8/ceph.rst
Original file line number Diff line number Diff line change
Expand Up @@ -963,12 +963,6 @@ Usage::

ceph osd stat

Subcommand ``thrash`` thrashes OSDs for <num_epochs>.

Usage::

ceph osd thrash <int[0-]>

Subcommand ``tier`` is used for managing tiers. It uses some additional
subcommands.

Expand Down
2 changes: 0 additions & 2 deletions qa/workunits/cephtool/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions src/mon/MonCommands.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <num_epochs>", "osd", "rw", "cli,rest")
COMMAND("osd df " \
"name=output_method,type=CephChoices,strings=plain|tree,req=false", \
"show OSD utilization", "osd", "r", "cli,rest")
Expand Down
117 changes: 0 additions & 117 deletions src/mon/OSDMonitor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{}

Expand Down Expand Up @@ -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<pg_t,pg_stat_t>::iterator p = mon->pgmon()->pg_map.pg_stat.begin();
ceph::unordered_map<pg_t,pg_stat_t>::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<int> 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<int>::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";

Expand Down Expand Up @@ -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;
}
Expand Down
5 changes: 0 additions & 5 deletions src/mon/OSDMonitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 0 additions & 3 deletions src/test/pybind/test_ceph_argparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 904913b

Please sign in to comment.