]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: check placement target existence during bucket creation 16384/head
authorJiaying Ren <jiaying.ren@umcloud.com>
Wed, 21 Jun 2017 05:03:33 +0000 (13:03 +0800)
committerJiaying Ren <jiaying.ren@umcloud.com>
Wed, 19 Jul 2017 04:55:50 +0000 (12:55 +0800)
when the placement target has been specified explicitly,we
need to check whether it exists.

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

index c02b3d8396ddf4a3af5987feccfdb7d9f853a9e9..563aaf8f71657cac7203da3d0e55a85499ad684a 100644 (file)
@@ -2524,6 +2524,17 @@ void RGWCreateBucket::execute()
     return;
   }
 
+  const auto& zonegroup = store->get_zonegroup();
+  if (!placement_rule.empty() &&
+      !zonegroup.placement_targets.count(placement_rule)) {
+    ldout(s->cct, 0) << "placement target (" << placement_rule << ")"
+                     << " doesn't exist in the placement targets of zonegroup"
+                     << " (" << store->get_zonegroup().api_name << ")" << dendl;
+    op_ret = -ERR_INVALID_LOCATION_CONSTRAINT;
+    s->err.message = "The specified placement target does not exist";
+    return;
+  }
+
   /* we need to make sure we read bucket info, it's not read before for this
    * specific request */
   RGWObjectCtx& obj_ctx = *static_cast<RGWObjectCtx *>(s->obj_ctx);