From: liuchang0812 Date: Thu, 24 Aug 2017 02:56:29 +0000 (+0800) Subject: mgr: kill MgrSession when MMgrReport come from daemon without metadata info X-Git-Tag: v13.0.1~855^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=29080134339e5e64d50af1db9fe50df7ea55c1d0;p=ceph.git mgr: kill MgrSession when MMgrReport come from daemon without metadata info Signed-off-by: liuchang0812 --- diff --git a/src/mgr/DaemonServer.cc b/src/mgr/DaemonServer.cc index c5f31c8503a6..48e0f9a4cca5 100644 --- a/src/mgr/DaemonServer.cc +++ b/src/mgr/DaemonServer.cc @@ -390,14 +390,18 @@ bool DaemonServer::handle_report(MMgrReport *m) dout(20) << "updating existing DaemonState for " << key << dendl; daemon = daemon_state.get(key); } else { - dout(4) << "constructing new DaemonState for " << key << dendl; - daemon = std::make_shared(daemon_state.types); - // FIXME: crap, we don't know the hostname at this stage. - daemon->key = key; - daemon_state.insert(daemon); - // FIXME: we should avoid this case by rejecting MMgrReport from - // daemons without sessions, and ensuring that session open - // always contains metadata. + // we don't know the hostname at this stage, reject MMgrReport here. + dout(1) << "rejecting report from " << key << ", since we do not have its metadata now." + << dendl; + // kill session + MgrSessionRef session(static_cast(m->get_connection()->get_priv())); + if (!session) { + return false; + } + m->get_connection()->mark_down(); + session->put(); + + return false; } assert(daemon != nullptr); auto &daemon_counters = daemon->perf_counters; diff --git a/src/mgr/Mgr.cc b/src/mgr/Mgr.cc index f138018f6ff7..edb93846851a 100644 --- a/src/mgr/Mgr.cc +++ b/src/mgr/Mgr.cc @@ -410,7 +410,7 @@ void Mgr::handle_osd_map() * reload the metadata. */ objecter->with_osdmap([this, &names_exist](const OSDMap &osd_map) { - for (unsigned int osd_id = 0; osd_id < osd_map.get_num_osds(); ++osd_id) { + for (unsigned int osd_id = 0; osd_id < osd_map.get_max_osd(); ++osd_id) { if (!osd_map.exists(osd_id)) { continue; }