]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: fix bucket creation and deletion when there is no realm or period configured
authorOrit Wasserman <owasserm@redhat.com>
Tue, 3 Nov 2015 15:21:32 +0000 (16:21 +0100)
committerYehuda Sadeh <yehuda@redhat.com>
Fri, 12 Feb 2016 00:13:28 +0000 (16:13 -0800)
Signed-off-by: Orit Wasserman <owasserm@redhat.com>
src/rgw/rgw_op.cc
src/rgw/rgw_rados.cc
src/rgw/rgw_rados.h

index 53f21d06e3aafa177a42a822a75252660d872f3d..81d646bd9b6e3d15e504f3d995bfb54a1ce2e44c 100644 (file)
@@ -409,13 +409,13 @@ static int rgw_build_bucket_policies(RGWRados *store, struct req_state *s)
     s->bucket_owner = s->bucket_acl->get_owner();
 
     RGWZoneGroup zonegroup;
-    ret = store->current_period.get_zonegroup(zonegroup, s->bucket_info.zonegroup);
+    ret = store->get_zonegroup(s->bucket_info.zonegroup, zonegroup);
     if (!ret && !zonegroup.endpoints.empty()) {
       s->zonegroup_endpoint = zonegroup.endpoints.front();
     }
 
     if (s->bucket_exists && !store->get_zonegroup().equals(s->bucket_info.zonegroup)) {
-      ldout(s->cct, 0) << "NOTICE: request for data in a different zonegroup (" << s->bucket_info.zonegroup << " != " << store->get_zonegroup().get_name() << ")" << dendl;
+      ldout(s->cct, 0) << "NOTICE: request for data in a different zonegroup (" << s->bucket_info.zonegroup << " != " << store->get_zonegroup().get_id() << ")" << dendl;
       /* we now need to make sure that the operation actually requires copy source, that is
        * it's a copy operation
        */
index b170e1038b28cb8d98a901f37ce88041d64f33a8..067561b3e19397519e3a09b1890a90e68fdc6309 100644 (file)
@@ -137,6 +137,7 @@ const string& RGWZoneGroup::get_pool_name(CephContext *cct_)
 int RGWZoneGroup::create_default(bool old_format)
 {
   name = default_zonegroup_name;
+  is_master = true;
 
   RGWZoneGroupPlacementTarget placement_target;
   placement_target.name = "default-placement";
@@ -1242,6 +1243,7 @@ int RGWZoneParams::create_default(bool old_format)
     name = id;
   }
 
+  r = set_as_default();
   return r;
 }
 
@@ -3289,13 +3291,14 @@ int RGWRados::init_complete()
        return ret;
       }
     }
+    ldout(cct, 20) << "zonegroup " << zonegroup.get_name() << dendl;
     if (zonegroup.is_master) {
       rest_master_conn = new RGWRESTConn(cct, this, zonegroup.endpoints);
     }
   }
 
   if (!has_period_zone) {
-    ldout(cct, 10) << " cannot find current period zonegroup using local zonegroup" << dendl;
+    ldout(cct, 10) << "Cannot find current period zone using local zone" << dendl;
     if (creating_defaults && cct->_conf->rgw_zone.empty()) {
       zone_params.set_name(default_zone_name);
     }
@@ -3307,6 +3310,7 @@ int RGWRados::init_complete()
     map<string, RGWZone>::iterator zone_iter = zonegroup.zones.find(zone_params.get_id());
     if (zone_iter != zonegroup.zones.end()) {
       zone_public_config = zone_iter->second;
+      ldout(cct, 20) << "zone " << zone_params.get_name() << dendl;
     } else {
       lderr(cct) << "Cannot find zone " << zone_params.get_name() << dendl;
       return -EINVAL;
@@ -4728,17 +4732,15 @@ int RGWRados::create_bucket(RGWUserInfo& owner, rgw_bucket& bucket,
   return -ENOENT;
 }
 
-int RGWRados::select_new_bucket_location(RGWUserInfo& user_info, const string& zonegroup_name, const string& request_rule,
+int RGWRados::select_new_bucket_location(RGWUserInfo& user_info, const string& zonegroup_id, const string& request_rule,
                                          const string& tenant_name, const string& bucket_name, rgw_bucket& bucket, string *pselected_rule)
 {
   /* first check that rule exists within the specific zonegroup */
   RGWZoneGroup zonegroup;
-  if (!current_period.get_id().empty()) {
-    int ret = current_period.get_zonegroup(zonegroup, zonegroup_name);
-    if (ret < 0) {
-      ldout(cct, 0) << "could not find zonegroup " << zonegroup_name << " in zonegroup map" << dendl;
-      return ret;
-    }
+  int ret = get_zonegroup(zonegroup_id, zonegroup);
+  if (ret < 0) {
+    ldout(cct, 0) << "could not find zonegroup " << zonegroup_id << " in current period" << dendl;
+    return ret;
   }
 
   /* now check that tag exists within zonegroup */
index b00f2d1d2cd6980d3625041f7871922f8ea7f098..b719bd7c4facecf00bb372595194a275de376315 100644 (file)
@@ -1774,6 +1774,8 @@ protected:
   RGWZone period_zone; /* external zone params, e.g., entrypoints, log flags, etc. */  
   bool has_period_zonegroup;
   bool has_period_zone;
+
+  RGWPeriod current_period;
 public:
   RGWRados() : max_req_id(0), lock("rados_timer_lock"), watchers_lock("watchers_lock"), timer(NULL),
                gc(NULL), obj_expirer(NULL), use_gc_thread(false), quota_threads(false),
@@ -1820,11 +1822,21 @@ public:
   string host_id;
 
   RGWRealm realm;
-  RGWPeriod current_period;
+
   RGWRESTConn *rest_master_conn;
   map<string, RGWRESTConn *> zone_conn_map;
   map<string, RGWRESTConn *> zonegroup_conn_map;
 
+  int get_zonegroup(const string& id, RGWZoneGroup& zonegroup) {
+    int ret = 0;
+    if (id == get_zonegroup().get_id()) {
+      zonegroup = get_zonegroup();
+    } else if (!current_period.get_id().empty()) {
+      ret = current_period.get_zonegroup(zonegroup, zonegroup_id);
+    }
+    return ret;
+  }
+
   RGWZoneParams& get_zone_params() { return zone_params; }
   RGWZoneGroup& get_zonegroup() {
     if (has_period_zonegroup) {