]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: switch to local zonegroup config if zone is not found
authorYehuda Sadeh <yehuda@redhat.com>
Fri, 4 Dec 2015 21:52:24 +0000 (13:52 -0800)
committerYehuda Sadeh <yehuda@redhat.com>
Fri, 12 Feb 2016 00:13:42 +0000 (16:13 -0800)
We might be just creating a zone that is not in the period config yet,
if we can't find it in period config switch to using the local zonegroup
config.

Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/rgw/rgw_rados.cc

index 5a30eb8dc3989e3be5997ad1a79baa31f5d5b53b..91e743c532c8f87a4faa424648f8cd9218ad38f8 100644 (file)
@@ -3440,7 +3440,8 @@ int RGWRados::init_complete()
   }
 
   bool creating_defaults = false;
-  if (!zg_initialized) {
+  bool using_local = (!zg_initialized);
+  if (using_local) {
     ldout(cct, 10) << " cannot find current period zonegroup using local zonegroup" << dendl;
     ret = init_zg_from_local(&creating_defaults);
     if (ret < 0) {
@@ -3459,6 +3460,18 @@ int RGWRados::init_complete()
     return ret;
   }
   map<string, RGWZone>::iterator zone_iter = get_zonegroup().zones.find(zone_params.get_id());
+  if (zone_iter == get_zonegroup().zones.end()) {
+    if (using_local) {
+      lderr(cct) << "Cannot find zone id=" << zone_params.get_id() << " (name=" << zone_params.get_name() << ")" << dendl;
+      return -EINVAL;
+    }
+    lderr(cct) << "Cannot find zone id=" << zone_params.get_id() << " (name=" << zone_params.get_name() << "), switching to local zonegroup configuration" << dendl;
+    ret = init_zg_from_local(&creating_defaults);
+    if (ret < 0) {
+      return ret;
+    }
+    zone_iter = get_zonegroup().zones.find(zone_params.get_id());
+  }
   if (zone_iter != get_zonegroup().zones.end()) {
     zone_public_config = zone_iter->second;
     ldout(cct, 20) << "zone " << zone_params.get_name() << dendl;