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: v12.2.3~106^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e97ad14cdc22c0da907fabc48d62698c94f6ba66;p=ceph.git mgr: kill MgrSession when MMgrReport come from daemon without metadata info Signed-off-by: liuchang0812 (cherry picked from commit 29080134339e5e64d50af1db9fe50df7ea55c1d0) --- diff --git a/src/mgr/DaemonServer.cc b/src/mgr/DaemonServer.cc index 321a38ad5349..e612086ad3ec 100644 --- a/src/mgr/DaemonServer.cc +++ b/src/mgr/DaemonServer.cc @@ -416,14 +416,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; } // Update the DaemonState diff --git a/src/mgr/Mgr.cc b/src/mgr/Mgr.cc index 2ed89636f6b9..7615bd647cd1 100644 --- a/src/mgr/Mgr.cc +++ b/src/mgr/Mgr.cc @@ -412,7 +412,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; }