]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: sync module tier config fixes
authorYehuda Sadeh <yehuda@redhat.com>
Tue, 9 Jan 2018 09:30:46 +0000 (01:30 -0800)
committerYehuda Sadeh <yehuda@redhat.com>
Thu, 12 Apr 2018 22:38:37 +0000 (15:38 -0700)
Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/rgw/rgw_admin.cc

index 3b7439a14652d9b6c575f7cffb30e0e664a79c39..59b2145668c120fa1d4fc701f7a051b4840c1355 100644 (file)
@@ -2305,23 +2305,19 @@ static void parse_tier_config_param(const string& s, map<string, string, ltstr_n
   string cur_conf;
   list<string> confs;
   for (auto c : s) {
-    switch (c) {
-      case '{':
-        ++level;
-        break;
-      case '}':
-        --level;
-        break;
-      case ',':
-        if (level == 0) {
-          confs.push_back(cur_conf);
-        }
-        cur_conf.clear();
-        break;
-      default:
-        cur_conf += c;
-        break;
-    };
+    if (c == ',') {
+      if (level == 0) {
+        confs.push_back(cur_conf);
+      }
+      cur_conf.clear();
+      continue;
+    }
+    if (c == '{') {
+      ++level;
+    } else if (c == '}') {
+      --level;
+    }
+    cur_conf += c;
   }
   if (!cur_conf.empty()) {
     confs.push_back(cur_conf);
@@ -2330,7 +2326,7 @@ static void parse_tier_config_param(const string& s, map<string, string, ltstr_n
   for (auto c : confs) {
     ssize_t pos = c.find("=");
     if (pos < 0) {
-      out[""] = c;
+      out[c] = "";
     } else {
       out[c.substr(0, pos)] = c.substr(pos + 1);
     }
@@ -3669,6 +3665,7 @@ int main(int argc, const char **argv)
         }
 
         string *ptier_type = (tier_type_specified ? &tier_type : nullptr);
+
         for (auto a : tier_config_add) {
           int r = zone.tier_config.set(a.first, a.second);
           if (r < 0) {
@@ -4358,16 +4355,20 @@ int main(int argc, const char **argv)
 
         if (tier_config_add.size() > 0) {
           for (auto add : tier_config_add) {
-            zone.tier_config.set(add.first, add.second);
+            int r = zone.tier_config.set(add.first, add.second);
+            if (r < 0) {
+              cerr << "ERROR: failed to set configurable: " << add << std::endl;
+              return EINVAL;
+            }
           }
           need_zone_update = true;
         }
 
-        if (tier_config_rm.size() > 0) {
-          for (auto rm : tier_config_rm) {
+        for (auto rm : tier_config_rm) {
+          if (!rm.first.empty()) { /* otherwise will remove the entire config */
             zone.tier_config.erase(rm.first);
+            need_zone_update = true;
           }
-          need_zone_update = true;
         }
 
         if (need_zone_update) {