From: Sridhar Seshasayee Date: Wed, 9 Aug 2023 12:52:29 +0000 (+0530) Subject: mon/ConfigMonitor: Show localized name in "config dump --format json" output X-Git-Tag: v16.2.15~160^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=7f1d13d2abd6590ec98f566d28c4810558227ac8;p=ceph.git mon/ConfigMonitor: Show localized name in "config dump --format json" output The "ceph config dump" command without the json formatted output shows the localized option names and their values. An example of a normalized vs localized option is shown below: Normalized: mgr/dashboard/ssl_server_port (maintaned within Option struct) Localized: mgr/dashboard/x/ssl_server_port (maintained in mon store) But the "ceph config dump --format json*" output showed the normalized option names which was not consistent with the "config dump" output. The output of the command along with variations for pretty printing must show the same content. This commit introduces a new member within the ConfigMap's MaskedOption struct called "localized_name". This is initialized to the localized name as part of ConfigMonitor::load_config() method. The MaskedOption::dump() used for the json formatting is modified to display the localized_name instead of the normalized name. Fixes: https://tracker.ceph.com/issues/62379 Signed-off-by: Sridhar Seshasayee (cherry picked from commit 3821722e5660437298a7c0f41e1061d363090103) --- diff --git a/src/mon/ConfigMap.cc b/src/mon/ConfigMap.cc index 763b8ce9b173..7a639947bdef 100644 --- a/src/mon/ConfigMap.cc +++ b/src/mon/ConfigMap.cc @@ -66,7 +66,7 @@ void OptionMask::dump(Formatter *f) const void MaskedOption::dump(Formatter *f) const { - f->dump_string("name", opt->name); + f->dump_string("name", localized_name); f->dump_string("value", raw_value); f->dump_string("level", Option::level_to_str(opt->level)); f->dump_bool("can_update_at_runtime", opt->can_update_at_runtime()); @@ -76,7 +76,7 @@ void MaskedOption::dump(Formatter *f) const ostream& operator<<(ostream& out, const MaskedOption& o) { - out << o.opt->name; + out << o.localized_name; if (o.mask.location_type.size()) { out << "@" << o.mask.location_type << '=' << o.mask.location_value; } diff --git a/src/mon/ConfigMap.h b/src/mon/ConfigMap.h index 2ecdcc071336..11b46fc451e8 100644 --- a/src/mon/ConfigMap.h +++ b/src/mon/ConfigMap.h @@ -62,6 +62,7 @@ struct MaskedOption { const Option *opt; ///< the option OptionMask mask; std::unique_ptr unknown_opt; ///< if fabricated for an unknown option + std::string localized_name; ///< localized name for the option MaskedOption(const Option *o, bool fab=false) : opt(o) { if (fab) { @@ -73,6 +74,7 @@ struct MaskedOption { opt = o.opt; mask = std::move(o.mask); unknown_opt = std::move(o.unknown_opt); + localized_name = std::move(o.localized_name); } const MaskedOption& operator=(const MaskedOption& o) = delete; const MaskedOption& operator=(MaskedOption&& o) = delete; diff --git a/src/mon/ConfigMonitor.cc b/src/mon/ConfigMonitor.cc index 1dd3747e73d0..20411d5197f2 100644 --- a/src/mon/ConfigMonitor.cc +++ b/src/mon/ConfigMonitor.cc @@ -843,6 +843,7 @@ void ConfigMonitor::load_config() MaskedOption mopt(opt); mopt.raw_value = value; + mopt.localized_name = name; string section_name; if (who.size() && !ConfigMap::parse_mask(who, §ion_name, &mopt.mask)) {