summaryrefslogtreecommitdiffstats
path: root/src/rgw/rgw_rest_pubsub.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/rgw/rgw_rest_pubsub.cc')
-rw-r--r--src/rgw/rgw_rest_pubsub.cc27
1 files changed, 17 insertions, 10 deletions
diff --git a/src/rgw/rgw_rest_pubsub.cc b/src/rgw/rgw_rest_pubsub.cc
index c0345a4f88a..f1ffe09cf25 100644
--- a/src/rgw/rgw_rest_pubsub.cc
+++ b/src/rgw/rgw_rest_pubsub.cc
@@ -234,7 +234,13 @@ bool verify_topic_permission(const DoutPrefixProvider* dpp, req_state* s,
return verify_topic_permission(dpp, s, topic.owner, arn, policy, op);
}
-// command (AWS compliant):
+bool should_forward_request_to_master(req_state* s, rgw::sal::Driver* driver) {
+ return (!driver->is_meta_master() &&
+ rgw::all_zonegroups_support(*s->penv.site,
+ rgw::zone_features::notification_v2));
+}
+
+// command (AWS compliant):
// POST
// Action=CreateTopic&Name=<topic-name>[&OpaqueData=data][&push-endpoint=<endpoint>[&persistent][&<arg1>=<value1>]]
class RGWPSCreateTopicOp : public RGWOp {
@@ -273,7 +279,7 @@ class RGWPSCreateTopicOp : public RGWOp {
// Remove the args that are parsed, so the push_endpoint_args only contains
// necessary one's which is parsed after this if. but only if master zone,
// else we do not remove as request is forwarded to master.
- if (driver->is_meta_master()) {
+ if (!should_forward_request_to_master(s, driver)) {
s->info.args.remove("OpaqueData");
s->info.args.remove("push-endpoint");
s->info.args.remove("persistent");
@@ -396,7 +402,7 @@ class RGWPSCreateTopicOp : public RGWOp {
void RGWPSCreateTopicOp::execute(optional_yield y) {
// master request will replicate the topic creation.
- if (!driver->is_meta_master()) {
+ if (should_forward_request_to_master(s, driver)) {
op_ret = rgw_forward_request_to_master(
this, *s->penv.site, s->owner.id, &bl_post_body, nullptr, s->info, y);
if (op_ret < 0) {
@@ -494,11 +500,11 @@ void RGWPSListTopicsOp::execute(optional_yield y) {
const RGWPubSub ps(driver, get_account_or_tenant(s->owner.id), *s->penv.site);
if (rgw::all_zonegroups_support(*s->penv.site, rgw::zone_features::notification_v2) &&
- driver->stat_topics_v1(s->bucket->get_tenant(), null_yield, this) == -ENOENT) {
- op_ret = ps.get_topics_v1(this, result, y);
- } else {
+ driver->stat_topics_v1(get_account_or_tenant(s->owner.id), null_yield, this) == -ENOENT) {
constexpr int max_items = 100;
op_ret = ps.get_topics_v2(this, start_token, max_items, result, next_token, y);
+ } else {
+ op_ret = ps.get_topics_v1(this, result, y);
}
// if there are no topics it is not considered an error
op_ret = op_ret == -ENOENT ? 0 : op_ret;
@@ -863,7 +869,7 @@ class RGWPSSetTopicAttributesOp : public RGWOp {
};
void RGWPSSetTopicAttributesOp::execute(optional_yield y) {
- if (!driver->is_meta_master()) {
+ if (should_forward_request_to_master(s, driver)) {
op_ret = rgw_forward_request_to_master(
this, *s->penv.site, s->owner.id, &bl_post_body, nullptr, s->info, y);
if (op_ret < 0) {
@@ -1008,9 +1014,10 @@ class RGWPSDeleteTopicOp : public RGWOp {
};
void RGWPSDeleteTopicOp::execute(optional_yield y) {
- if (!driver->is_meta_master()) {
+ if (should_forward_request_to_master(s, driver)) {
op_ret = rgw_forward_request_to_master(
this, *s->penv.site, s->owner.id, &bl_post_body, nullptr, s->info, y);
+
if (op_ret < 0) {
ldpp_dout(this, 1)
<< "DeleteTopic forward_request_to_master returned ret = " << op_ret
@@ -1260,7 +1267,7 @@ int RGWPSCreateNotifOp::verify_permission(optional_yield y) {
}
void RGWPSCreateNotifOp::execute(optional_yield y) {
- if (!driver->is_meta_master()) {
+ if (should_forward_request_to_master(s, driver)) {
op_ret = rgw_forward_request_to_master(
this, *s->penv.site, s->owner.id, &data, nullptr, s->info, y);
if (op_ret < 0) {
@@ -1462,7 +1469,7 @@ int RGWPSDeleteNotifOp::verify_permission(optional_yield y) {
}
void RGWPSDeleteNotifOp::execute(optional_yield y) {
- if (!driver->is_meta_master()) {
+ if (should_forward_request_to_master(s, driver)) {
bufferlist indata;
op_ret = rgw_forward_request_to_master(
this, *s->penv.site, s->owner.id, &indata, nullptr, s->info, y);