From 363ddeae928c4ea1e5871d523162b7186465b82f Mon Sep 17 00:00:00 2001 From: Jiaying Ren Date: Wed, 21 Jun 2017 13:03:33 +0800 Subject: [PATCH] rgw: check placement target existence during bucket creation when the placement target has been specified explicitly,we need to check whether it exists. Signed-off-by: Jiaying Ren --- src/rgw/rgw_op.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index c02b3d8396d..563aaf8f716 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -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(s->obj_ctx); -- 2.39.5