From: Sage Weil Date: Mon, 20 Jan 2020 19:11:05 +0000 (-0600) Subject: mon/ConfigMonitor: clean out bad config records X-Git-Tag: v15.1.0~117^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=08fcf01c040e0caaf5b418d300f774bf8c3033da;p=ceph-ci.git mon/ConfigMonitor: clean out bad config records If we encounter an invalid config key in the database, clean it out instead of ignoring it forever. Signed-off-by: Sage Weil --- diff --git a/src/mon/ConfigMonitor.cc b/src/mon/ConfigMonitor.cc index a599233be5d..03ee276a285 100644 --- a/src/mon/ConfigMonitor.cc +++ b/src/mon/ConfigMonitor.cc @@ -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, §ion_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()) { diff --git a/src/mon/ConfigMonitor.h b/src/mon/ConfigMonitor.h index ace33ae082a..8fd85c8bfe2 100644 --- a/src/mon/ConfigMonitor.h +++ b/src/mon/ConfigMonitor.h @@ -16,6 +16,7 @@ class ConfigMonitor : public PaxosService ConfigMap config_map; map> pending; string pending_description; + list need_clean_options; map current;