]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: Add method to store config option key/value on the MON store
authorSridhar Seshasayee <sseshasa@redhat.com>
Thu, 24 Jun 2021 07:44:28 +0000 (13:14 +0530)
committerSridhar Seshasayee <sseshasa@redhat.com>
Fri, 30 Jul 2021 12:46:00 +0000 (18:16 +0530)
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 <sseshasa@redhat.com>
src/osd/OSD.cc
src/osd/OSD.h

index 04bce76377d4586b87f862d6d1bda6059323c1b0..78c386e1e0b81f52403cb5168b1da755b0e3f66a 100644 (file)
@@ -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<std::string> 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<string,string> log_to_monitors;
index bbcb411b6a6159b76f9e18493d81338b2aec17fa..57964679afd505d81fbac4bd5c3d3615608de1b7 100644 (file)
@@ -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);