From: Kefu Chai Date: Fri, 22 Sep 2017 04:30:41 +0000 (+0800) Subject: Merge pull request #17309 from jcsp/wip-daemonserver-locks X-Git-Tag: v13.0.1~835 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=fff6f2e812d6a513ea6320e01816e7304d899d73;p=ceph-ci.git Merge pull request #17309 from jcsp/wip-daemonserver-locks mgr: locking fixes Reviewed-by: Sage Weil --- fff6f2e812d6a513ea6320e01816e7304d899d73 diff --cc src/mgr/DaemonServer.cc index e1321f0b2a0,e384be395a6..88cf0285ef2 --- a/src/mgr/DaemonServer.cc +++ b/src/mgr/DaemonServer.cc @@@ -405,25 -417,35 +417,39 @@@ bool DaemonServer::handle_report(MMgrRe 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 assert(daemon != nullptr); - auto &daemon_counters = daemon->perf_counters; { Mutex::Locker l(daemon->lock); + auto &daemon_counters = daemon->perf_counters; daemon_counters.update(m); + + if (daemon->service_daemon) { + utime_t now = ceph_clock_now(); + if (m->daemon_status) { + daemon->service_status = *m->daemon_status; + daemon->service_status_stamp = now; + } + daemon->last_service_beacon = now; + } else if (m->daemon_status) { + derr << "got status from non-daemon " << key << dendl; + } } + // if there are any schema updates, notify the python modules if (!m->declare_types.empty() || !m->undeclare_types.empty()) { ostringstream oss;