From a2e7cd585499f7dfb215e8383bfd7e8f56c734a5 Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Thu, 15 Oct 2015 17:12:38 -0700 Subject: [PATCH] rgw: update master zone Signed-off-by: Yehuda Sadeh --- src/rgw/rgw_admin.cc | 1 + src/rgw/rgw_rados.cc | 21 ++++++++++++++++----- src/rgw/rgw_rados.h | 1 + 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index 9ee0c41bf695b..2c9f68119fba4 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -2413,6 +2413,7 @@ int main(int argc, char **argv) } if (need_update) { + zonegroup.post_process_params(); ret = zonegroup.update(); if (ret < 0) { cerr << "failed to update zonegroup: " << cpp_strerror(-ret) << std::endl; diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index a5212c98c37a8..709834b17e7de 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -260,10 +260,17 @@ void RGWZoneGroup::post_process_params() { bool log_data = zones.size() > 1; + if (master_zone.empty()) { + map::iterator iter = zones.begin(); + if (iter != zones.end()) { + master_zone = iter->first; + } + } + for (map::iterator iter = zones.begin(); iter != zones.end(); ++iter) { RGWZone& zone = iter->second; zone.log_data = log_data; - zone.log_meta = (is_master && zone.name == master_zone); + zone.log_meta = (is_master && zone.id == master_zone); RGWZoneParams zone_params(zone.id, zone.name); int ret = zone_params.init(cct, store); @@ -281,11 +288,10 @@ void RGWZoneGroup::post_process_params() placement_targets[placement_name] = placement_target; } } + } - if (default_placement.empty() && !placement_targets.empty()) { - default_placement = placement_targets.begin()->first; - } - + if (default_placement.empty() && !placement_targets.empty()) { + default_placement = placement_targets.begin()->first; } } @@ -990,6 +996,11 @@ int RGWPeriod::update() continue; } + if (zg.is_master_zonegroup()) { + master_zonegroup = zg.get_id(); + master_zone = zg.master_zone; + } + int ret = period_map.update(zg); if (ret < 0) { ldout(cct, 0) << "ERROR: updating period map: " << cpp_strerror(-ret) << dendl; diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index 432ab71a9b549..8952b28850699 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -1393,6 +1393,7 @@ public: epoch_t get_epoch() { return epoch;} const string& get_predecessor() { return predecessor_uuid;} const string& get_master_zone() { return master_zone;} + const string& get_master_zonegroup() { return master_zonegroup;} const string& get_realm() { return realm_id;} const RGWPeriodMap& get_map() { return period_map;} const RGWPeriodConfig& get_config() { return period_config;} -- 2.39.5