]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/common: throw if fails to change config
authorKefu Chai <kchai@redhat.com>
Fri, 27 Jul 2018 11:47:24 +0000 (19:47 +0800)
committerKefu Chai <kchai@redhat.com>
Sat, 28 Jul 2018 13:01:52 +0000 (21:01 +0800)
simpler this way, and this allows us to have more detailed error message
so we can present it to end-user. skipping the updating step if no
changes is made is nice to have, but changing settings is not in the
critical path. so let's keep it simple.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/crimson/common/config_proxy.h

index 7ea0a23960372da9bec6d95b642648d1b02e7cc6..32b2828af263656928b1a38b394904b0c6e60168 100644 (file)
@@ -7,6 +7,7 @@
 #include "common/config.h"
 #include "common/config_obs.h"
 #include "common/config_obs_mgr.h"
+#include "common/errno.h"
 
 namespace ceph::common {
 
@@ -34,8 +35,7 @@ class ConfigProxy : public seastar::peering_sharded_service<ConfigProxy>
   }
 
   // apply changes to all shards
-  // @param func a functor which accepts @c "ConfigValues&", and returns
-  //             a boolean indicating if the values is changed or not
+  // @param func a functor which accepts @c "ConfigValues&"
   template<typename Func>
   seastar::future<> do_change(Func&& func) {
     auto new_values = seastar::make_lw_shared(*values);
@@ -76,7 +76,10 @@ public:
   }
   seastar::future<> rm_val(const std::string& key) {
     return do_change([key, this](ConfigValues& values) {
-      return get_config().rm_val(values, key) >= 0;
+      auto ret = get_config().rm_val(values, key);
+      if (ret < 0) {
+        throw std::invalid_argument(cpp_strerror(ret));
+      }
     });
   }
   seastar::future<> set_val(const std::string& key,
@@ -87,7 +90,6 @@ public:
       if (ret < 0) {
        throw std::invalid_argument(err.str());
       }
-      return ret > 0;
     });
   }
   int get_val(const std::string &key, std::string *val) const {
@@ -100,9 +102,7 @@ public:
 
   seastar::future<> set_mon_vals(const std::map<std::string,std::string>& kv) {
     return do_change([kv, this](ConfigValues& values) {
-       auto ret = get_config().set_mon_vals(nullptr, values, obs_mgr,
-                                            kv, nullptr);
-      return ret > 0;
+      get_config().set_mon_vals(nullptr, values, obs_mgr, kv, nullptr);
     });
   }