From ec2fb022307eea93a802f80307b957bfb2581249 Mon Sep 17 00:00:00 2001 From: Orit Wasserman Date: Tue, 11 Oct 2016 11:00:00 +0200 Subject: [PATCH] rgw: mark configuration as converted to avoid corruption when running older admins Fixes: http://tracker.ceph.com/issues/17371 Signed-off-by: Orit Wasserman (cherry picked from commit ceafa2863dd9c02da8a30c5a5324b472ed5d3404) --- src/rgw/rgw_rados.cc | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 738d60f624e10..00f58149e4ede 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -3312,9 +3312,26 @@ int RGWRados::replace_region_with_zonegroup() default_oid = default_region_info_oid; } - string default_region; + RGWZoneGroup default_zonegroup; - int ret = default_zonegroup.init(cct, this, false, true); + string pool_name = default_zonegroup.get_pool_name(cct); + rgw_bucket pool(pool_name.c_str()); + string oid = "converted"; + bufferlist bl; + RGWObjectCtx obj_ctx(this); + + int ret = rgw_get_system_obj(this, obj_ctx, pool ,oid, bl, NULL, NULL); + if (ret < 0 && ret != -ENOENT) { + ldout(cct, 0) << "failed to read converted: ret "<< ret << " " << cpp_strerror(-ret) + << dendl; + return ret; + } else if (ret != -ENOENT) { + ldout(cct, 0) << "System already converted " << dendl; + return 0; + } + + string default_region; + ret = default_zonegroup.init(cct, this, false, true); if (ret < 0) { ldout(cct, 0) << "failed init default region: ret "<< ret << " " << cpp_strerror(-ret) << dendl; return ret; @@ -3513,6 +3530,15 @@ int RGWRados::replace_region_with_zonegroup() } } + /* mark as converted */ + ret = rgw_put_system_obj(this, pool, oid, bl.c_str(), bl.length(), + true, NULL, real_time(), NULL); + if (ret < 0 ) { + ldout(cct, 0) << "failed to mark cluster as converted: ret "<< ret << " " << cpp_strerror(-ret) + << dendl; + return ret; + } + return 0; } -- 2.39.5