]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr: set hostname in DeviceState::set_metadata()
authorKefu Chai <kchai@redhat.com>
Wed, 18 Sep 2019 03:59:18 +0000 (11:59 +0800)
committerKefu Chai <kchai@redhat.com>
Wed, 18 Sep 2019 04:49:44 +0000 (12:49 +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>
src/mgr/DaemonServer.cc
src/mgr/DaemonState.h

index ba6c7f8c4a8627586eb345824857b4e137d3d55d..683842745a40aa9525c1d66b763264d605dda25c 100644 (file)
@@ -417,9 +417,6 @@ bool DaemonServer::handle_open(const ref_t<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) {
@@ -2745,9 +2742,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 8c5a8021eaf5808ab4fe694315e718b304237f30..356dcc6b1114224d486f9b853d6dc0af2e982662 100644 (file)
@@ -181,6 +181,10 @@ class DaemonState
        }
       }
     }
+    p = m.find("hostname");
+    if (p != m.end()) {
+      hostname = p->second;
+    }
   }
 
   const std::map<std::string,std::string>& _get_config_defaults() {