From d2dbe7550296da6db885b5344c71f77f9acbfd8f Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Sat, 18 Mar 2023 16:55:58 -0400 Subject: [PATCH] rgw: add free function rgw_forward_request_to_master() Signed-off-by: Casey Bodley --- src/rgw/driver/rados/rgw_rest_bucket.cc | 13 +-- src/rgw/driver/rados/rgw_rest_user.cc | 77 +++++++------- src/rgw/driver/rados/rgw_zone.h | 4 + src/rgw/rgw_op.cc | 128 +++++++++++++++++------- src/rgw/rgw_op.h | 15 ++- src/rgw/rgw_rest_user_policy.cc | 9 +- 6 files changed, 151 insertions(+), 95 deletions(-) diff --git a/src/rgw/driver/rados/rgw_rest_bucket.cc b/src/rgw/driver/rados/rgw_rest_bucket.cc index 6853173be4f..a530d405673 100644 --- a/src/rgw/driver/rados/rgw_rest_bucket.cc +++ b/src/rgw/driver/rados/rgw_rest_bucket.cc @@ -3,6 +3,7 @@ #include "rgw_op.h" #include "driver/rados/rgw_bucket.h" +#include "rgw_process_env.h" #include "rgw_rest_bucket.h" #include "rgw_sal.h" @@ -150,8 +151,8 @@ void RGWOp_Bucket_Link::execute(optional_yield y) op_state.set_bucket_id(bucket_id); op_state.set_new_bucket_name(new_bucket_name); - bufferlist data; - op_ret = driver->forward_request_to_master(s, s->user.get(), nullptr, data, nullptr, s->info, y); + op_ret = rgw_forward_request_to_master(this, *s->penv.site, s->user->get_id(), + nullptr, nullptr, s->info, y); if (op_ret < 0) { ldpp_dout(this, 0) << "forward_request_to_master returned ret=" << op_ret << dendl; return; @@ -188,8 +189,8 @@ void RGWOp_Bucket_Unlink::execute(optional_yield y) op_state.set_user_id(uid); op_state.set_bucket_name(bucket); - bufferlist data; - op_ret = driver->forward_request_to_master(s, s->user.get(), nullptr, data, nullptr, s->info, y); + op_ret = rgw_forward_request_to_master(this, *s->penv.site, s->user->get_id(), + nullptr, nullptr, s->info, y); if (op_ret < 0) { ldpp_dout(this, 0) << "forward_request_to_master returned ret=" << op_ret << dendl; return; @@ -220,8 +221,8 @@ void RGWOp_Bucket_Remove::execute(optional_yield y) RESTArgs::get_string(s, "bucket", bucket_name, &bucket_name); RESTArgs::get_bool(s, "purge-objects", false, &delete_children); - bufferlist data; - op_ret = driver->forward_request_to_master(s, s->user.get(), nullptr, data, nullptr, s->info, y); + op_ret = rgw_forward_request_to_master(this, *s->penv.site, s->user->get_id(), + nullptr, nullptr, s->info, y); if (op_ret < 0) { ldpp_dout(this, 0) << "forward_request_to_master returned ret=" << op_ret << dendl; if (op_ret == -ENOENT) { diff --git a/src/rgw/driver/rados/rgw_rest_user.cc b/src/rgw/driver/rados/rgw_rest_user.cc index 361ceb0f70f..200f1c03d2e 100644 --- a/src/rgw/driver/rados/rgw_rest_user.cc +++ b/src/rgw/driver/rados/rgw_rest_user.cc @@ -5,6 +5,7 @@ #include "rgw_op.h" #include "rgw_user.h" +#include "rgw_process_env.h" #include "rgw_rest_user.h" #include "rgw_sal.h" @@ -19,19 +20,23 @@ using namespace std; -int fetch_access_keys_from_master(const DoutPrefixProvider *dpp, rgw::sal::Driver* driver, RGWUserAdminOpState &op_state, req_state *s, optional_yield y) { - bufferlist data; - JSONParser jp; - RGWUserInfo ui; - int op_ret = driver->forward_request_to_master(s, s->user.get(), nullptr, data, &jp, s->info, y); - if (op_ret < 0) { - ldpp_dout(dpp, 0) << "forward_request_to_master returned ret=" << op_ret << dendl; - return op_ret; - } - ui.decode_json(&jp); - op_state.op_access_keys = std::move(ui.access_keys); +int fetch_access_keys_from_master(const DoutPrefixProvider* dpp, req_state* s, + std::map& keys, + optional_yield y) +{ + bufferlist data; + JSONParser jp; + int ret = rgw_forward_request_to_master(dpp, *s->penv.site, s->user->get_id(), + &data, &jp, s->info, y); + if (ret < 0) { + ldpp_dout(dpp, 0) << "forward_request_to_master returned ret=" << ret << dendl; + return ret; + } - return 0; + RGWUserInfo ui; + ui.decode_json(&jp); + keys = std::move(ui.access_keys); + return 0; } class RGWOp_User_List : public RGWRESTOp { @@ -238,15 +243,13 @@ void RGWOp_User_Create::execute(optional_yield y) op_state.set_placement_tags(placement_tags_list); } - if(!(driver->is_meta_master())) { - op_ret = fetch_access_keys_from_master(this, driver, op_state, s, y); - - if(op_ret < 0) { + if (!s->penv.site->is_meta_master()) { + op_ret = fetch_access_keys_from_master(this, s, op_state.op_access_keys, y); + if (op_ret < 0) { return; - } else { - // set_generate_key() is not set if keys have already been fetched from master zone - gen_key = false; } + // set_generate_key() is not set if keys have already been fetched from master zone + gen_key = false; } if (gen_key) { @@ -384,15 +387,13 @@ void RGWOp_User_Modify::execute(optional_yield y) op_state.set_placement_tags(placement_tags_list); } - if(!(driver->is_meta_master())) { - op_ret = fetch_access_keys_from_master(this, driver, op_state, s, y); - - if(op_ret < 0) { + if (!s->penv.site->is_meta_master()) { + op_ret = fetch_access_keys_from_master(this, s, op_state.op_access_keys, y); + if (op_ret < 0) { return; - } else { - // set_generate_key() is not set if keys have already been fetched from master zone - gen_key = false; } + // set_generate_key() is not set if keys have already been fetched from master zone + gen_key = false; } if (gen_key) { @@ -434,8 +435,8 @@ void RGWOp_User_Remove::execute(optional_yield y) op_state.set_purge_data(purge_data); - bufferlist data; - op_ret = driver->forward_request_to_master(s, s->user.get(), nullptr, data, nullptr, s->info, y); + op_ret = rgw_forward_request_to_master(this, *s->penv.site, s->user->get_id(), + nullptr, nullptr, s->info, y); if (op_ret < 0) { ldpp_dout(this, 0) << "forward_request_to_master returned ret=" << op_ret << dendl; return; @@ -509,8 +510,8 @@ void RGWOp_Subuser_Create::execute(optional_yield y) } op_state.set_key_type(key_type); - bufferlist data; - op_ret = driver->forward_request_to_master(s, s->user.get(), nullptr, data, nullptr, s->info, y); + op_ret = rgw_forward_request_to_master(this, *s->penv.site, s->user->get_id(), + nullptr, nullptr, s->info, y); if (op_ret < 0) { ldpp_dout(this, 0) << "forward_request_to_master returned ret=" << op_ret << dendl; return; @@ -576,8 +577,8 @@ void RGWOp_Subuser_Modify::execute(optional_yield y) } op_state.set_key_type(key_type); - bufferlist data; - op_ret = driver->forward_request_to_master(s, s->user.get(), nullptr, data, nullptr, s->info, y); + op_ret = rgw_forward_request_to_master(this, *s->penv.site, s->user->get_id(), + nullptr, nullptr, s->info, y); if (op_ret < 0) { ldpp_dout(this, 0) << "forward_request_to_master returned ret=" << op_ret << dendl; return; @@ -619,8 +620,8 @@ void RGWOp_Subuser_Remove::execute(optional_yield y) if (purge_keys) op_state.set_purge_keys(); - bufferlist data; - op_ret = driver->forward_request_to_master(s, s->user.get(), nullptr, data, nullptr, s->info, y); + op_ret = rgw_forward_request_to_master(this, *s->penv.site, s->user->get_id(), + nullptr, nullptr, s->info, y); if (op_ret < 0) { ldpp_dout(this, 0) << "forward_request_to_master returned ret=" << op_ret << dendl; return; @@ -760,8 +761,8 @@ void RGWOp_Caps_Add::execute(optional_yield y) op_state.set_user_id(uid); op_state.set_caps(caps); - bufferlist data; - op_ret = driver->forward_request_to_master(s, s->user.get(), nullptr, data, nullptr, s->info, y); + op_ret = rgw_forward_request_to_master(this, *s->penv.site, s->user->get_id(), + nullptr, nullptr, s->info, y); if (op_ret < 0) { ldpp_dout(this, 0) << "forward_request_to_master returned ret=" << op_ret << dendl; return; @@ -798,8 +799,8 @@ void RGWOp_Caps_Remove::execute(optional_yield y) op_state.set_user_id(uid); op_state.set_caps(caps); - bufferlist data; - op_ret = driver->forward_request_to_master(s, s->user.get(), nullptr, data, nullptr, s->info, y); + op_ret = rgw_forward_request_to_master(this, *s->penv.site, s->user->get_id(), + nullptr, nullptr, s->info, y); if (op_ret < 0) { ldpp_dout(this, 0) << "forward_request_to_master returned ret=" << op_ret << dendl; return; diff --git a/src/rgw/driver/rados/rgw_zone.h b/src/rgw/driver/rados/rgw_zone.h index b57b05ada85..4c6b82a2995 100644 --- a/src/rgw/driver/rados/rgw_zone.h +++ b/src/rgw/driver/rados/rgw_zone.h @@ -965,6 +965,10 @@ class SiteConfig { const RGWZoneGroup& get_zonegroup() const { return *zonegroup; } /// Return the public zone configuration. const RGWZone& get_zone() const { return *zone; } + /// Return true if the local zone can write metadata. + bool is_meta_master() const { + return zonegroup->is_master && zonegroup->master_zone == zone->id; + } /// Load or reload the multisite configuration from storage. This is not /// thread-safe, so requires careful coordination with the RGWRealmReloader. diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index 1bd1fd85ba0..1fbd2ec7105 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -110,6 +110,47 @@ static constexpr auto S3_EXISTING_OBJTAG = "s3:ExistingObjectTag"; static constexpr auto S3_RESOURCE_TAG = "s3:ResourceTag"; static constexpr auto S3_RUNTIME_RESOURCE_VAL = "${s3:ResourceTag"; +int rgw_forward_request_to_master(const DoutPrefixProvider* dpp, + const rgw::SiteConfig& site, + const rgw_user& uid, + bufferlist* indata, JSONParser* jp, + req_info& req, optional_yield y) +{ + const auto& period = site.get_period(); + if (!period) { + return 0; // not multisite + } + if (site.is_meta_master()) { + return 0; // don't need to forward metadata requests + } + const auto& pmap = period->period_map; + auto zg = pmap.zonegroups.find(pmap.master_zonegroup); + if (zg == pmap.zonegroups.end()) { + return -EINVAL; + } + auto z = zg->second.zones.find(zg->second.master_zone); + if (z == zg->second.zones.end()) { + return -EINVAL; + } + const RGWAccessKey& creds = site.get_zone_params().system_key; + + // use the master zone's endpoints + auto conn = RGWRESTConn{dpp->get_cct(), z->second.id, z->second.endpoints, + creds, zg->second.id, zg->second.api_name}; + bufferlist outdata; + constexpr size_t max_response_size = 128 * 1024; // we expect a very small response + int ret = conn.forward(dpp, uid, req, nullptr, max_response_size, + indata, &outdata, y); + if (ret < 0) { + return ret; + } + if (jp && !jp->parse(outdata.c_str(), outdata.length())) { + ldpp_dout(dpp, 0) << "failed parsing response from master zonegroup" << dendl; + return -EINVAL; + } + return 0; +} + int RGWGetObj::parse_range(void) { int r = -ERANGE; @@ -1215,9 +1256,11 @@ void RGWPutBucketTags::execute(optional_yield y) if (op_ret < 0) return; - op_ret = driver->forward_request_to_master(this, s->user.get(), nullptr, in_data, nullptr, s->info, y); + op_ret = rgw_forward_request_to_master(this, *s->penv.site, s->user->get_id(), + &in_data, nullptr, s->info, y); if (op_ret < 0) { ldpp_dout(this, 0) << "forward_request_to_master returned ret=" << op_ret << dendl; + return; } op_ret = retry_raced_bucket_write(this, s->bucket.get(), [this, y] { @@ -1244,8 +1287,8 @@ int RGWDeleteBucketTags::verify_permission(optional_yield y) void RGWDeleteBucketTags::execute(optional_yield y) { - bufferlist in_data; - op_ret = driver->forward_request_to_master(this, s->user.get(), nullptr, in_data, nullptr, s->info, y); + op_ret = rgw_forward_request_to_master(this, *s->penv.site, s->user->get_id(), + nullptr, nullptr, s->info, y); if (op_ret < 0) { ldpp_dout(this, 0) << "forward_request_to_master returned ret=" << op_ret << dendl; return; @@ -1300,7 +1343,8 @@ void RGWPutBucketReplication::execute(optional_yield y) { if (op_ret < 0) return; - op_ret = driver->forward_request_to_master(this, s->user.get(), nullptr, in_data, nullptr, s->info, y); + op_ret = rgw_forward_request_to_master(this, *s->penv.site, s->user->get_id(), + &in_data, nullptr, s->info, y); if (op_ret < 0) { ldpp_dout(this, 0) << "forward_request_to_master returned ret=" << op_ret << dendl; return; @@ -1341,8 +1385,8 @@ int RGWDeleteBucketReplication::verify_permission(optional_yield y) void RGWDeleteBucketReplication::execute(optional_yield y) { - bufferlist in_data; - op_ret = driver->forward_request_to_master(this, s->user.get(), nullptr, in_data, nullptr, s->info, y); + op_ret = rgw_forward_request_to_master(this, *s->penv.site, s->user->get_id(), + nullptr, nullptr, s->info, y); if (op_ret < 0) { ldpp_dout(this, 0) << "forward_request_to_master returned ret=" << op_ret << dendl; return; @@ -2781,7 +2825,8 @@ void RGWSetBucketVersioning::execute(optional_yield y) } } - op_ret = driver->forward_request_to_master(this, s->user.get(), nullptr, in_data, nullptr, s->info, y); + op_ret = rgw_forward_request_to_master(this, *s->penv.site, s->user->get_id(), + &in_data, nullptr, s->info, y); if (op_ret < 0) { ldpp_dout(this, 0) << "forward_request_to_master returned ret=" << op_ret << dendl; return; @@ -2870,7 +2915,8 @@ void RGWSetBucketWebsite::execute(optional_yield y) return; } - op_ret = driver->forward_request_to_master(this, s->user.get(), nullptr, in_data, nullptr, s->info, y); + op_ret = rgw_forward_request_to_master(this, *s->penv.site, s->user->get_id(), + &in_data, nullptr, s->info, y); if (op_ret < 0) { ldpp_dout(this, 0) << " forward_request_to_master returned ret=" << op_ret << dendl; return; @@ -2911,9 +2957,8 @@ void RGWDeleteBucketWebsite::execute(optional_yield y) return; } - bufferlist in_data; - - op_ret = driver->forward_request_to_master(this, s->user.get(), nullptr, in_data, nullptr, s->info, y); + op_ret = rgw_forward_request_to_master(this, *s->penv.site, s->user->get_id(), + nullptr, nullptr, s->info, y); if (op_ret < 0) { ldpp_dout(this, 0) << "NOTICE: forward_to_master failed on bucket=" << s->bucket->get_name() << "returned err=" << op_ret << dendl; @@ -3524,8 +3569,8 @@ void RGWCreateBucket::execute(optional_yield y) // apply bucket creation on the master zone first bufferlist in_data; JSONParser jp; - op_ret = driver->forward_request_to_master(this, s->user.get(), nullptr, - in_data, &jp, s->info, y); + op_ret = rgw_forward_request_to_master(this, *s->penv.site, s->user->get_id(), + &in_data, &jp, s->info, y); if (op_ret < 0) { return; } @@ -3669,8 +3714,8 @@ void RGWDeleteBucket::execute(optional_yield y) return; } - bufferlist in_data; - op_ret = driver->forward_request_to_master(this, s->user.get(), &ot.read_version, in_data, nullptr, s->info, y); + op_ret = rgw_forward_request_to_master(this, *s->penv.site, s->user->get_id(), + nullptr, nullptr, s->info, y); if (op_ret < 0) { if (op_ret == -ENOENT) { /* adjust error, we want to return with NoSuchBucket and not @@ -6038,7 +6083,8 @@ void RGWPutACLs::execute(optional_yield y) if (s->canned_acl.empty()) { in_data.append(data); } - op_ret = driver->forward_request_to_master(this, s->user.get(), nullptr, in_data, nullptr, s->info, y); + op_ret = rgw_forward_request_to_master(this, *s->penv.site, s->user->get_id(), + &in_data, nullptr, s->info, y); if (op_ret < 0) { ldpp_dout(this, 0) << "forward_request_to_master returned ret=" << op_ret << dendl; return; @@ -6167,7 +6213,8 @@ void RGWPutLC::execute(optional_yield y) ldpp_dout(this, 15) << "New LifecycleConfiguration:" << ss.str() << dendl; } - op_ret = driver->forward_request_to_master(this, s->user.get(), nullptr, data, nullptr, s->info, y); + op_ret = rgw_forward_request_to_master(this, *s->penv.site, s->user->get_id(), + &data, nullptr, s->info, y); if (op_ret < 0) { ldpp_dout(this, 0) << "forward_request_to_master returned ret=" << op_ret << dendl; return; @@ -6182,8 +6229,8 @@ void RGWPutLC::execute(optional_yield y) void RGWDeleteLC::execute(optional_yield y) { - bufferlist data; - op_ret = driver->forward_request_to_master(this, s->user.get(), nullptr, data, nullptr, s->info, y); + op_ret = rgw_forward_request_to_master(this, *s->penv.site, s->user->get_id(), + nullptr, nullptr, s->info, y); if (op_ret < 0) { ldpp_dout(this, 0) << "forward_request_to_master returned ret=" << op_ret << dendl; return; @@ -6235,7 +6282,8 @@ void RGWPutCORS::execute(optional_yield y) if (op_ret < 0) return; - op_ret = driver->forward_request_to_master(this, s->user.get(), nullptr, in_data, nullptr, s->info, y); + op_ret = rgw_forward_request_to_master(this, *s->penv.site, s->user->get_id(), + &in_data, nullptr, s->info, y); if (op_ret < 0) { ldpp_dout(this, 0) << "forward_request_to_master returned ret=" << op_ret << dendl; return; @@ -6260,8 +6308,8 @@ int RGWDeleteCORS::verify_permission(optional_yield y) void RGWDeleteCORS::execute(optional_yield y) { - bufferlist data; - op_ret = driver->forward_request_to_master(this, s->user.get(), nullptr, data, nullptr, s->info, y); + op_ret = rgw_forward_request_to_master(this, *s->penv.site, s->user->get_id(), + nullptr, nullptr, s->info, y); if (op_ret < 0) { ldpp_dout(this, 0) << "forward_request_to_master returned ret=" << op_ret << dendl; return; @@ -6383,7 +6431,8 @@ void RGWSetRequestPayment::execute(optional_yield y) if (op_ret < 0) return; - op_ret = driver->forward_request_to_master(this, s->user.get(), nullptr, in_data, nullptr, s->info, y); + op_ret = rgw_forward_request_to_master(this, *s->penv.site, s->user->get_id(), + &in_data, nullptr, s->info, y); if (op_ret < 0) { ldpp_dout(this, 0) << "forward_request_to_master returned ret=" << op_ret << dendl; return; @@ -7423,9 +7472,8 @@ bool RGWBulkDelete::Deleter::delete_single(const acct_path_t& path, optional_yie req_info req = s->info; forward_req_info(dpp, s->cct, req, path.bucket_name); - bufferlist data; - ret = driver->forward_request_to_master(dpp, s->user.get(), nullptr, - data, nullptr, req, y); + ret = rgw_forward_request_to_master(dpp, *s->penv.site, s->user->get_id(), + nullptr, nullptr, req, y); if (ret < 0) { goto delop_fail; } @@ -7679,8 +7727,8 @@ int RGWBulkUploadOp::handle_dir(const std::string_view path, optional_yield y) req_info req = s->info; forward_req_info(this, s->cct, req, bucket_name); - ret = driver->forward_request_to_master(this, s->user.get(), nullptr, - in_data, &jp, req, y); + ret = rgw_forward_request_to_master(this, *s->penv.site, s->user->get_id(), + &in_data, &jp, req, y); if (ret < 0) { return ret; } @@ -8390,7 +8438,8 @@ void RGWPutBucketPolicy::execute(optional_yield y) return; } - op_ret = driver->forward_request_to_master(this, s->user.get(), nullptr, data, nullptr, s->info, y); + op_ret = rgw_forward_request_to_master(this, *s->penv.site, s->user->get_id(), + &data, nullptr, s->info, y); if (op_ret < 0) { ldpp_dout(this, 20) << "forward_request_to_master returned ret=" << op_ret << dendl; return; @@ -8491,8 +8540,8 @@ int RGWDeleteBucketPolicy::verify_permission(optional_yield y) void RGWDeleteBucketPolicy::execute(optional_yield y) { - bufferlist data; - op_ret = driver->forward_request_to_master(this, s->user.get(), nullptr, data, nullptr, s->info, y); + op_ret = rgw_forward_request_to_master(this, *s->penv.site, s->user->get_id(), + nullptr, nullptr, s->info, y); if (op_ret < 0) { ldpp_dout(this, 0) << "forward_request_to_master returned ret=" << op_ret << dendl; return; @@ -8558,7 +8607,8 @@ void RGWPutBucketObjectLock::execute(optional_yield y) return; } - op_ret = driver->forward_request_to_master(this, s->user.get(), nullptr, data, nullptr, s->info, y); + op_ret = rgw_forward_request_to_master(this, *s->penv.site, s->user->get_id(), + &data, nullptr, s->info, y); if (op_ret < 0) { ldpp_dout(this, 20) << __func__ << "forward_request_to_master returned ret=" << op_ret << dendl; return; @@ -8920,7 +8970,8 @@ void RGWPutBucketPublicAccessBlock::execute(optional_yield y) return; } - op_ret = driver->forward_request_to_master(this, s->user.get(), nullptr, data, nullptr, s->info, y); + op_ret = rgw_forward_request_to_master(this, *s->penv.site, s->user->get_id(), + &data, nullptr, s->info, y); if (op_ret < 0) { ldpp_dout(this, 0) << "forward_request_to_master returned ret=" << op_ret << dendl; return; @@ -8995,8 +9046,8 @@ int RGWDeleteBucketPublicAccessBlock::verify_permission(optional_yield y) void RGWDeleteBucketPublicAccessBlock::execute(optional_yield y) { - bufferlist data; - op_ret = driver->forward_request_to_master(this, s->user.get(), nullptr, data, nullptr, s->info, y); + op_ret = rgw_forward_request_to_master(this, *s->penv.site, s->user->get_id(), + nullptr, nullptr, s->info, y); if (op_ret < 0) { ldpp_dout(this, 0) << "forward_request_to_master returned ret=" << op_ret << dendl; return; @@ -9051,7 +9102,8 @@ void RGWPutBucketEncryption::execute(optional_yield y) return; } - op_ret = driver->forward_request_to_master(this, s->user.get(), nullptr, data, nullptr, s->info, y); + op_ret = rgw_forward_request_to_master(this, *s->penv.site, s->user->get_id(), + &data, nullptr, s->info, y); if (op_ret < 0) { ldpp_dout(this, 20) << "forward_request_to_master returned ret=" << op_ret << dendl; return; @@ -9105,8 +9157,8 @@ int RGWDeleteBucketEncryption::verify_permission(optional_yield y) void RGWDeleteBucketEncryption::execute(optional_yield y) { - bufferlist data; - op_ret = driver->forward_request_to_master(this, s->user.get(), nullptr, data, nullptr, s->info, y); + op_ret = rgw_forward_request_to_master(this, *s->penv.site, s->user->get_id(), + nullptr, nullptr, s->info, y); if (op_ret < 0) { ldpp_dout(this, 0) << "forward_request_to_master returned ret=" << op_ret << dendl; return; diff --git a/src/rgw/rgw_op.h b/src/rgw/rgw_op.h index 21044046680..09fe6cf4d7a 100644 --- a/src/rgw/rgw_op.h +++ b/src/rgw/rgw_op.h @@ -66,16 +66,13 @@ class RGWRados; class RGWMultiCompleteUpload; class RGWPutObj_Torrent; +namespace rgw::auth::registry { class StrategyRegistry; } -namespace rgw { -namespace auth { -namespace registry { - -class StrategyRegistry; - -} -} -} +int rgw_forward_request_to_master(const DoutPrefixProvider* dpp, + const rgw::SiteConfig& site, + const rgw_user& uid, + bufferlist* indata, JSONParser* jp, + req_info& req, optional_yield y); int rgw_op_get_bucket_policy_from_attr(const DoutPrefixProvider *dpp, CephContext *cct, diff --git a/src/rgw/rgw_rest_user_policy.cc b/src/rgw/rgw_rest_user_policy.cc index 2e300468b95..ddca86a95d8 100644 --- a/src/rgw/rgw_rest_user_policy.cc +++ b/src/rgw/rgw_rest_user_policy.cc @@ -13,6 +13,7 @@ #include "rgw_common.h" #include "rgw_op.h" +#include "rgw_process_env.h" #include "rgw_rest.h" #include "rgw_rest_user_policy.h" #include "rgw_sal.h" @@ -131,8 +132,8 @@ void RGWPutUserPolicy::execute(optional_yield y) return; } - ceph::bufferlist in_data; - op_ret = driver->forward_request_to_master(this, s->user.get(), nullptr, in_data, nullptr, s->info, y); + op_ret = rgw_forward_request_to_master(this, *s->penv.site, s->user->get_id(), + nullptr, nullptr, s->info, y); if (op_ret < 0) { ldpp_dout(this, 0) << "ERROR: forward_request_to_master returned ret=" << op_ret << dendl; return; @@ -362,8 +363,8 @@ void RGWDeleteUserPolicy::execute(optional_yield y) return; } - ceph::bufferlist in_data; - op_ret = driver->forward_request_to_master(this, s->user.get(), nullptr, in_data, nullptr, s->info, y); + op_ret = rgw_forward_request_to_master(this, *s->penv.site, s->user->get_id(), + nullptr, nullptr, s->info, y); if (op_ret < 0) { // a policy might've been uploaded to this site when there was no sync // req. in earlier releases, proceed deletion -- 2.39.5