From: Greg Farnum Date: Tue, 7 Mar 2017 23:30:55 +0000 (-0800) Subject: MonClient: support "passthrough" of MonMap messages so other Dispatchers can see... X-Git-Tag: v12.1.0~288^2~129 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=8d803e0483d797fc87c0e58de28009ba296b7dfb;p=ceph-ci.git MonClient: support "passthrough" of MonMap messages so other Dispatchers can see them Use this in the Manager so it can notify of new monitor maps. Signed-off-by: Greg Farnum --- diff --git a/src/mgr/Mgr.cc b/src/mgr/Mgr.cc index 9df32239bd0..b4892c3f8ef 100644 --- a/src/mgr/Mgr.cc +++ b/src/mgr/Mgr.cc @@ -466,16 +466,6 @@ bool Mgr::ms_dispatch(Message *m) handle_mgr_digest(static_cast(m)); break; case CEPH_MSG_MON_MAP: - // FIXME: we probably never get called here because MonClient - // has consumed the message. For consuming OSDMap we need - // to be the tail dispatcher, but to see MonMap we would - // need to be at the head. - // Result is that ClusterState has access to monmap (it reads - // from monclient anyway), but we don't see notifications. Hook - // into MonClient to get notifications instead of messing - // with message delivery to achieve it? - ceph_abort(); - py_modules.notify_all("mon_map", ""); m->put(); break; diff --git a/src/mon/MonClient.cc b/src/mon/MonClient.cc index 73d1a110d02..cd749a012c7 100644 --- a/src/mon/MonClient.cc +++ b/src/mon/MonClient.cc @@ -48,7 +48,8 @@ MonClient::MonClient(CephContext *cct_) : Dispatcher(cct_), messenger(NULL), monc_lock("MonClient::monc_lock"), - timer(cct_, monc_lock), finisher(cct_), + timer(cct_, monc_lock), + finisher(cct_), initialized(false), no_keyring_disabled_cephx(false), log_client(NULL), @@ -267,6 +268,11 @@ bool MonClient::ms_dispatch(Message *m) switch (m->get_type()) { case CEPH_MSG_MON_MAP: handle_monmap(static_cast(m)); + if (passthrough_monmap) { + return false; + } else { + m->put(); + } break; case CEPH_MSG_AUTH_REPLY: handle_auth(static_cast(m)); @@ -311,6 +317,8 @@ void MonClient::flush_log() send_log(); } +/* Unlike all the other message-handling functions, we don't put away a reference +* because we want to support MMonMap passthrough to other Dispatchers. */ void MonClient::handle_monmap(MMonMap *m) { ldout(cct, 10) << __func__ << " " << *m << dendl; @@ -337,8 +345,6 @@ void MonClient::handle_monmap(MMonMap *m) map_cond.Signal(); want_monmap = false; - - m->put(); } // ---------------------- diff --git a/src/mon/MonClient.h b/src/mon/MonClient.h index be24d7a6706..283f2335c02 100644 --- a/src/mon/MonClient.h +++ b/src/mon/MonClient.h @@ -187,7 +187,8 @@ private: // monclient bool want_monmap; Cond map_cond; -private: + bool passthrough_monmap = false; + // authenticate std::unique_ptr auth; uint32_t want_keys = 0; @@ -339,6 +340,21 @@ public: int build_initial_monmap(); int get_monmap(); int get_monmap_privately(); + /** + * If you want to see MonMap messages, set this and + * the MonClient will tell the Messenger it hasn't + * dealt with it. + * Note that if you do this, *you* are of course responsible for + * putting the message reference! + */ + void set_passthrough_monmap() { + Mutex::Locker l(monc_lock); + passthrough_monmap = true; + } + void unset_passthrough_monmap() { + Mutex::Locker l(monc_lock); + passthrough_monmap = false; + } /** * Ping monitor with ID @p mon_id and record the resulting * reply in @p result_reply.