Skip to content

Commit 666e79f

Browse files
yuvalifcbodley
authored andcommitted
rgw/notifications: delete persistent queue only if topic is deleted
Signed-off-by: Yuval Lifshitz <[email protected]>
1 parent bcd79d2 commit 666e79f

File tree

3 files changed

+24
-23
lines changed

3 files changed

+24
-23
lines changed

src/rgw/driver/rados/rgw_notify.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1065,7 +1065,7 @@ static inline bool notification_match(reservation_t& res,
10651065
ldpp_dout(res.dpp, 1)
10661066
<< "INFO: failed to load topic: " << topic_cfg.name
10671067
<< ". error: " << ret
1068-
<< " while resrving persistent notification event" << dendl;
1068+
<< " while reserving persistent notification event" << dendl;
10691069
if (ret == -ENOENT) {
10701070
// either the topic is deleted but the corresponding notification still
10711071
// exist or in v2 mode the notification could have synced first but

src/rgw/rgw_admin.cc

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10771,12 +10771,6 @@ int main(int argc, const char **argv)
1077110771
cerr << "ERROR: Run 'topic rm' from master zone " << std::endl;
1077210772
return -EINVAL;
1077310773
}
10774-
ret = rgw::notify::remove_persistent_topic(
10775-
dpp(), static_cast<rgw::sal::RadosStore*>(driver)->getRados()->get_notif_pool_ctx(), topic_name, null_yield);
10776-
if (ret < 0) {
10777-
cerr << "ERROR: could not remove persistent topic: " << cpp_strerror(-ret) << std::endl;
10778-
return -ret;
10779-
}
1078010774

1078110775
RGWPubSub ps(driver, tenant, *site);
1078210776

@@ -10785,6 +10779,13 @@ int main(int argc, const char **argv)
1078510779
cerr << "ERROR: could not remove topic: " << cpp_strerror(-ret) << std::endl;
1078610780
return -ret;
1078710781
}
10782+
10783+
ret = rgw::notify::remove_persistent_topic(
10784+
dpp(), static_cast<rgw::sal::RadosStore*>(driver)->getRados()->get_notif_pool_ctx(), topic_name, null_yield);
10785+
if (ret < 0 && ret != -ENOENT) {
10786+
cerr << "ERROR: could not remove persistent topic: " << cpp_strerror(-ret) << std::endl;
10787+
return -ret;
10788+
}
1078810789
}
1078910790

1079010791
if (opt_cmd == OPT::PUBSUB_NOTIFICATION_RM) {

src/rgw/rgw_rest_pubsub.cc

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -814,35 +814,35 @@ void RGWPSDeleteTopicOp::execute(optional_yield y) {
814814
op_ret = verify_topic_owner_or_policy(
815815
s, result, driver->get_zone()->get_zonegroup().get_name(),
816816
rgw::IAM::snsDeleteTopic);
817-
if (op_ret != 0) {
817+
if (op_ret < 0) {
818818
ldpp_dout(this, 1) << "no permission to remove topic '" << topic_name
819819
<< "'" << dendl;
820820
return;
821821
}
822-
} else {
822+
op_ret = ps.remove_topic(this, topic_name, y);
823+
if (op_ret < 0 && op_ret != -ENOENT) {
824+
ldpp_dout(this, 1) << "failed to remove topic '" << topic_name << ", ret=" << op_ret << dendl;
825+
return;
826+
}
827+
ldpp_dout(this, 1) << "successfully removed topic '" << topic_name << "'" << dendl;
828+
} else if (op_ret != -ENOENT) {
823829
ldpp_dout(this, 1) << "failed to fetch topic '" << topic_name
824830
<< "' with error: " << op_ret << dendl;
825-
if (op_ret == -ENOENT) {
826-
// its not an error if no topics exist, just a no-op
827-
op_ret = 0;
828-
}
829831
return;
830832
}
833+
if (op_ret == -ENOENT) {
834+
// its not an error if no topics exist, just a no-op
835+
op_ret = 0;
836+
}
831837
// upon deletion it is not known if topic is persistent or not
832838
// will try to delete the persistent topic anyway
833-
op_ret = rgw::notify::remove_persistent_topic(topic_name, s->yield);
834-
if (op_ret != -ENOENT && op_ret < 0) {
839+
// doing this regardless of the topic being previously deleted
840+
// to allow for cleanup if only the queue deletion failed
841+
if (const auto ret = rgw::notify::remove_persistent_topic(topic_name, s->yield); ret < 0 && ret != -ENOENT) {
835842
ldpp_dout(this, 1) << "DeleteTopic Action failed to remove queue for "
836843
"persistent topics. error:"
837-
<< op_ret << dendl;
838-
return;
839-
}
840-
op_ret = ps.remove_topic(this, topic_name, y);
841-
if (op_ret < 0) {
842-
ldpp_dout(this, 1) << "failed to remove topic '" << topic_name << ", ret=" << op_ret << dendl;
843-
return;
844+
<< ret << dendl;
844845
}
845-
ldpp_dout(this, 1) << "successfully removed topic '" << topic_name << "'" << dendl;
846846
}
847847

848848
using op_generator = RGWOp*(*)(bufferlist);

0 commit comments

Comments
 (0)