]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/multisite: check location constraint existness 15333/head
authorJiaying Ren <jiaying.ren@umcloud.com>
Thu, 25 May 2017 12:17:46 +0000 (20:17 +0800)
committerJiaying Ren <jiaying.ren@umcloud.com>
Sun, 18 Jun 2017 03:24:43 +0000 (11:24 +0800)
to match the behavior of AWS S3

Signed-off-by: Jiaying Ren <jiaying.ren@umcloud.com>
src/rgw/rgw_op.cc
src/rgw/rgw_rados.h

index 3a2fbdfee3b88a031223b839bda6739de67b661c..5b98e50fdb6825cfc203858265a3238492211c3b 100644 (file)
@@ -2394,6 +2394,15 @@ void RGWCreateBucket::execute()
   if (op_ret < 0)
     return;
 
+  if (!location_constraint.empty() &&
+      !store->has_zonegroup_api(location_constraint)) {
+      ldout(s->cct, 0) << "location constraint (" << location_constraint << ")"
+                       << " can't be found." << dendl;
+      op_ret = -ERR_INVALID_LOCATION_CONSTRAINT;
+      s->err.message = "The specified location-constraint is not valid";
+      return;
+  }
+
   if (!store->get_zonegroup().is_master_zonegroup() &&
       store->get_zonegroup().api_name != location_constraint) {
     ldout(s->cct, 0) << "location constraint (" << location_constraint << ")"
index 24bb8bb3cb12ef8d43b5938069f553dee44de8c9..4e81cbe4fcf36c8fe727a1ed2ad5334589cdb346 100644 (file)
@@ -2465,6 +2465,16 @@ public:
   const string& get_current_period_id() {
     return current_period.get_id();
   }
+
+  bool has_zonegroup_api(const std::string& api) const {
+    if (!current_period.get_id().empty()) {
+      const auto& zonegroups_by_api = current_period.get_map().zonegroups_by_api;
+      if (zonegroups_by_api.find(api) != zonegroups_by_api.end())
+        return true;
+    }
+    return false;
+  }
+
   // pulls missing periods for period_history
   std::unique_ptr<RGWPeriodPuller> period_puller;
   // maintains a connected history of periods