From: Sage Weil Date: Mon, 4 Dec 2017 22:51:33 +0000 (-0600) Subject: mgr/MgrClient: report running config to mgr X-Git-Tag: v13.0.2~78^2~118 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d8450574cf4884f5d45ef09fce99b7ad24b332a6;p=ceph.git mgr/MgrClient: report running config to mgr Signed-off-by: Sage Weil --- diff --git a/src/common/config.cc b/src/common/config.cc index 5e18029a6500..bfff12dc97dd 100644 --- a/src/common/config.cc +++ b/src/common/config.cc @@ -51,15 +51,6 @@ static const char *CEPH_CONF_FILE_DEFAULT = "$data_dir/config, /etc/ceph/$cluste #define _STR(x) #x #define STRINGIFY(x) _STR(x) -enum { - CONF_DEFAULT, - CONF_MON, - CONF_CONFFILE, - CONF_ENV, - CONF_OVERRIDE, - CONF_FINAL -}; - const char *ceph_conf_level_name(int level) { switch (level) { @@ -310,6 +301,7 @@ int md_config_t::set_mon_vals(CephContext *cct, const map& kv) } } } + values_bl.clear(); return 0; } @@ -893,6 +885,23 @@ int md_config_t::rm_val(const std::string& key) return _rm_val(key, CONF_OVERRIDE); } +void md_config_t::get_config_bl(bufferlist *bl) +{ + Mutex::Locker l(lock); + if (values_bl.length() == 0) { + ::encode((uint32_t)values.size(), values_bl); + for (auto& i : values) { + ::encode(i.first, values_bl); + ::encode((uint32_t)i.second.size(), values_bl); + for (auto& j : i.second) { + ::encode(j.first, values_bl); + ::encode(stringify(j.second), values_bl); + } + } + } + *bl = values_bl; +} + int md_config_t::get_val(const std::string &key, char **buf, int len) const { Mutex::Locker l(lock); @@ -1237,11 +1246,13 @@ int md_config_t::_set_val( } else { p->second[level] = new_value; } + values_bl.clear(); if (p->second.rbegin()->first > level) { // there was a higher priority value; no effect return 0; } } else { + values_bl.clear(); values[opt.name][level] = new_value; } @@ -1291,6 +1302,7 @@ int md_config_t::_rm_val(const std::string& key, int level) if (matters) { _refresh(*find_option(key)); } + values_bl.clear(); return 0; } diff --git a/src/common/config.h b/src/common/config.h index 15a83fba3a36..af4e50fd4af5 100644 --- a/src/common/config.h +++ b/src/common/config.h @@ -28,6 +28,17 @@ class CephContext; +enum { + CONF_DEFAULT, + CONF_MON, + CONF_CONFFILE, + CONF_ENV, + CONF_OVERRIDE, + CONF_FINAL +}; + +extern const char *ceph_conf_level_name(int level); + /** This class represents the current Ceph configuration. * * For Ceph daemons, this is the daemon configuration. Log levels, caching @@ -90,7 +101,10 @@ public: /** * The current values of all settings described by the schema */ - std::map> values; + std::map> values; + + /// encoded, cached copy of of values + bufferlist values_bl; typedef enum { OPT_INT, OPT_LONGLONG, OPT_STR, OPT_DOUBLE, OPT_FLOAT, OPT_BOOL, @@ -165,6 +179,9 @@ public: /// clear override value int rm_val(const std::string& key); + /// get encoded map> of entire config + void get_config_bl(bufferlist *bl); + // Get a configuration value. // No metavariables will be returned (they will have already been expanded) int get_val(const std::string &key, char **buf, int len) const; diff --git a/src/messages/MMgrOpen.h b/src/messages/MMgrOpen.h index 42fedee8010d..171ef5a1e258 100644 --- a/src/messages/MMgrOpen.h +++ b/src/messages/MMgrOpen.h @@ -19,7 +19,7 @@ class MMgrOpen : public Message { - static const int HEAD_VERSION = 2; + static const int HEAD_VERSION = 3; static const int COMPAT_VERSION = 1; public: @@ -31,6 +31,9 @@ public: std::map daemon_metadata; std::map daemon_status; + // encode map> of current config + bufferlist config_bl; + void decode_payload() override { bufferlist::iterator p = payload.begin(); @@ -43,6 +46,9 @@ public: decode(daemon_status, p); } } + if (header.version >= 3) { + ::decode(config_bl, p); + } } void encode_payload(uint64_t features) override { @@ -54,6 +60,7 @@ public: encode(daemon_metadata, payload); encode(daemon_status, payload); } + ::encode(config_bl, payload); } const char *get_type_name() const override { return "mgropen"; } diff --git a/src/messages/MMgrReport.h b/src/messages/MMgrReport.h index 66beab56b49c..ecc9c4ad7f76 100644 --- a/src/messages/MMgrReport.h +++ b/src/messages/MMgrReport.h @@ -72,7 +72,7 @@ WRITE_CLASS_ENCODER(PerfCounterType) class MMgrReport : public Message { - static const int HEAD_VERSION = 5; + static const int HEAD_VERSION = 6; static const int COMPAT_VERSION = 1; public: @@ -100,6 +100,9 @@ public: std::vector osd_health_metrics; + // encode map> of current config + bufferlist config_bl; + void decode_payload() override { bufferlist::iterator p = payload.begin(); @@ -115,6 +118,9 @@ public: if (header.version >= 5) { decode(osd_health_metrics, p); } + if (header.version >= 6) { + decode(config_bl, p); + } } void encode_payload(uint64_t features) override { @@ -126,6 +132,7 @@ public: encode(service_name, payload); encode(daemon_status, payload); encode(osd_health_metrics, payload); + encode(config_bl, payload); } const char *get_type_name() const override { return "mgrreport"; } diff --git a/src/mgr/DaemonServer.cc b/src/mgr/DaemonServer.cc index 090c2af97783..165e4e86ad56 100644 --- a/src/mgr/DaemonServer.cc +++ b/src/mgr/DaemonServer.cc @@ -378,6 +378,12 @@ bool DaemonServer::handle_open(MMgrOpen *m) daemon->metadata = m->daemon_metadata; daemon->service_status = m->daemon_status; + auto p = m->config_bl.begin(); + if (p != m->config_bl.end()) { + ::decode(daemon->config, p); + dout(20) << " got config " << daemon->config << dendl; + } + utime_t now = ceph_clock_now(); auto d = pending_service_map.get_daemon(m->service_name, m->daemon_name); @@ -493,6 +499,12 @@ bool DaemonServer::handle_report(MMgrReport *m) auto &daemon_counters = daemon->perf_counters; daemon_counters.update(m); + auto p = m->config_bl.begin(); + if (p != m->config_bl.end()) { + ::decode(daemon->config, p); + dout(20) << " got config " << daemon->config << dendl; + } + if (daemon->service_daemon) { utime_t now = ceph_clock_now(); if (m->daemon_status) { diff --git a/src/mgr/DaemonState.h b/src/mgr/DaemonState.h index 9a12b1187c6a..352541583b3a 100644 --- a/src/mgr/DaemonState.h +++ b/src/mgr/DaemonState.h @@ -106,6 +106,9 @@ class DaemonState std::map service_status; utime_t last_service_beacon; + // running config + std::map> config; + // The perf counters received in MMgrReport messages DaemonPerfCounters perf_counters; diff --git a/src/mgr/MgrClient.cc b/src/mgr/MgrClient.cc index 15be2e7ddd5e..2b557d0acef1 100644 --- a/src/mgr/MgrClient.cc +++ b/src/mgr/MgrClient.cc @@ -174,6 +174,7 @@ void MgrClient::_send_open() open->service_daemon = service_daemon; open->daemon_metadata = daemon_metadata; } + cct->_conf->get_config_bl(&open->config_bl); session->con->send_message(open); } } @@ -328,6 +329,9 @@ void MgrClient::send_report() } report->osd_health_metrics = std::move(osd_health_metrics); + + cct->_conf->get_config_bl(&report->config_bl); + session->con->send_message(report); }