From: Sridhar Seshasayee Date: Thu, 24 Jun 2021 07:44:28 +0000 (+0530) Subject: osd: Add method to store config option key/value on the MON store X-Git-Tag: v17.1.0~1244^2~9 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=1fca4bdfd4c919907247f8f31a3f9e6ca7a11653;p=ceph.git osd: Add method to store config option key/value on the MON store Add method mon_cmd_set_config() to save config option key and value to the MON store. The ConfigMonitor command, 'config set' is used to achieve this. A corresponding get method is unnecessary since any config option found on the MON store is loaded during OSD boot-up and set using the md_config_t::set_mon_vals() method. Therefore, the existing versions of ConfigProxy::get_val() method are sufficient to get the latest value for the config option. Fixes: https://tracker.ceph.com/issues/51464 Signed-off-by: Sridhar Seshasayee --- diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 04bce76377d45..78c386e1e0b81 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -10295,6 +10295,32 @@ bool OSD::maybe_override_options_for_qos() return false; } +int OSD::mon_cmd_set_config(const std::string &key, const std::string &val) +{ + std::string cmd = + "{" + "\"prefix\": \"config set\", " + "\"who\": \"osd." + std::to_string(whoami) + "\", " + "\"name\": \"" + key + "\", " + "\"value\": \"" + val + "\"" + "}"; + + vector vcmd{cmd}; + bufferlist inbl; + std::string outs; + C_SaferCond cond; + monc->start_mon_command(vcmd, inbl, nullptr, &outs, &cond); + int r = cond.wait(); + if (r < 0) { + derr << __func__ << " Failed to set config key " << key + << " err: " << cpp_strerror(r) + << " errstr: " << outs << dendl; + return r; + } + + return 0; +} + void OSD::update_log_config() { map log_to_monitors; diff --git a/src/osd/OSD.h b/src/osd/OSD.h index bbcb411b6a615..57964679afd50 100644 --- a/src/osd/OSD.h +++ b/src/osd/OSD.h @@ -2107,6 +2107,7 @@ private: int64_t onum, double *elapsed, std::ostream& ss); + int mon_cmd_set_config(const std::string &key, const std::string &val); void scrub_purged_snaps(); void probe_smart(const std::string& devid, std::ostream& ss);