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)
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) {
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;
}
}
}
+ p = m.find("hostname");
+ if (p != m.end()) {
+ hostname = p->second;
+ }
}
const std::map<std::string,std::string>& _get_config_defaults() {