From: Sage Weil Date: Fri, 1 Nov 2019 15:58:40 +0000 (-0500) Subject: mon/ConfigMap: search nested sections X-Git-Tag: v15.1.0~1032^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=09ef9b850f8eb8c381f61ff2855df253a68c7a55;p=ceph.git mon/ConfigMap: search nested sections For an entity a.b.c.d, search all dot-delineated prefix sections. This enables you to establish a hierarchical set of options for clients, such as radosgw daemons. Signed-off-by: Sage Weil --- diff --git a/PendingReleaseNotes b/PendingReleaseNotes index 9edf474c8faf..110f3f19bab0 100644 --- a/PendingReleaseNotes +++ b/PendingReleaseNotes @@ -277,3 +277,14 @@ Accordingly, the ``osd_op_queue_mclock*`` family of config options has been removed in favor of the ``osd_mclock_scheduler*`` family of options. + +* The config subsystem now searches dot ('.') delineated prefixes for + options. That means for an entity like ``client.foo.bar``, it's + overall configuration will be a combination of the global options, + ``client``, ``client.foo``, and ``client.foo.bar``. Previously, + only global, ``client``, and ``client.foo.bar`` options would apply. + This change may affect the configuration for clients that include a + ``.`` in their name. + + Note that this only applies to configuration options in the + monitor's database--config file parsing is not affected. \ No newline at end of file diff --git a/qa/workunits/mon/config.sh b/qa/workunits/mon/config.sh index 3221e6f61203..cef30d09c062 100755 --- a/qa/workunits/mon/config.sh +++ b/qa/workunits/mon/config.sh @@ -50,6 +50,16 @@ ceph config rm mon.a debug_asok ceph config get mon.a debug_asok | grep 11 ceph config rm mon debug_asok ceph config get mon.a debug_asok | grep 33 +# nested .-prefix scoping +ceph config set client.foo debug_asok 44 +ceph config get client.foo.bar debug_asok | grep 44 +ceph config get client.foo.bar.baz debug_asok | grep 44 +ceph config set client.foo.bar debug_asok 55 +ceph config get client.foo.bar.baz debug_asok | grep 55 +ceph config rm client.foo debug_asok +ceph config get client.foo.bar.baz debug_asok | grep 55 +ceph config rm client.foo.bar debug_asok +ceph config get client.foo.bar.baz debug_asok | grep 33 ceph config rm global debug_asok # help diff --git a/src/mon/ConfigMap.cc b/src/mon/ConfigMap.cc index 2defe969f329..b7343ce4264b 100644 --- a/src/mon/ConfigMap.cc +++ b/src/mon/ConfigMap.cc @@ -109,15 +109,26 @@ ConfigMap::generate_entity_map( const std::string& device_class, std::map> *src) { - // global, then by type, then by full name. + // global, then by type, then by name prefix component(s), then name. + // name prefix components are .-separated, + // e.g. client.a.b.c -> [global, client, client.a, client.a.b, client.a.b.c] vector> sections = { make_pair("global", &global) }; auto p = by_type.find(name.get_type_name()); if (p != by_type.end()) { sections.push_back(make_pair(name.get_type_name(), &p->second)); } - auto q = by_id.find(name.to_str()); - if (q != by_id.end()) { - sections.push_back(make_pair(name.to_str(), &q->second)); + vector name_bits; + boost::split(name_bits, name.to_str(), [](char c){ return c == '.'; }); + std::string tname; + for (unsigned p = 0; p < name_bits.size(); ++p) { + if (p) { + tname += '.'; + } + tname += name_bits[p]; + auto q = by_id.find(tname); + if (q != by_id.end()) { + sections.push_back(make_pair(tname, &q->second)); + } } std::map> out; MaskedOption *prev = nullptr;