Skip to content

Commit

Permalink
mon: create fail_mds_gid() helper; make 'ceph mds rm ...' more generic
Browse files Browse the repository at this point in the history
Take a gid or a rank or a name.  Use a nicer helper.

Signed-off-by: Sage Weil <sage@inktank.com>
  • Loading branch information
Sage Weil committed Jan 18, 2013
1 parent 5a384f4 commit e330b7e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 12 deletions.
36 changes: 24 additions & 12 deletions src/mon/MDSMonitor.cc
Expand Up @@ -672,10 +672,28 @@ bool MDSMonitor::preprocess_command(MMonCommand *m)
return false;
}

void MDSMonitor::fail_mds_gid(uint64_t gid)
{
assert(pending_mdsmap.mds_info.count(gid));
MDSMap::mds_info_t& info = pending_mdsmap.mds_info[gid];
utime_t until = ceph_clock_now(g_ceph_context);
until += g_conf->mds_blacklist_interval;

pending_mdsmap.last_failure_osd_epoch = mon->osdmon()->blacklist(info.addr, until);
mon->osdmon()->propose_pending();

if (info.rank >= 0) {
pending_mdsmap.up.erase(info.rank);
pending_mdsmap.failed.insert(info.rank);
}

pending_mdsmap.mds_info.erase(gid);
}

int MDSMonitor::fail_mds(std::ostream &ss, const std::string &arg)
{
std::string err;
int w = strict_strtol(arg.c_str(), 10, &err);
int w = strict_strtoll(arg.c_str(), 10, &err);
if (!err.empty()) {
// Try to interpret the arg as an MDS name
const MDSMap::mds_info_t *mds_info = mdsmap.find_by_name(arg);
Expand All @@ -688,18 +706,12 @@ int MDSMonitor::fail_mds(std::ostream &ss, const std::string &arg)

if (pending_mdsmap.up.count(w)) {
uint64_t gid = pending_mdsmap.up[w];
if (pending_mdsmap.mds_info.count(gid)) {
utime_t until = ceph_clock_now(g_ceph_context);
until += g_conf->mds_blacklist_interval;
MDSMap::mds_info_t& info = pending_mdsmap.mds_info[pending_mdsmap.up[w]];
pending_mdsmap.last_failure_osd_epoch = mon->osdmon()->blacklist(info.addr, until);
mon->osdmon()->propose_pending();

pending_mdsmap.mds_info.erase(gid);
}
pending_mdsmap.up.erase(w);
pending_mdsmap.failed.insert(w);
if (pending_mdsmap.mds_info.count(gid))
fail_mds_gid(gid);
ss << "failed mds." << w;
} else if (pending_mdsmap.mds_info.count(w)) {
fail_mds_gid(w);
ss << "failed mds gid " << w;
}
return 0;
}
Expand Down
2 changes: 2 additions & 0 deletions src/mon/MDSMonitor.h
Expand Up @@ -96,6 +96,8 @@ class MDSMonitor : public PaxosService {
void get_health(list<pair<health_status_t,string> >& summary,
list<pair<health_status_t,string> > *detail) const;
int fail_mds(std::ostream &ss, const std::string &arg);
void fail_mds_gid(uint64_t gid);

int cluster_fail(std::ostream &ss);

bool preprocess_command(MMonCommand *m);
Expand Down

0 comments on commit e330b7e

Please sign in to comment.