From 12062e7d8766522c51aa88e83070cfba409c6461 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 26 Feb 2018 12:41:46 -0600 Subject: [PATCH] common/config: check against raw value (no meta) to detect unchanged option 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 --- src/common/config.cc | 12 +++++++++++- src/common/config.h | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/common/config.cc b/src/common/config.cc index 3982cb5ec9d6a..30142575c28b1 100644 --- a/src/common/config.cc +++ b/src/common/config.cc @@ -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(&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; diff --git a/src/common/config.h b/src/common/config.h index 01db98cbaef98..56f25f0186d45 100644 --- a/src/common/config.h +++ b/src/common/config.h @@ -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); -- 2.39.5