Skip to content

Commit

Permalink
mds: addr -> addrvec
Browse files Browse the repository at this point in the history
Update MDSMap to use entity_addrvec_t instead of entity_addr_t.  Adjust
the various mon and mgr pieces that touch it accordingly.

Signed-off-by: Sage Weil <[email protected]>
  • Loading branch information
liewegas committed Jul 3, 2018
1 parent 78edca9 commit ea1481d
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 46 deletions.
2 changes: 1 addition & 1 deletion src/ceph_mds.cc
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ int main(int argc, const char **argv)
forker.exit(1);
msgr->set_cluster_protocol(CEPH_MDS_PROTOCOL);

cout << "starting " << g_conf->name << " at " << msgr->get_myaddr()
cout << "starting " << g_conf->name << " at " << msgr->get_myaddrs()
<< std::endl;
uint64_t required =
CEPH_FEATURE_OSDREPLYMUX;
Expand Down
2 changes: 1 addition & 1 deletion src/mds/Beacon.cc
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ void Beacon::_send()
if (want_state == MDSMap::STATE_BOOT) {
map<string, string> sys_info;
collect_sys_info(&sys_info, cct);
sys_info["addr"] = stringify(monc->get_myaddr());
sys_info["addr"] = stringify(monc->get_myaddrs());
beacon->set_sys_info(sys_info);
}
monc->send_mon_message(beacon);
Expand Down
9 changes: 5 additions & 4 deletions src/mds/MDSDaemon.cc
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,7 @@ void MDSDaemon::handle_mds_map(MMDSMap *m)
return;
}

entity_addr_t addr;
entity_addrvec_t addrs;

// keep old map, for a moment
MDSMap *oldmap = mdsmap;
Expand Down Expand Up @@ -916,7 +916,7 @@ void MDSDaemon::handle_mds_map(MMDSMap *m)
++p) {
if (mdsmap->get_mds_info().count(p->first) == 0) {
dout(10) << " peer mds gid " << p->first << " removed from map" << dendl;
messenger->mark_down(p->second.addr);
messenger->mark_down_addrs(p->second.addrs);
}
}

Expand All @@ -926,8 +926,9 @@ void MDSDaemon::handle_mds_map(MMDSMap *m)
}

// see who i am
addr = messenger->get_myaddr();
dout(10) << "map says I am " << addr << " mds." << whoami << "." << incarnation
addrs = messenger->get_myaddrs();
dout(10) << "map says I am " << addrs
<< " mds." << whoami << "." << incarnation
<< " state " << ceph_mds_state_name(new_state) << dendl;

