#include "rgw_op.h"
#include "rgw_user.h"
+#include "rgw_process_env.h"
#include "rgw_rest_user.h"
#include "rgw_sal.h"
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<std::string, RGWAccessKey>& 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 {
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) {
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) {
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;
}
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;
}
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;
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;
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;
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;
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;
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] {
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;
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;
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;
}
}
- 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;
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;
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;
// 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;
}
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
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;
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;
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;
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;
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;
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;
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;
}
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;
}
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;
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;
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;
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;
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;
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;
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;