From: Sage Weil Date: Tue, 16 Feb 2021 22:06:35 +0000 (-0500) Subject: mgr: maintain a ConfigMap copy X-Git-Tag: v17.1.0~2900^2~6 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=18a12f81030bfb04580cbf2dc70937f2a975e0ad;p=ceph.git mgr: maintain a ConfigMap copy Signed-off-by: Sage Weil --- diff --git a/src/mgr/ActivePyModules.cc b/src/mgr/ActivePyModules.cc index 7c81c736a50c..6ca2b49e2fdf 100644 --- a/src/mgr/ActivePyModules.cc +++ b/src/mgr/ActivePyModules.cc @@ -53,6 +53,10 @@ ActivePyModules::ActivePyModules( server(server), py_module_registry(pmr) { store_cache = std::move(store_data); + // we can only trust our ConfigMap if the mon cluster has provided + // kv sub since our startup. + have_local_config_map = mon_provides_kv_sub; + _refresh_config_map(); cmd_finisher.start(); } @@ -767,6 +771,7 @@ void ActivePyModules::update_kv_data( const map, std::less<>>& data) { std::lock_guard l(lock); + bool do_config = false; if (!incremental) { dout(10) << "full update on " << prefix << dendl; auto p = store_cache.lower_bound(prefix); @@ -785,6 +790,68 @@ void ActivePyModules::update_kv_data( dout(20) << " rm " << i.first << dendl; store_cache.erase(i.first); } + if (i.first.find("config/") == 0) { + do_config = true; + } + } + if (do_config) { + _refresh_config_map(); + } +} + +void ActivePyModules::_refresh_config_map() +{ + dout(10) << dendl; + config_map.clear(); + for (auto p = store_cache.lower_bound("config/"); + p != store_cache.end() && p->first.find("config/") == 0; + ++p) { + string key = p->first.substr(7); + if (key.find("mgr/") == 0) { + // NOTE: for now, we ignore module options. see also ceph_foreign_option_get(). + continue; + } + string value = p->second; + string name; + string who; + config_map.parse_key(key, &name, &who); + + const Option *opt = g_conf().find_option(name); + if (!opt) { + config_map.stray_options.push_back( + std::unique_ptr