]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr: have MgrStandby send mgr reports to active mgr (even self!)
authorSage Weil <sage@redhat.com>
Fri, 5 Jan 2018 20:55:12 +0000 (14:55 -0600)
committerSage Weil <sage@redhat.com>
Tue, 6 Mar 2018 20:44:48 +0000 (14:44 -0600)
This allows the mgr daemons to register state with the active mgr just
like the rest of the cluster, including perfcounters and current config.

Signed-off-by: Sage Weil <sage@redhat.com>
src/mgr/DaemonServer.cc
src/mgr/DaemonServer.h
src/mgr/Mgr.cc
src/mgr/MgrStandby.cc
src/mgr/MgrStandby.h

index f57933deb04a968745e6ea52917254da5ddf826b..0f1cafad7afd72309b9b3165486647d20d3d87b9 100644 (file)
@@ -1662,6 +1662,34 @@ void DaemonServer::got_service_map()
   }
 }
 
+void DaemonServer::got_mgr_map()
+{
+  Mutex::Locker l(lock);
+  set<std::string> have;
+  cluster_state.with_mgrmap([&](const MgrMap& mgrmap) {
+      if (mgrmap.active_name.size()) {
+       DaemonKey key("mgr", mgrmap.active_name);
+       have.insert(mgrmap.active_name);
+       if (!daemon_state.exists(key)) {
+         auto daemon = std::make_shared<DaemonState>(daemon_state.types);
+         daemon->key = key;
+         daemon_state.insert(daemon);
+         dout(10) << "added missing " << key << dendl;
+       }
+      }
+      for (auto& i : mgrmap.standbys) {
+       DaemonKey key("mgr", i.second.name);
+       have.insert(i.second.name);
+       if (!daemon_state.exists(key)) {
+         auto daemon = std::make_shared<DaemonState>(daemon_state.types);
+         daemon->key = key;
+         daemon_state.insert(daemon);
+         dout(10) << "added missing " << key << dendl;
+       }
+      }
+    });
+  daemon_state.cull("mgr", have);
+}
 
 const char** DaemonServer::get_tracked_conf_keys() const
 {
index 9c0575461d2bb2e74d001a14d8df8fa3276f2a7e..6a01714c4f010dd5bd42de48347a54b8390386b8 100644 (file)
@@ -136,6 +136,7 @@ public:
   bool handle_command(MCommand *m);
   void send_report();
   void got_service_map();
+  void got_mgr_map();
 
   void _send_configure(ConnectionRef c);
 
index e2b73fdee64d644275a4b17a30f4d3e3ca588b28..0c901a6933e2b259455eac6712d9f08b161c044e 100644 (file)
@@ -593,6 +593,7 @@ bool Mgr::got_mgr_map(const MgrMap& m)
   }
 
   cluster_state.set_mgr_map(m);
+  server.got_mgr_map();
 
   return false;
 }
index 2172dbc5e5f1449f56266891bdbe163ddfadf9c8..0cb1ab2ac4b01bb4c90585437b76353f1b1c515f 100644 (file)
 MgrStandby::MgrStandby(int argc, const char **argv) :
   Dispatcher(g_ceph_context),
   monc{g_ceph_context},
-  client_messenger(Messenger::create_client_messenger(g_ceph_context, "mgr")),
+  client_messenger(Messenger::create(
+                    g_ceph_context,
+                    cct->_conf->get_val<std::string>("ms_type"),
+                    entity_name_t::MGR(),
+                    "mgr",
+                    getpid(),
+                    0)),
   objecter{g_ceph_context, client_messenger.get(), &monc, NULL, 0, 0},
   client{client_messenger.get(), &monc, &objecter},
+  mgrc(g_ceph_context, client_messenger.get()),
   log_client(g_ceph_context, client_messenger.get(), &monc.monmap, LogClient::NO_FLAGS),
   clog(log_client.create_channel(CLOG_CHANNEL_CLUSTER)),
   audit_clog(log_client.create_channel(CLOG_CHANNEL_AUDIT)),
@@ -125,6 +132,9 @@ int MgrStandby::init()
     client_messenger->wait();
     return r;
   }
+  mgrc.init();
+  client_messenger->add_dispatcher_tail(&mgrc);
+
   r = monc.authenticate();
   if (r < 0) {
     derr << "Authentication failed, did you specify a mgr ID with a valid keyring?" << dendl;
@@ -135,7 +145,7 @@ int MgrStandby::init()
   }
 
   client_t whoami = monc.get_global_id();
-  client_messenger->set_myname(entity_name_t::CLIENT(whoami.v));
+  client_messenger->set_myname(entity_name_t::MGR(whoami.v));
   monc.set_log_client(&log_client);
   _update_log_config();
   objecter.set_client_incarnation(0);
@@ -241,6 +251,7 @@ void MgrStandby::shutdown()
   timer.shutdown();
   // client uses monc and objecter
   client.shutdown();
+  mgrc.shutdown();
   // stop monc, so mon won't be able to instruct me to shutdown/activate after
   // the active_mgr is stopped
   monc.shutdown();
@@ -380,8 +391,6 @@ void MgrStandby::handle_mgr_map(MMgrMap* mmap)
       }
     }
   }
-
-  mmap->put();
 }
 
 bool MgrStandby::ms_dispatch(Message *m)
@@ -391,16 +400,19 @@ bool MgrStandby::ms_dispatch(Message *m)
 
   if (m->get_type() == MSG_MGR_MAP) {
     handle_mgr_map(static_cast<MMgrMap*>(m));
-    return true;
-  } else if (active_mgr) {
+  }
+  bool handled = false;
+  if (active_mgr) {
     auto am = active_mgr;
     lock.Unlock();
-    bool handled = am->ms_dispatch(m);
+    handled = am->ms_dispatch(m);
     lock.Lock();
-    return handled;
-  } else {
-    return false;
   }
+  if (m->get_type() == MSG_MGR_MAP && !handled) {
+    m->put();
+    handled = true;
+  }
+  return handled;
 }
 
 
index a64fd7e99958c4f164dd9fe3aee6e8d6fc30fb46..4d4cc364c312e723dbd412335a10bacc6cf9031a 100644 (file)
@@ -24,7 +24,7 @@
 #include "mon/MonClient.h"
 #include "osdc/Objecter.h"
 #include "PyModuleRegistry.h"
-
+#include "MgrClient.h"
 
 class MMgrMap;
 class Mgr;
@@ -43,6 +43,8 @@ protected:
   Objecter objecter;
   Client client;
 
+  MgrClient mgrc;
+
   LogClient log_client;
   LogChannelRef clog, audit_clog;