From: Seena Fallah Date: Wed, 9 Oct 2024 21:32:49 +0000 (+0200) Subject: rgw: allow bucket deletion from secondary zonegroup X-Git-Tag: v19.2.3~139^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=dfe08b55889e5f9d55a118ae8064e5a28b9f83ad;p=ceph.git 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 (cherry picked from commit c7694ddedc3e12d2e7dcf5357e96e6a6f813bfa5) --- diff --git a/src/common/options/rgw.yaml.in b/src/common/options/rgw.yaml.in index eff70c92feb31..49e37672451ac 100644 --- a/src/common/options/rgw.yaml.in +++ b/src/common/options/rgw.yaml.in @@ -1000,6 +1000,8 @@ options: level: advanced desc: Path prefix to be used for accessing RGW RESTful admin API. fmt_desc: The entry point for an admin request URL. + long_desc: Note that multisite replication requires the value admin, + so this option must be left at the default in such deployments. default: admin services: - rgw diff --git a/src/rgw/driver/rados/rgw_bucket.cc b/src/rgw/driver/rados/rgw_bucket.cc index ab78f76c24de1..850e99ba1414a 100644 --- a/src/rgw/driver/rados/rgw_bucket.cc +++ b/src/rgw/driver/rados/rgw_bucket.cc @@ -1278,7 +1278,8 @@ int RGWBucketAdminOp::check_index(rgw::sal::Driver* driver, RGWBucketAdminOpStat return 0; } -int RGWBucketAdminOp::remove_bucket(rgw::sal::Driver* driver, RGWBucketAdminOpState& op_state, +int RGWBucketAdminOp::remove_bucket(rgw::sal::Driver* driver, const rgw::SiteConfig& site, + RGWBucketAdminOpState& op_state, optional_yield y, const DoutPrefixProvider *dpp, bool bypass_gc, bool keep_index_consistent, bool forwarded_request) { @@ -1302,6 +1303,24 @@ int RGWBucketAdminOp::remove_bucket(rgw::sal::Driver* driver, RGWBucketAdminOpSt ret = bucket->remove_bypass_gc(op_state.get_max_aio(), keep_index_consistent, y, dpp); else ret = bucket->remove(dpp, op_state.will_delete_children(), y); + if (ret < 0) + return ret; + + // forward to master zonegroup + const std::string delpath = "/admin/bucket"; + RGWEnv env; + env.set("REQUEST_METHOD", "DELETE"); + env.set("SCRIPT_URI", delpath); + env.set("REQUEST_URI", delpath); + env.set("QUERY_STRING", fmt::format("bucket={}&tenant={}", bucket->get_name(), bucket->get_tenant())); + req_info req(dpp->get_cct(), &env); + + ret = rgw_forward_request_to_master(dpp, site, bucket->get_owner(), nullptr, nullptr, req, y); + if (ret < 0) { + ldpp_dout(dpp, 0) << "ERROR: failed to forward request to master zonegroup: " + << ret << dendl; + return ret; + } return ret; } diff --git a/src/rgw/driver/rados/rgw_bucket.h b/src/rgw/driver/rados/rgw_bucket.h index 95eb8404c4b1f..82fc3b9448fa2 100644 --- a/src/rgw/driver/rados/rgw_bucket.h +++ b/src/rgw/driver/rados/rgw_bucket.h @@ -397,7 +397,7 @@ public: static int check_index_unlinked(rgw::sal::RadosStore* driver, RGWBucketAdminOpState& op_state, RGWFormatterFlusher& flusher, const DoutPrefixProvider *dpp); - static int remove_bucket(rgw::sal::Driver* driver, RGWBucketAdminOpState& op_state, optional_yield y, + static int remove_bucket(rgw::sal::Driver* driver, const rgw::SiteConfig& site, RGWBucketAdminOpState& op_state, optional_yield y, const DoutPrefixProvider *dpp, bool bypass_gc = false, bool keep_index_consistent = true, bool forwarded_request = false); static int remove_object(rgw::sal::Driver* driver, RGWBucketAdminOpState& op_state, const DoutPrefixProvider *dpp, optional_yield y); static int info(rgw::sal::Driver* driver, RGWBucketAdminOpState& op_state, RGWFormatterFlusher& flusher, optional_yield y, const DoutPrefixProvider *dpp); diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index 5c2f9f43d9dcc..fd0354c8aa19d 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -6478,7 +6478,6 @@ int main(int argc, const char **argv) OPT::USER_SUSPEND, OPT::SUBUSER_CREATE, OPT::SUBUSER_MODIFY, OPT::SUBUSER_RM, OPT::BUCKET_LINK, OPT::BUCKET_UNLINK, - OPT::BUCKET_RM, OPT::BUCKET_CHOWN, OPT::METADATA_PUT, OPT::METADATA_RM, OPT::MFA_CREATE, OPT::MFA_REMOVE, OPT::MFA_RESYNC, @@ -8755,14 +8754,14 @@ next: if (opt_cmd == OPT::BUCKET_RM) { if (!inconsistent_index) { - RGWBucketAdminOp::remove_bucket(driver, bucket_op, null_yield, dpp(), bypass_gc, true, false); + RGWBucketAdminOp::remove_bucket(driver, *site, bucket_op, null_yield, dpp(), bypass_gc, true, false); } else { if (!yes_i_really_mean_it) { cerr << "using --inconsistent_index can corrupt the bucket index " << std::endl << "do you really mean it? (requires --yes-i-really-mean-it)" << std::endl; return 1; } - RGWBucketAdminOp::remove_bucket(driver, bucket_op, null_yield, dpp(), bypass_gc, false, false); + RGWBucketAdminOp::remove_bucket(driver, *site, bucket_op, null_yield, dpp(), bypass_gc, false, false); } } diff --git a/src/rgw/rgw_auth.cc b/src/rgw/rgw_auth.cc index 7ec32cc0a2388..b0d82f2e9f1bd 100644 --- a/src/rgw/rgw_auth.cc +++ b/src/rgw/rgw_auth.cc @@ -353,13 +353,6 @@ uint32_t rgw_perms_from_aclspec_default_strategy( } -static inline const std::string make_spec_item(const std::string& tenant, - const std::string& id) -{ - return tenant + ":" + id; -} - - static inline std::pair strategy_handle_rejected(rgw::auth::Engine::result_t&& engine_result, const rgw::auth::Strategy::Control policy,