]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
MonClient: support "passthrough" of MonMap messages so other Dispatchers can see...
authorGreg Farnum <gfarnum@redhat.com>
Tue, 7 Mar 2017 23:30:55 +0000 (15:30 -0800)
committerSage Weil <sage@redhat.com>
Fri, 2 Jun 2017 16:58:14 +0000 (12:58 -0400)
Use this in the Manager so it can notify of new monitor maps.

Signed-off-by: Greg Farnum <gfarnum@redhat.com>
src/mgr/Mgr.cc
src/mon/MonClient.cc
src/mon/MonClient.h

index 9df32239bd0bc04b8e6f225558a45c8139755d87..b4892c3f8efda143baf93e978a0289f64b502d07 100644 (file)
@@ -466,16 +466,6 @@ bool Mgr::ms_dispatch(Message *m)
       handle_mgr_digest(static_cast<MMgrDigest*>(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;
index 73d1a110d0241c9e1b410c55c211c643eea50415..cd749a012c78b1795c87f5c78443de9366d8ae86 100644 (file)
@@ -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<MMonMap*>(m));
+    if (passthrough_monmap) {
+      return false;
+    } else {
+      m->put();
+    }
     break;
   case CEPH_MSG_AUTH_REPLY:
     handle_auth(static_cast<MAuthReply*>(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();
 }
 
 // ----------------------
index be24d7a67065b3fe0092158112b06bbad0767945..283f2335c0287f91a7d1695962ff11678f51531c 100644 (file)
@@ -187,7 +187,8 @@ private:
   // monclient
   bool want_monmap;
   Cond map_cond;
-private:
+  bool passthrough_monmap = false;
+
   // authenticate
   std::unique_ptr<AuthClientHandler> 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.