]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mon/ConfigMonitor: clean out bad config records
authorSage Weil <sage@redhat.com>
Mon, 20 Jan 2020 19:11:05 +0000 (13:11 -0600)
committerSage Weil <sage@redhat.com>
Mon, 20 Jan 2020 19:12:04 +0000 (13:12 -0600)
If we encounter an invalid config key in the database, clean it out instead
of ignoring it forever.

Signed-off-by: Sage Weil <sage@redhat.com>
src/mon/ConfigMonitor.cc
src/mon/ConfigMonitor.h

index a599233be5d6296be8801357739e6d78829a100a..03ee276a2853abc3a13d12c05deeea5b8792ef3b 100644 (file)
@@ -66,6 +66,12 @@ void ConfigMonitor::encode_pending(MonitorDBStore::TransactionRef t)
   dout(10) << " " << (version+1) << dendl;
   put_last_committed(t, version+1);
 
+  for (auto& key : need_clean_options) {
+    derr << __func__ << " removing bad config key '" << key << "'" << dendl;
+    t->erase(CONFIG_PREFIX, key);
+  }
+  need_clean_options.clear();
+
   // TODO: record changed sections (osd, mds.foo, rack:bar, ...)
 
   string history = HISTORY_PREFIX + stringify(version+1) + "/";
@@ -698,6 +704,9 @@ void ConfigMonitor::tick()
   }
   dout(10) << __func__ << dendl;
   bool changed = false;
+  if (!need_clean_options.empty()) {
+    changed = true;
+  }
   if (changed) {
     propose_pending();
   }
@@ -714,6 +723,7 @@ void ConfigMonitor::load_config()
   it->lower_bound(KEY_PREFIX);
   config_map.clear();
   current.clear();
+  need_clean_options.clear();
   while (it->valid() &&
         it->key().compare(0, KEY_PREFIX.size(), KEY_PREFIX) == 0) {
     string key = it->key().substr(KEY_PREFIX.size());
@@ -756,7 +766,13 @@ void ConfigMonitor::load_config()
     string section_name;
     if (who.size() &&
        !ConfigMap::parse_mask(who, &section_name, &mopt.mask)) {
-      derr << __func__ << " ignoring key " << key << dendl;
+      derr << __func__ << " invalid mask for key " << key << dendl;
+      need_clean_options.push_back(KEY_PREFIX + key);
+    } else if (opt->has_flag(Option::FLAG_NO_MON_UPDATE)) {
+      dout(10) << __func__ << " NO_MON_UPDATE option '"
+              << name << "' = '" << value << "' for " << name
+              << dendl;
+      need_clean_options.push_back(KEY_PREFIX + key);
     } else {
       Section *section = &config_map.global;;
       if (section_name.size()) {
index ace33ae082a62a95afd4e66fe29ee630a6864ed9..8fd85c8bfe2942b3238ef8db1e363e9e846f77d0 100644 (file)
@@ -16,6 +16,7 @@ class ConfigMonitor : public PaxosService
   ConfigMap config_map;
   map<string,boost::optional<bufferlist>> pending;
   string pending_description;
+  list<string> need_clean_options;
 
   map<string,bufferlist> current;