]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr: set hostname in DeviceState::set_metadata() 30624/head
authorKefu Chai <kchai@redhat.com>
Wed, 18 Sep 2019 03:59:18 +0000 (11:59 +0800)
committerKefu Chai <kchai@redhat.com>
Fri, 27 Sep 2019 17:40:53 +0000 (01:40 +0800)
before this change, we don't update daemon's host if the daemon already
exists in the `daemon_state` registry when handling MMgrOpen even if the
hostname is updated and different from the existing one. and we set
daemon's metadata and update daemon's hostname when handling MMgrOpen or
MServiceMap.

after this change, daemon's hostname is always set whenever
`DaemonState::set_metadata()` is called.

Fixes: https://tracker.ceph.com/issues/40871
Signed-off-by: Kefu Chai <kchai@redhat.com>
(cherry picked from commit ff6b3997caa43d3eac0fc462f3be9ec4fa5ae6ed)

src/mgr/DaemonServer.cc
src/mgr/DaemonState.h

index acf4443a65524b7bbc85c028411c051c1fbaf43c..9acfdf28e2e74a4375d3cb09a1354f590c71596a 100644 (file)
@@ -431,9 +431,6 @@ bool DaemonServer::handle_open(MMgrOpen *m)
     daemon = std::make_shared<DaemonState>(daemon_state.types);
     daemon->key = key;
     daemon->service_daemon = true;
-    if (m->daemon_metadata.count("hostname")) {
-      daemon->hostname = m->daemon_metadata["hostname"];
-    }
     daemon_state.insert(daemon);
   }
   if (daemon) {
@@ -2705,9 +2702,6 @@ void DaemonServer::got_service_map()
        auto daemon = std::make_shared<DaemonState>(daemon_state.types);
        daemon->key = key;
        daemon->set_metadata(q.second.metadata);
-        if (q.second.metadata.count("hostname")) {
-          daemon->hostname = q.second.metadata["hostname"];
-        }
        daemon->service_daemon = true;
        daemon_state.insert(daemon);
        dout(10) << "added missing " << key << dendl;
index 680d4a0cc2cf5112e13a1b322e67c92f7110ea9e..706286a2b12f8673d7035872bfae4ca197cd8223 100644 (file)
@@ -180,6 +180,10 @@ class DaemonState
        }
       }
     }
+    p = m.find("hostname");
+    if (p != m.end()) {
+      hostname = p->second;
+    }
   }
 
   const std::map<std::string,std::string>& _get_config_defaults() {