]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr: add mgr daemon to DaemonStateIndex with metadata (hostname) 20875/head
authorJan Fajerski <jfajerski@suse.com>
Tue, 13 Mar 2018 15:21:27 +0000 (16:21 +0100)
committerJan Fajerski <jfajerski@suse.com>
Tue, 10 Apr 2018 09:49:22 +0000 (11:49 +0200)
This commit changes when (and how) the mgr daemons are added to the
DaemonStateIndex. A change in the mgr map now doesn't immediately
trigger the addition of a mgr daemon, but triggers a MetadataUpdate
operation so that the mgr daemon is added with metadata queried from the
mon (most notably the hostname).
Fixes: http://tracker.ceph.com/issues/23286
Signed-off-by: Jan Fajerski <jfajerski@suse.com>
src/mgr/DaemonServer.cc
src/mgr/Mgr.cc

index 5684ec669641f04e8ebedde1643d089a494cff68..dfbd5915fa115e6c6e8e3c6d699ea7d9fa70a4eb 100644 (file)
@@ -1810,24 +1810,27 @@ void DaemonServer::got_mgr_map()
   Mutex::Locker l(lock);
   set<std::string> have;
   cluster_state.with_mgrmap([&](const MgrMap& mgrmap) {
+      auto md_update = [&] (DaemonKey key) {
+        std::ostringstream oss;
+        auto c = new MetadataUpdate(daemon_state, key);
+        oss << "{\"prefix\": \"mgr metadata\", \"who\": \""
+              << key.second << "\"}";
+        monc->start_mon_command({oss.str()}, {}, &c->outbl, &c->outs, c);
+      };
       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;
+       if (!daemon_state.exists(key) && !daemon_state.is_updating(key)) {
+         md_update(key);
+         dout(10) << "triggered addition of " << key << " via metadata update" << dendl;
        }
       }
       for (auto& i : mgrmap.standbys) {
-       DaemonKey key("mgr", i.second.name);
+        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;
+       if (!daemon_state.exists(key) && !daemon_state.is_updating(key)) {
+         md_update(key);
+         dout(10) << "triggered addition of " << key << " via metadata update" << dendl;
        }
       }
     });
index be39b5753427b2baceebad9bbd14b20f35ec9379..5e74350d93fc453a821c02dcd6d0cbe364f23ea6 100644 (file)
@@ -72,7 +72,7 @@ void MetadataUpdate::finish(int r)
 {
   daemon_state.clear_updating(key);
   if (r == 0) {
-    if (key.first == "mds" || key.first == "osd") {
+    if (key.first == "mds" || key.first == "osd" || key.first == "mgr") {
       json_spirit::mValue json_result;
       bool read_ok = json_spirit::read(
           outbl.to_str(), json_result);
@@ -97,7 +97,7 @@ void MetadataUpdate::finish(int r)
       if (daemon_state.exists(key)) {
         state = daemon_state.get(key);
        Mutex::Locker l(state->lock);
-        if (key.first == "mds") {
+        if (key.first == "mds" || key.first == "mgr") {
           daemon_meta.erase("name");
         } else if (key.first == "osd") {
           daemon_meta.erase("id");
@@ -112,7 +112,7 @@ void MetadataUpdate::finish(int r)
         state->key = key;
         state->hostname = daemon_meta.at("hostname").get_str();
 
-        if (key.first == "mds") {
+        if (key.first == "mds" || key.first == "mgr") {
           daemon_meta.erase("name");
         } else if (key.first == "osd") {
           daemon_meta.erase("id");