mirror of
https://github.com/ceph/ceph
synced 2025-02-21 01:47:25 +00:00
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 <sage@redhat.com>
This commit is contained in:
parent
e293d40e6a
commit
904913b37f
@ -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.
|
||||
|
||||
|
@ -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
|
||||
|
@ -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")
|
||||
|
@ -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<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";
|
||||
|
||||
@ -7946,16 +7839,6 @@ done:
|
||||
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;
|
||||
}
|
||||
|
@ -131,11 +131,6 @@ private:
|
||||
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);
|
||||
|
@ -1121,9 +1121,6 @@ class TestOSD(TestArgparse):
|
||||
'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,
|
||||
|
Loading…
Reference in New Issue
Block a user