From 16a1deb5b3f276efe7dd3904c26786e6d837ddee Mon Sep 17 00:00:00 2001 From: Patrick Donnelly Date: Tue, 26 Nov 2019 12:49:01 -0800 Subject: [PATCH] mgr: drop session with Ceph daemon when not ready If the mgr is waiting on daemon metadata from the mons, it has no DaemonState associated with the daemon yet. If we try to process this MgrOpen, the metadata sent by the daemon (like its config) will not be recorded. Fixes: https://tracker.ceph.com/issues/43037 Signed-off-by: Patrick Donnelly --- src/mgr/DaemonServer.cc | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/mgr/DaemonServer.cc b/src/mgr/DaemonServer.cc index 334bc96ab69..7b81ffff027 100644 --- a/src/mgr/DaemonServer.cc +++ b/src/mgr/DaemonServer.cc @@ -400,12 +400,22 @@ bool DaemonServer::handle_open(const ref_t& m) if (daemon_state.exists(key)) { daemon = daemon_state.get(key); } - if (m->service_daemon && !daemon) { - dout(4) << "constructing new DaemonState for " << key << dendl; - daemon = std::make_shared(daemon_state.types); - daemon->key = key; - daemon->service_daemon = true; - daemon_state.insert(daemon); + if (!daemon) { + if (m->service_daemon) { + dout(4) << "constructing new DaemonState for " << key << dendl; + daemon = std::make_shared(daemon_state.types); + daemon->key = key; + daemon->service_daemon = true; + daemon_state.insert(daemon); + } else { + /* A normal Ceph daemon has connected but we are or should be waiting on + * metadata for it. Close the session so that it tries to reconnect. + */ + dout(2) << "ignoring open from " << key << " " << con->get_peer_addr() + << "; not ready for session (expect reconnect)" << dendl; + con->mark_down(); + return true; + } } if (daemon) { dout(20) << "updating existing DaemonState for " << m->daemon_name << dendl; -- 2.39.5