From 84f9a26c86d814089237a2554e0dbbd5ab7eb699 Mon Sep 17 00:00:00 2001 From: Orit Wasserman Date: Tue, 22 Sep 2015 09:47:08 +0200 Subject: [PATCH] rgw: update zonegroupmap when creating new realm Signed-off-by: Orit Wasserman --- src/rgw/rgw_admin.cc | 22 +++++++++++++++++++++- src/rgw/rgw_rados.cc | 9 ++++++--- src/rgw/rgw_rados.h | 3 ++- 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index 82e231d0481c5..02de6db053ca4 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -1934,6 +1934,26 @@ int main(int argc, char **argv) cerr << "ERROR: couldn't create realm " << realm_name << ": " << cpp_strerror(-ret) << std::endl; return ret; } + + ret = store->zonegroup_map.update(realm); + if (ret < 0) { + cerr << "ERROR: couldn't update realm " << realm_name << ": " << cpp_strerror(-ret) << std::endl; + return ret; + } + + ret = store->zonegroup_map.update(g_ceph_context, store, realm.get_current_period(), realm.get_id()); + if (ret < 0) { + cerr << "ERROR: couldn't update " << realm_name << " current period: " << cpp_strerror(-ret) + << std::endl; + return ret; + } + + ret = store->zonegroup_map.store(g_ceph_context, store); + if (ret < 0) { + cerr << "ERROR: couldn't store zonegroup map info: " << cpp_strerror(-ret) << std::endl; + return 1; + } + encode_json("realm", realm, formatter); formatter->flush(cout); cout << std::endl; @@ -2320,7 +2340,7 @@ int main(int argc, char **argv) return -ret; } zonegroupmap.update(realm); - zonegroupmap.update(g_ceph_context, store, realm.get_current_period()); + zonegroupmap.update(g_ceph_context, store, realm.get_current_period(), realm.get_id()); } list zonegroups; diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 31429371ee9e6..5b8f78d114123 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -642,6 +642,7 @@ int RGWPeriod::init(CephContext *_cct, RGWRados *_store, bool setup_obj) RGWRealm realm(realm_id, realm_name); int ret = realm.init(cct, store); if (ret < 0) { + derr << "RGWPeriod::init failed to init realm " << realm_id << " for period " << id << dendl; ldout(cct, 0) << "failed to init realm " << realm_name << " id " << realm_id << " : " << cpp_strerror(-ret) << dendl; return ret; @@ -1128,14 +1129,16 @@ int RGWZoneGroupMap::update(RGWRealm& realm) } int RGWZoneGroupMap::update(CephContext *cct, RGWRados *store, - const string& period_id) + const string& period_id, + const string& realm_id) { Mutex::Locker l(lock); RGWPeriod period(period_id); - int ret = period.init(cct, store); + derr << "update period " << period_id << " realm " << realm_id << dendl; + int ret = period.init(cct, store, realm_id); if (ret < 0) { - cerr << "failed to init period: " << cpp_strerror(-ret) << std::endl; + derr << "failed to init period: " << cpp_strerror(-ret) << dendl; return ret; } diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index ba1d2ca4dcfca..2bbff88ead31f 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -1175,7 +1175,8 @@ struct RGWZoneGroupMap { int update(RGWZoneGroup& zonegroup); int update(RGWRealm& realm); int update(CephContext *cct, RGWRados *store, - const string& period_id); + const string& period_id, + const string& realm_id); int get_master_zonegroup(const string& current_period, RGWZoneGroup& master_zonegroup); -- 2.39.5