From e154b4b8cb9672fbdcfe6605b918d5974bd0f3af Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Tue, 9 Jan 2018 01:30:46 -0800 Subject: [PATCH] rgw: sync module tier config fixes Signed-off-by: Yehuda Sadeh --- src/rgw/rgw_admin.cc | 45 ++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index 3b7439a14652d..59b2145668c12 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -2305,23 +2305,19 @@ static void parse_tier_config_param(const string& s, map 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 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) { -- 2.39.5