]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common/config: check against raw value (no meta) to detect unchanged option
authorSage Weil <sage@redhat.com>
Mon, 26 Feb 2018 18:41:46 +0000 (12:41 -0600)
committerSage Weil <sage@redhat.com>
Tue, 6 Mar 2018 20:44:50 +0000 (14:44 -0600)
If we are looking at a new value from the mon and comparing it to what we
already have active, compare the non-meta-substituted form.  This way a
value from the mon that can't update at runtime but we have already set to
the same value will not be falsely flagged as ignored.

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

index 3982cb5ec9d6a1516f74f981782b09f991ac5aa3..30142575c28b1bcfe22b2db2fa1a45eecb2cfcee 100644 (file)
@@ -1033,6 +1033,16 @@ Option::value_t md_config_t::_get_val(
   return _expand_meta(_get_val_default(o), &o, stack, err);
 }
 
+Option::value_t md_config_t::_get_val_nometa(const Option& o) const
+{
+  auto p = values.find(o.name);
+  if (p != values.end() && !p->second.empty()) {
+    // use highest-priority value available (see CONF_*)
+    return p->second.rbegin()->second;
+  }
+  return _get_val_default(o);
+}
+
 const Option::value_t& md_config_t::_get_val_default(const Option& o) const
 {
   bool has_daemon_default = !boost::get<boost::blank>(&o.daemon_value);
@@ -1310,7 +1320,7 @@ int md_config_t::_set_val(
       safe_to_start_threads &&
       observers.count(opt.name) == 0) {
     // accept value if it is not actually a change
-    if (new_value != _get_val(opt)) {
+    if (new_value != _get_val_nometa(opt)) {
       *error_message = string("Configuration option '") + opt.name +
        "' may not be modified at runtime";
       return -ENOSYS;
index 01db98cbaef98aa9358dc96e78e7173646cf3d72..56f25f0186d45ff6fe2124f55469b25b26cbb38e 100644 (file)
@@ -258,6 +258,7 @@ private:
                           expand_stack_t *stack=0,
                           std::ostream *err=0) const;
   const Option::value_t& _get_val_default(const Option& o) const;
+  Option::value_t _get_val_nometa(const Option& o) const;
 
   int _rm_val(const std::string& key, int level);