if (whoami == MDS_RANK_NONE) {
Expand Down
40 changes: 27 additions & 13 deletions src/mds/MDSMap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ void MDSMap::mds_info_t::dump(Formatter *f) const
f->dump_int("incarnation", inc);
f->dump_stream("state") << ceph_mds_state_name(state);
f->dump_int("state_seq", state_seq);
f->dump_stream("addr") << addr;
f->dump_stream("addr") << addrs.legacy_addr();
f->dump_object("addrs", addrs);
if (laggy_since != utime_t())
f->dump_stream("laggy_since") << laggy_since;

Expand All @@ -97,7 +98,7 @@ void MDSMap::mds_info_t::dump(Formatter *f) const
void MDSMap::mds_info_t::print_summary(ostream &out) const
{
out << global_id << ":\t"
<< addr
<< addrs
<< " '" << name << "'"
<< " mds." << rank
<< "." << inc
Expand Down Expand Up @@ -369,13 +370,17 @@ void MDSMap::get_health(list<pair<health_status_t,string> >& summary,
map<mds_gid_t,mds_info_t>::const_iterator info = mds_info.find(gid);
stringstream ss;
if (is_resolve(i))
ss << "mds." << info->second.name << " at " << info->second.addr << " rank " << i << " is resolving";
ss << "mds." << info->second.name << " at " << info->second.addrs
<< " rank " << i << " is resolving";
if (is_replay(i))
ss << "mds." << info->second.name << " at " << info->second.addr << " rank " << i << " is replaying journal";
ss << "mds." << info->second.name << " at " << info->second.addrs
<< " rank " << i << " is replaying journal";
if (is_rejoin(i))
ss << "mds." << info->second.name << " at " << info->second.addr << " rank " << i << " is rejoining";
ss << "mds." << info->second.name << " at " << info->second.addrs
<< " rank " << i << " is rejoining";
if (is_reconnect(i))
ss << "mds." << info->second.name << " at " << info->second.addr << " rank " << i << " is reconnecting to clients";
ss << "mds." << info->second.name << " at " << info->second.addrs
<< " rank " << i << " is reconnecting to clients";
if (ss.str().length())
detail->push_back(make_pair(HEALTH_WARN, ss.str()));
}
Expand Down Expand Up @@ -408,7 +413,8 @@ void MDSMap::get_health(list<pair<health_status_t,string> >& summary,
laggy.insert(mds_info.name);
if (detail) {
std::ostringstream oss;
oss << "mds." << mds_info.name << " at " << mds_info.addr << " is laggy/unresponsive";
oss << "mds." << mds_info.name << " at " << mds_info.addrs
<< " is laggy/unresponsive";
detail->push_back(make_pair(HEALTH_WARN, oss.str()));
}
}
Expand Down Expand Up @@ -460,7 +466,7 @@ void MDSMap::get_health_checks(health_check_map_t *checks) const
map<mds_gid_t,mds_info_t>::const_iterator info = mds_info.find(gid);
stringstream ss;
ss << "fs " << fs_name << " mds." << info->second.name << " at "
<< info->second.addr << " rank " << i;
<< info->second.addrs << " rank " << i;
if (is_resolve(i))
ss << " is resolving";
if (is_replay(i))
Expand Down Expand Up @@ -508,14 +514,22 @@ void MDSMap::get_health_checks(health_check_map_t *checks) const

void MDSMap::mds_info_t::encode_versioned(bufferlist& bl, uint64_t features) const
{
ENCODE_START(7, 4, bl);
__u8 v = 8;
if (!HAVE_FEATURE(features, SERVER_NAUTILUS)) {
v = 7;
}
ENCODE_START(v, 4, bl);
encode(global_id, bl);
encode(name, bl);
encode(rank, bl);
encode(inc, bl);
encode((int32_t)state, bl);
encode(state_seq, bl);
encode(addr, bl, features);
if (v < 8) {
encode(addrs.legacy_addr(), bl, features);
} else {
encode(addrs, bl, features);
}
encode(laggy_since, bl);
encode(standby_for_rank, bl);
encode(standby_for_name, bl);
Expand All @@ -537,7 +551,7 @@ void MDSMap::mds_info_t::encode_unversioned(bufferlist& bl) const
encode(inc, bl);
encode((int32_t)state, bl);
encode(state_seq, bl);
encode(addr, bl, 0);
encode(addrs.legacy_addr(), bl, 0);
encode(laggy_since, bl);
encode(standby_for_rank, bl);
encode(standby_for_name, bl);
Expand All @@ -546,14 +560,14 @@ void MDSMap::mds_info_t::encode_unversioned(bufferlist& bl) const

void MDSMap::mds_info_t::decode(bufferlist::const_iterator& bl)
{
DECODE_START_LEGACY_COMPAT_LEN(7, 4, 4, bl);
DECODE_START_LEGACY_COMPAT_LEN(8, 4, 4, bl);
decode(global_id, bl);
decode(name, bl);
decode(rank, bl);
decode(inc, bl);
decode((int32_t&)(state), bl);
decode(state_seq, bl);
decode(addr, bl);
decode(addrs, bl);
decode(laggy_since, bl);
decode(standby_for_rank, bl);
decode(standby_for_name, bl);
Expand Down
4 changes: 2 additions & 2 deletions src/mds/MDSMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class MDSMap {
int32_t inc;
MDSMap::DaemonState state;
version_t state_seq;
entity_addr_t addr;
entity_addrvec_t addrs;
utime_t laggy_since;
mds_rank_t standby_for_rank;
std::string standby_for_name;
Expand All @@ -146,7 +146,7 @@ class MDSMap {
void clear_laggy() { laggy_since = utime_t(); }

entity_addrvec_t get_addrs() const {
return entity_addrvec_t(addr);
return addrs;
}

void encode(bufferlist& bl, uint64_t features) const {
Expand Down
12 changes: 6 additions & 6 deletions src/mgr/Mgr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -579,12 +579,12 @@ void Mgr::handle_fs_map(MFSMap* m)
metadata->metadata.count("addr") == 0) {
update = true;
} else {
auto metadata_addr = metadata->metadata.at("addr");
const auto map_addr = info.addr;
update = metadata_addr != stringify(map_addr);
auto metadata_addrs = metadata->metadata.at("addr");
const auto map_addrs = info.addrs;
update = metadata_addrs != stringify(map_addrs);
if (update) {
dout(4) << "MDS[" << info.name << "] addr change " << metadata_addr
<< " != " << stringify(map_addr) << dendl;
dout(4) << "MDS[" << info.name << "] addr change " << metadata_addrs
<< " != " << stringify(map_addrs) << dendl;
}
}
} else {
Expand All @@ -596,7 +596,7 @@ void Mgr::handle_fs_map(MFSMap* m)

// Older MDS daemons don't have addr in the metadata, so
// fake it if the returned metadata doesn't have the field.
c->set_default("addr", stringify(info.addr));
c->set_default("addr", stringify(info.addrs));

std::ostringstream cmd;
cmd << "{\"prefix\": \"mds metadata\", \"who\": \""
Expand Down
42 changes: 23 additions & 19 deletions src/mon/MDSMonitor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ bool MDSMonitor::prepare_beacon(MonOpRequestRef op)
MMDSBeacon *m = static_cast<MMDSBeacon*>(op->get_req());
// -- this is an update --
dout(12) << "prepare_beacon " << *m << " from " << m->get_orig_source_inst() << dendl;
entity_addr_t addr = m->get_orig_source_inst().addr;
entity_addrvec_t addrs = m->get_orig_source_addrs();
mds_gid_t gid = m->get_global_id();
MDSMap::DaemonState state = m->get_state();
version_t seq = m->get_seq();
Expand Down Expand Up @@ -585,7 +585,7 @@ bool MDSMonitor::prepare_beacon(MonOpRequestRef op)
MDSMap::mds_info_t new_info;
new_info.global_id = gid;
new_info.name = m->get_name();
new_info.addr = addr;
new_info.addrs = addrs;
new_info.mds_features = m->get_mds_features();
new_info.state = MDSMap::STATE_STANDBY;
new_info.state_seq = seq;
Expand Down Expand Up @@ -649,7 +649,7 @@ bool MDSMonitor::prepare_beacon(MonOpRequestRef op)
}

if (info.laggy()) {
dout(10) << "prepare_beacon clearing laggy flag on " << addr << dendl;
dout(10) << "prepare_beacon clearing laggy flag on " << addrs << dendl;
pending.modify_daemon(info.global_id, [](MDSMap::mds_info_t *info)
{
info->clear_laggy();
Expand Down Expand Up @@ -698,7 +698,7 @@ bool MDSMonitor::prepare_beacon(MonOpRequestRef op)

utime_t until = ceph_clock_now();
until += g_conf->get_val<double>("mon_mds_blacklist_interval");
const auto blacklist_epoch = mon->osdmon()->blacklist(info.addr, until);
const auto blacklist_epoch = mon->osdmon()->blacklist(info.addrs, until);
request_proposal(mon->osdmon());
pending.damaged(gid, blacklist_epoch);
last_beacon.erase(gid);
Expand Down Expand Up @@ -1076,7 +1076,7 @@ bool MDSMonitor::fail_mds_gid(FSMap &fsmap, mds_gid_t gid)
if (info.rank >= 0 && info.state != MDSMap::STATE_STANDBY_REPLAY) {
utime_t until = ceph_clock_now();
until += g_conf->get_val<double>("mon_mds_blacklist_interval");
blacklist_epoch = mon->osdmon()->blacklist(info.addr, until);
blacklist_epoch = mon->osdmon()->blacklist(info.addrs, until);
}

fsmap.erase(gid, blacklist_epoch);
Expand Down Expand Up @@ -1484,7 +1484,8 @@ void MDSMonitor::check_sub(Subscription *sub)
// What (if any) namespace are you assigned to?
auto mds_info = fsmap.get_mds_info();
for (const auto &p : mds_info) {
if (p.second.addr == sub->session->inst.addr) {
#warning fixme
if (p.second.addrs.legacy_addr() == sub->session->inst.addr) {
mds_gid = p.first;
fscid = fsmap.mds_roles.at(mds_gid);
}
Expand Down Expand Up @@ -1737,7 +1738,7 @@ bool MDSMonitor::maybe_resize_cluster(FSMap &fsmap, fs_cluster_id_t fscid)
}

const auto &new_info = fsmap.get_info_gid(newgid);
dout(1) << "assigned standby " << new_info.addr
dout(1) << "assigned standby " << new_info.addrs
<< " as mds." << mds << dendl;

mon->clog->info() << new_info.human_name() << " assigned to "
Expand Down Expand Up @@ -1805,10 +1806,11 @@ void MDSMonitor::maybe_replace_gid(FSMap &fsmap, mds_gid_t gid,
{

MDSMap::mds_info_t si = fsmap.get_info_gid(sgid);
dout(10) << " replacing " << gid << " " << info.addr << " mds."
<< info.rank << "." << info.inc
<< " " << ceph_mds_state_name(info.state)
<< " with " << sgid << "/" << si.name << " " << si.addr << dendl;
dout(10) << " replacing " << gid << " " << info.addrs
<< " mds." << info.rank << "." << info.inc
<< " " << ceph_mds_state_name(info.state)
<< " with " << sgid << "/" << si.name << " " << si.addrs
<< dendl;

mon->clog->warn() << info.human_name()
<< " is not responding, replacing it "
Expand All @@ -1828,17 +1830,19 @@ void MDSMonitor::maybe_replace_gid(FSMap &fsmap, mds_gid_t gid,
*mds_propose = true;
} else if ((info.state == MDSMap::STATE_STANDBY_REPLAY ||
info.state == MDSMap::STATE_STANDBY) && may_replace) {
dout(10) << " failing and removing " << gid << " " << info.addr << " mds." << info.rank
<< "." << info.inc << " " << ceph_mds_state_name(info.state)
<< dendl;
dout(10) << " failing and removing " << gid << " " << info.addrs
<< " mds." << info.rank
<< "." << info.inc << " " << ceph_mds_state_name(info.state)
<< dendl;
mon->clog->info() << "Standby " << info.human_name() << " is not "
"responding, dropping it";
fail_mds_gid(fsmap, gid);
*mds_propose = true;
} else if (!info.laggy()) {
dout(10) << " marking " << gid << " " << info.addr << " mds." << info.rank << "." << info.inc
<< " " << ceph_mds_state_name(info.state)
<< " laggy" << dendl;
dout(10) << " marking " << gid << " " << info.addrs
<< " mds." << info.rank << "." << info.inc
<< " " << ceph_mds_state_name(info.state)
<< " laggy" << dendl;
fsmap.modify_daemon(info.global_id, [](MDSMap::mds_info_t *info) {
info->laggy_since = ceph_clock_now();
});
Expand Down Expand Up @@ -1866,7 +1870,7 @@ bool MDSMonitor::maybe_promote_standby(FSMap &fsmap, std::shared_ptr<Filesystem>
if (sgid) {
const MDSMap::mds_info_t si = fsmap.get_info_gid(sgid);
dout(0) << " taking over failed mds." << f << " with " << sgid
<< "/" << si.name << " " << si.addr << dendl;
<< "/" << si.name << " " << si.addrs << dendl;
mon->clog->info() << "Standby " << si.human_name()
<< " assigned to filesystem " << fs->mds_map.fs_name
<< " as rank " << f;
Expand Down Expand Up @@ -2031,7 +2035,7 @@ void MDSMonitor::tick()
if (since_last.count() >= g_conf->mds_beacon_grace) {
auto &info = pending.get_info_gid(gid);
dout(1) << "no beacon from mds." << info.rank << "." << info.inc
<< " (gid: " << gid << " addr: " << info.addr
<< " (gid: " << gid << " addr: " << info.addrs
<< " state: " << ceph_mds_state_name(info.state) << ")"
<< " since " << since_last.count() << "s" << dendl;
// If the OSDMap is writeable, we can blacklist things, so we can
Expand Down

0 comments on commit ea1481d

Please sign in to comment.