Skip to content

Commit c7694dd

Browse files
committed
rgw: allow bucket deletion from secondary zonegroup
Allow running `radosgw-admin bucket rm` from secondary zonegroup. This allows bucket deletion with `--purge-objects` and with `--bypass-gc` when deleting the bucket owned by non-master zonegroup. Signed-off-by: Seena Fallah <[email protected]>
1 parent 9ae2d8c commit c7694dd

File tree

5 files changed

+25
-12
lines changed

5 files changed

+25
-12
lines changed

src/common/options/rgw.yaml.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,6 +1019,8 @@ options:
10191019
level: advanced
10201020
desc: Path prefix to be used for accessing RGW RESTful admin API.
10211021
fmt_desc: The entry point for an admin request URL.
1022+
long_desc: Note that multisite replication requires the value admin,
1023+
so this option must be left at the default in such deployments.
10221024
default: admin
10231025
services:
10241026
- rgw

src/rgw/driver/rados/rgw_bucket.cc

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1433,7 +1433,8 @@ int RGWBucketAdminOp::check_index(rgw::sal::Driver* driver,
14331433
return 0;
14341434
}
14351435

1436-
int RGWBucketAdminOp::remove_bucket(rgw::sal::Driver* driver, RGWBucketAdminOpState& op_state,
1436+
int RGWBucketAdminOp::remove_bucket(rgw::sal::Driver* driver, const rgw::SiteConfig& site,
1437+
RGWBucketAdminOpState& op_state,
14371438
optional_yield y, const DoutPrefixProvider *dpp,
14381439
bool bypass_gc, bool keep_index_consistent, bool forwarded_request)
14391440
{
@@ -1457,6 +1458,24 @@ int RGWBucketAdminOp::remove_bucket(rgw::sal::Driver* driver, RGWBucketAdminOpSt
14571458
ret = bucket->remove_bypass_gc(op_state.get_max_aio(), keep_index_consistent, y, dpp);
14581459
else
14591460
ret = bucket->remove(dpp, op_state.will_delete_children(), y);
1461+
if (ret < 0)
1462+
return ret;
1463+
1464+
// forward to master zonegroup
1465+
const std::string delpath = "/admin/bucket";
1466+
RGWEnv env;
1467+
env.set("REQUEST_METHOD", "DELETE");
1468+
env.set("SCRIPT_URI", delpath);
1469+
env.set("REQUEST_URI", delpath);
1470+
env.set("QUERY_STRING", fmt::format("bucket={}&tenant={}", bucket->get_name(), bucket->get_tenant()));
1471+
req_info req(dpp->get_cct(), &env);
1472+
1473+
ret = rgw_forward_request_to_master(dpp, site, bucket->get_owner(), nullptr, nullptr, req, y);
1474+
if (ret < 0) {
1475+
ldpp_dout(dpp, 0) << "ERROR: failed to forward request to master zonegroup: "
1476+
<< ret << dendl;
1477+
return ret;
1478+
}
14601479

14611480
return ret;
14621481
}

src/rgw/driver/rados/rgw_bucket.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ class RGWBucketAdminOp {
384384
static int check_index_unlinked(rgw::sal::RadosStore* driver, RGWBucketAdminOpState& op_state,
385385
RGWFormatterFlusher& flusher, const DoutPrefixProvider *dpp);
386386

387-
static int remove_bucket(rgw::sal::Driver* driver, RGWBucketAdminOpState& op_state, optional_yield y,
387+
static int remove_bucket(rgw::sal::Driver* driver, const rgw::SiteConfig& site, RGWBucketAdminOpState& op_state, optional_yield y,
388388
const DoutPrefixProvider *dpp, bool bypass_gc = false, bool keep_index_consistent = true, bool forwarded_request = false);
389389
static int remove_object(rgw::sal::Driver* driver, RGWBucketAdminOpState& op_state, const DoutPrefixProvider *dpp, optional_yield y);
390390
static int info(rgw::sal::Driver* driver, RGWBucketAdminOpState& op_state, RGWFormatterFlusher& flusher, optional_yield y, const DoutPrefixProvider *dpp);

src/rgw/radosgw-admin/radosgw-admin.cc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6634,7 +6634,6 @@ int main(int argc, const char **argv)
66346634
OPT::USER_SUSPEND, OPT::SUBUSER_CREATE,
66356635
OPT::SUBUSER_MODIFY, OPT::SUBUSER_RM,
66366636
OPT::BUCKET_LINK, OPT::BUCKET_UNLINK,
6637-
OPT::BUCKET_RM,
66386637
OPT::BUCKET_CHOWN, OPT::METADATA_PUT,
66396638
OPT::METADATA_RM, OPT::MFA_CREATE,
66406639
OPT::MFA_REMOVE, OPT::MFA_RESYNC,
@@ -8975,14 +8974,14 @@ int main(int argc, const char **argv)
89758974

89768975
if (opt_cmd == OPT::BUCKET_RM) {
89778976
if (!inconsistent_index) {
8978-
RGWBucketAdminOp::remove_bucket(driver, bucket_op, null_yield, dpp(), bypass_gc, true, false);
8977+
RGWBucketAdminOp::remove_bucket(driver, *site, bucket_op, null_yield, dpp(), bypass_gc, true, false);
89798978
} else {
89808979
if (!yes_i_really_mean_it) {
89818980
cerr << "using --inconsistent_index can corrupt the bucket index " << std::endl
89828981
<< "do you really mean it? (requires --yes-i-really-mean-it)" << std::endl;
89838982
return 1;
89848983
}
8985-
RGWBucketAdminOp::remove_bucket(driver, bucket_op, null_yield, dpp(), bypass_gc, false, false);
8984+
RGWBucketAdminOp::remove_bucket(driver, *site, bucket_op, null_yield, dpp(), bypass_gc, false, false);
89868985
}
89878986
}
89888987

src/rgw/rgw_auth.cc

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -357,13 +357,6 @@ uint32_t rgw_perms_from_aclspec_default_strategy(
357357
}
358358

359359

360-
static inline const std::string make_spec_item(const std::string& tenant,
361-
const std::string& id)
362-
{
363-
return tenant + ":" + id;
364-
}
365-
366-
367360
static inline std::pair<bool, rgw::auth::Engine::result_t>
368361
strategy_handle_rejected(rgw::auth::Engine::result_t&& engine_result,
369362
const rgw::auth::Strategy::Control policy,

0 commit comments

Comments
 (0)