From: Sage Weil Date: Tue, 18 Dec 2018 23:20:07 +0000 (-0600) Subject: mon/MgrMonitor: populate options X-Git-Tag: v14.1.0~532^2~17 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=2b47f3db143892818d9089851033e7dfa8367952;p=ceph.git mon/MgrMonitor: populate options Signed-off-by: Sage Weil --- diff --git a/src/common/options.h b/src/common/options.h index bc1fa6a9e2cd..ce5671729f7b 100644 --- a/src/common/options.h +++ b/src/common/options.h @@ -333,9 +333,9 @@ struct Option { return *this; } - Option& set_enum_allowed(const std::initializer_list& allowed) + Option& set_enum_allowed(const std::vector& allowed) { - enum_allowed.insert(enum_allowed.end(), allowed); + enum_allowed = allowed; return *this; } diff --git a/src/mon/MgrMonitor.cc b/src/mon/MgrMonitor.cc index be1ac123abd5..9a2a2a3c82c2 100644 --- a/src/mon/MgrMonitor.cc +++ b/src/mon/MgrMonitor.cc @@ -21,6 +21,7 @@ #include "mgr/MgrContext.h" #include "mgr/mgr_commands.h" #include "OSDMonitor.h" +#include "ConfigMonitor.h" #include "MgrMonitor.h" @@ -134,6 +135,56 @@ void MgrMonitor::update_from_paxos(bool *need_bootstrap) } } + // populate module options + mgr_module_options.clear(); + misc_option_strings.clear(); + for (auto& i : map.available_modules) { + for (auto& j : i.module_options) { + string name = string("mgr/") + i.name + "/" + j.second.name; + auto p = mgr_module_options.emplace( + name, + Option(name, static_cast(j.second.type), + static_cast(j.second.level))); + Option& opt = p.first->second; + opt.set_flags(static_cast(j.second.flags)); + opt.set_description(j.second.desc.c_str()); + opt.set_long_description(j.second.long_desc.c_str()); + for (auto& k : j.second.tags) { + opt.add_tag(k.c_str()); + } + for (auto& k : j.second.see_also) { + if (i.module_options.count(k)) { + // another module option + misc_option_strings.push_back(string("mgr/") + i.name + "/" + k); + opt.add_see_also(misc_option_strings.back().c_str()); + } else { + // ceph option + opt.add_see_also(k.c_str()); + } + } + Option::value_t v, v2; + std::string err; + if (j.second.default_value.size() && + !opt.parse_value(j.second.default_value, &v, &err)) { + opt.set_default(v); + } + if (j.second.min.size() && + j.second.max.size() && + !opt.parse_value(j.second.min, &v, &err) && + !opt.parse_value(j.second.max, &v2, &err)) { + opt.set_min_max(v, v2); + } + std::vector enum_allowed; + for (auto& k : j.second.enum_allowed) { + enum_allowed.push_back(k.c_str()); + } + opt.set_enum_allowed(enum_allowed); + } + } + // force ConfigMonitor to refresh, since it uses const Option * + // pointers into our mgr_module_options (which we just rebuilt). + mon->configmon()->load_config(); + // feed our pet MgrClient mon->mgr_client.ms_dispatch(new MMgrMap(map)); } diff --git a/src/mon/MgrMonitor.h b/src/mon/MgrMonitor.h index b295e4030096..bb330d4f0211 100644 --- a/src/mon/MgrMonitor.h +++ b/src/mon/MgrMonitor.h @@ -31,6 +31,9 @@ class MgrMonitor: public PaxosService std::map pending_metadata; std::set pending_metadata_rm; + std::map mgr_module_options; + std::list misc_option_strings; + utime_t first_seen_inactive; std::map last_beacon; @@ -78,6 +81,14 @@ public: const MgrMap &get_map() const { return map; } + const Option *find_module_option(const string& name) { + auto p = mgr_module_options.find(name); + if (p != mgr_module_options.end()) { + return &p->second; + } + return nullptr; + } + bool in_use() const { return map.epoch > 0; } version_t get_trim_to() const override;