]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr: request mon metadata when receiving a report msg from an unknown monitor
authorcfanz <songxinying@sensetime.com>
Sun, 30 Dec 2018 03:49:58 +0000 (11:49 +0800)
committerXinying Song <songxinying@sensetime.com>
Tue, 15 Jan 2019 10:51:35 +0000 (18:51 +0800)
* Mgr needs to issue an metadata request when receiving a report message
  from a monitor who hasn't been in the mgr's daemon_state. Otherwise the
  connection between mgr and monitor cannot be established.

Fixes: http://tracker.ceph.com/issues/37753
Signed-off-by: Xinying Song <songxinying@sensetime.com>
src/mgr/DaemonServer.cc
src/mgr/Mgr.cc
src/mgr/Mgr.h
src/mgr/MgrStandby.cc

index d4e5f8021143c4fa6b6ae6e8634c9f6b479f0077..bde92a379074b1f212e4ae5cb9d6134da2ccb6ec 100644 (file)
@@ -553,7 +553,7 @@ bool DaemonServer::handle_report(MMgrReport *m)
 
     // issue metadata request in background
     if (!daemon_state.is_updating(key) && 
-       (key.first == "osd" || key.first == "mds")) {
+       (key.first == "osd" || key.first == "mds" || key.first == "mon")) {
 
       std::ostringstream oss;
       auto c = new MetadataUpdate(daemon_state, key);
@@ -566,6 +566,9 @@ bool DaemonServer::handle_report(MMgrReport *m)
         oss << "{\"prefix\": \"mds metadata\", \"who\": \""
             << key.second << "\"}";
  
+      } else if (key.first == "mon") {
+        oss << "{\"prefix\": \"mon metadata\", \"id\": \""
+            << key.second << "\"}";
       } else {
        ceph_abort();
       }
index 571bc486b8af15755095768a8c172b76a9d9dedf..e4c83c4e1526e9d3b50b54bd0790f93bbacc11fa 100644 (file)
@@ -70,7 +70,8 @@ void MetadataUpdate::finish(int r)
 {
   daemon_state.clear_updating(key);
   if (r == 0) {
-    if (key.first == "mds" || key.first == "osd" || key.first == "mgr") {
+    if (key.first == "mds" || key.first == "osd" || 
+        key.first == "mgr" || key.first == "mon") {
       json_spirit::mValue json_result;
       bool read_ok = json_spirit::read(
           outbl.to_str(), json_result);
@@ -94,7 +95,7 @@ void MetadataUpdate::finish(int r)
       DaemonStatePtr state;
       if (daemon_state.exists(key)) {
         state = daemon_state.get(key);
-        if (key.first == "mds" || key.first == "mgr") {
+        if (key.first == "mds" || key.first == "mgr" || key.first == "mon") {
           daemon_meta.erase("name");
         } else if (key.first == "osd") {
           daemon_meta.erase("id");
@@ -111,7 +112,7 @@ void MetadataUpdate::finish(int r)
         state->key = key;
         state->hostname = daemon_meta.at("hostname").get_str();
 
-        if (key.first == "mds" || key.first == "mgr") {
+        if (key.first == "mds" || key.first == "mgr" || key.first == "mon") {
           daemon_meta.erase("name");
         } else if (key.first == "osd") {
           daemon_meta.erase("id");
@@ -496,6 +497,19 @@ void Mgr::handle_service_map(MServiceMap *m)
   server.got_service_map();
 }
 
+void Mgr::handle_mon_map()
+{
+  dout(20) << __func__ << dendl;
+  assert(lock.is_locked_by_me());
+  std::set<std::string> names_exist;
+  cluster_state.with_monmap([&] (auto &monmap) {
+    for (unsigned int i = 0; i < monmap.size(); i++) {
+      names_exist.insert(monmap.get_name(i));
+    }
+  });
+  daemon_state.cull("mon", names_exist);
+}
+
 bool Mgr::ms_dispatch(Message *m)
 {
   dout(4) << *m << dendl;
@@ -507,6 +521,7 @@ bool Mgr::ms_dispatch(Message *m)
       break;
     case CEPH_MSG_MON_MAP:
       py_module_registry->notify_all("mon_map", "");
+      handle_mon_map();
       m->put();
       break;
     case CEPH_MSG_FS_MAP:
index e5739c8c9a7ea1abdf2fea85874e886871081374..0248c9df61e6da3d8e5fc53004b3b902aa1d05be 100644 (file)
@@ -85,6 +85,7 @@ public:
   void handle_osd_map();
   void handle_log(MLog *m);
   void handle_service_map(MServiceMap *m);
+  void handle_mon_map();
 
   bool got_mgr_map(const MgrMap& m);
 
index 70e504c701001919c0511445df6b30ca2e773560..485d24339a0e864b5f60070821de0569fbead2aa 100644 (file)
@@ -161,6 +161,11 @@ int MgrStandby::init()
     client_messenger->wait();
     return r;
   }
+  // only forward monmap updates after authentication finishes, otherwise
+  // monc.authenticate() will be waiting for MgrStandy::ms_dispatch()
+  // to acquire the lock forever, as it is already locked in the beginning of
+  // this method.
+  monc.set_passthrough_monmap();
 
   client_t whoami = monc.get_global_id();
   client_messenger->set_myname(entity_name_t::MGR(whoami.v));