Skip to content

Commit dfe79fa

Browse files
committed
rgw/notification: Forward Topic & Notification requests to master only when notification_v2 enabled.
Signed-off-by: kchheda3 <[email protected]>
1 parent 73a383f commit dfe79fa

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

src/rgw/rgw_rest_pubsub.cc

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,13 @@ bool verify_topic_permission(const DoutPrefixProvider* dpp, req_state* s,
234234
return verify_topic_permission(dpp, s, topic.owner, arn, policy, op);
235235
}
236236

237-
// command (AWS compliant):
237+
bool should_forward_request_to_master(req_state* s, rgw::sal::Driver* driver) {
238+
return (!driver->is_meta_master() &&
239+
rgw::all_zonegroups_support(*s->penv.site,
240+
rgw::zone_features::notification_v2));
241+
}
242+
243+
// command (AWS compliant):
238244
// POST
239245
// Action=CreateTopic&Name=<topic-name>[&OpaqueData=data][&push-endpoint=<endpoint>[&persistent][&<arg1>=<value1>]]
240246
class RGWPSCreateTopicOp : public RGWOp {
@@ -273,7 +279,7 @@ class RGWPSCreateTopicOp : public RGWOp {
273279
// Remove the args that are parsed, so the push_endpoint_args only contains
274280
// necessary one's which is parsed after this if. but only if master zone,
275281
// else we do not remove as request is forwarded to master.
276-
if (driver->is_meta_master()) {
282+
if (!should_forward_request_to_master(s, driver)) {
277283
s->info.args.remove("OpaqueData");
278284
s->info.args.remove("push-endpoint");
279285
s->info.args.remove("persistent");
@@ -396,7 +402,7 @@ class RGWPSCreateTopicOp : public RGWOp {
396402

397403
void RGWPSCreateTopicOp::execute(optional_yield y) {
398404
// master request will replicate the topic creation.
399-
if (!driver->is_meta_master()) {
405+
if (should_forward_request_to_master(s, driver)) {
400406
op_ret = rgw_forward_request_to_master(
401407
this, *s->penv.site, s->owner.id, &bl_post_body, nullptr, s->info, y);
402408
if (op_ret < 0) {
@@ -858,7 +864,7 @@ class RGWPSSetTopicAttributesOp : public RGWOp {
858864
};
859865

860866
void RGWPSSetTopicAttributesOp::execute(optional_yield y) {
861-
if (!driver->is_meta_master()) {
867+
if (should_forward_request_to_master(s, driver)) {
862868
op_ret = rgw_forward_request_to_master(
863869
this, *s->penv.site, s->owner.id, &bl_post_body, nullptr, s->info, y);
864870
if (op_ret < 0) {
@@ -1003,9 +1009,10 @@ class RGWPSDeleteTopicOp : public RGWOp {
10031009
};
10041010

10051011
void RGWPSDeleteTopicOp::execute(optional_yield y) {
1006-
if (!driver->is_meta_master()) {
1012+
if (should_forward_request_to_master(s, driver)) {
10071013
op_ret = rgw_forward_request_to_master(
10081014
this, *s->penv.site, s->owner.id, &bl_post_body, nullptr, s->info, y);
1015+
10091016
if (op_ret < 0) {
10101017
ldpp_dout(this, 1)
10111018
<< "DeleteTopic forward_request_to_master returned ret = " << op_ret
@@ -1255,7 +1262,7 @@ int RGWPSCreateNotifOp::verify_permission(optional_yield y) {
12551262
}
12561263

12571264
void RGWPSCreateNotifOp::execute(optional_yield y) {
1258-
if (!driver->is_meta_master()) {
1265+
if (should_forward_request_to_master(s, driver)) {
12591266
op_ret = rgw_forward_request_to_master(
12601267
this, *s->penv.site, s->owner.id, &data, nullptr, s->info, y);
12611268
if (op_ret < 0) {
@@ -1457,7 +1464,7 @@ int RGWPSDeleteNotifOp::verify_permission(optional_yield y) {
14571464
}
14581465

14591466
void RGWPSDeleteNotifOp::execute(optional_yield y) {
1460-
if (!driver->is_meta_master()) {
1467+
if (should_forward_request_to_master(s, driver)) {
14611468
bufferlist indata;
14621469
op_ret = rgw_forward_request_to_master(
14631470
this, *s->penv.site, s->owner.id, &indata, nullptr, s->info, y);

0 commit comments

Comments
 (0)