From: Abhishek Lekshmanan Date: Tue, 12 Apr 2016 19:31:19 +0000 (+0200) Subject: rgw_admin: improve period update errors X-Git-Tag: v10.2.0~3^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=7ca01d4ff7449a87c54101347a83f6b9199e58f9;p=ceph.git rgw_admin: improve period update errors If we do a period update on a realm with multiple masters, we fail stating invalid argument, improving this to suggest that we have actually errored out because of multiple master zg in a realm, and printing both of these zonegroups. RGWPeriodMap::update takes CephContext as an argument, so that we can use ldout. Also dropping the error messages reporting invalid arguments on period.update() as these are handled within the function itself whenever it manifests itself. Fixes: http://tracker.ceph.com/issues/15251 Signed-off-by: Abhishek Lekshmanan --- diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index 13802bc132ab..3e4bcba2790b 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -1482,7 +1482,8 @@ static int update_period(const string& realm_id, const string& realm_name, period.fork(); ret = period.update(); if(ret < 0) { - cerr << "failed to update period: " << cpp_strerror(-ret) << std::endl; + // Dropping the error message here, as both the ret codes were handled in + // period.update() return ret; } ret = period.store_info(false); @@ -2537,7 +2538,6 @@ int main(int argc, char **argv) commit, remote, url, access_key, secret_key, formatter); if (ret < 0) { - cerr << "period update failed: " << cpp_strerror(-ret) << std::endl; return ret; } } @@ -3799,8 +3799,7 @@ int main(int argc, char **argv) commit, remote, url, access_key, secret_key, formatter); if (ret < 0) { - cerr << "period update failed: " << cpp_strerror(-ret) << std::endl; - return ret; + return ret; } } return 0; diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 61c2b625d52b..dc62b6785e62 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -1147,7 +1147,7 @@ int RGWPeriod::add_zonegroup(const RGWZoneGroup& zonegroup) if (zonegroup.realm_id != realm_id) { return 0; } - int ret = period_map.update(zonegroup); + int ret = period_map.update(zonegroup, cct); if (ret < 0) { ldout(cct, 0) << "ERROR: updating period map: " << cpp_strerror(-ret) << dendl; return ret; @@ -1184,9 +1184,8 @@ int RGWPeriod::update() master_zone = zg.master_zone; } - int ret = period_map.update(zg); + int ret = period_map.update(zg, cct); if (ret < 0) { - ldout(cct, 0) << "ERROR: updating period map: " << cpp_strerror(-ret) << dendl; return ret; } } @@ -1623,9 +1622,11 @@ void RGWPeriodMap::decode(bufferlist::iterator& bl) { } } -int RGWPeriodMap::update(const RGWZoneGroup& zonegroup) +int RGWPeriodMap::update(const RGWZoneGroup& zonegroup, CephContext *cct) { if (zonegroup.is_master && (!master_zonegroup.empty() && zonegroup.get_id() != master_zonegroup)) { + ldout(cct,0) << "Error updating periodmap, multiple master zonegroups configured "<< dendl; + ldout(cct,0) << "master zonegroup: " << master_zonegroup << " and " << zonegroup.get_id() <::iterator iter = zonegroups.find(zonegroup.get_id()); diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index 1195aa331444..c8951c03125d 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -1181,7 +1181,7 @@ struct RGWPeriodMap void encode(bufferlist& bl) const; void decode(bufferlist::iterator& bl); - int update(const RGWZoneGroup& zonegroup); + int update(const RGWZoneGroup& zonegroup, CephContext *cct); void dump(Formatter *f) const; void decode_json(JSONObj *obj);