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<DaemonState>(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<MgrSession*>(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;