From 53ec1d427adba416512da40f163ad02beee743bc Mon Sep 17 00:00:00 2001 From: Sridhar Seshasayee Date: Wed, 9 Aug 2023 18:22:29 +0530 Subject: [PATCH] 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) --- src/mon/ConfigMap.cc | 4 ++-- src/mon/ConfigMap.h | 2 ++ src/mon/ConfigMonitor.cc | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/mon/ConfigMap.cc b/src/mon/ConfigMap.cc index 763b8ce9b17..7a639947bde 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 a21e77265d6..34af942a61e 100644 --- a/src/mon/ConfigMap.h +++ b/src/mon/ConfigMap.h @@ -63,6 +63,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) { @@ -74,6 +75,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 471aebf6dd6..7bc13412137 100644 --- a/src/mon/ConfigMonitor.cc +++ b/src/mon/ConfigMonitor.cc @@ -831,6 +831,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)) { -- 2.39.5