Skip to content

Commit

Permalink
rgw/pubsub: RGWPubSub::remove_topic() removes persistent queue
Browse files Browse the repository at this point in the history
move the persistent queue removal into remove_topic() where we have
access to the topic metadata. avoid trying to remove the queue if it
isn't enabled

Signed-off-by: Casey Bodley <cbodley@redhat.com>
  • Loading branch information
cbodley committed Apr 10, 2024
1 parent 3ef1ab3 commit 4c50ad6
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 18 deletions.
7 changes: 0 additions & 7 deletions src/rgw/rgw_admin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11194,13 +11194,6 @@ int main(int argc, const char **argv)
cerr << "ERROR: could not remove topic: " << cpp_strerror(-ret) << std::endl;
return -ret;
}

ret = rgw::notify::remove_persistent_topic(
dpp(), static_cast<rgw::sal::RadosStore*>(driver)->getRados()->get_notif_pool_ctx(), topic_name, null_yield);
if (ret < 0 && ret != -ENOENT) {
cerr << "ERROR: could not remove persistent topic: " << cpp_strerror(-ret) << std::endl;
return -ret;
}
}

if (opt_cmd == OPT::PUBSUB_NOTIFICATION_RM) {
Expand Down
28 changes: 26 additions & 2 deletions src/rgw/rgw_pubsub.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "rgw_arn.h"
#include "rgw_pubsub_push.h"
#include "rgw_bucket.h"
#include "driver/rados/rgw_notify.h"
#include "common/errno.h"
#include "include/function2.hpp"
#include <regex>
Expand Down Expand Up @@ -1086,7 +1087,17 @@ int RGWPubSub::remove_topic_v2(const DoutPrefixProvider* dpp,
<< dendl;
return ret;
}
return ret;

const rgw_pubsub_dest& dest = topic.dest;
if (!dest.push_endpoint.empty() && dest.persistent &&
!dest.persistent_queue.empty()) {
ret = rgw::notify::remove_persistent_topic(topic.name, y);
if (ret < 0 && ret != -ENOENT) {
ldpp_dout(dpp, 1) << "WARNING: failed to remove queue for "
"persistent topic: " << cpp_strerror(ret) << dendl;
} // not fatal
}
return 0;
}

int RGWPubSub::remove_topic(const DoutPrefixProvider *dpp, const std::string& name, optional_yield y) const
Expand All @@ -1112,13 +1123,26 @@ int RGWPubSub::remove_topic(const DoutPrefixProvider *dpp, const std::string& na
return 0;
}

topics.topics.erase(name);
auto t = topics.topics.find(name);
if (t == topics.topics.end()) {
return -ENOENT;
}
const rgw_pubsub_dest dest = std::move(t->second.dest);
topics.topics.erase(t);

ret = write_topics_v1(dpp, topics, &objv_tracker, y);
if (ret < 0) {
ldpp_dout(dpp, 1) << "ERROR: failed to remove topics info: ret=" << ret << dendl;
return ret;
}

if (!dest.push_endpoint.empty() && dest.persistent &&
!dest.persistent_queue.empty()) {
ret = rgw::notify::remove_persistent_topic(name, y);
if (ret < 0 && ret != -ENOENT) {
ldpp_dout(dpp, 1) << "WARNING: failed to remove queue for "
"persistent topic: " << cpp_strerror(ret) << dendl;
} // not fatal
}
return 0;
}
9 changes: 0 additions & 9 deletions src/rgw/rgw_rest_pubsub.cc
Original file line number Diff line number Diff line change
Expand Up @@ -992,15 +992,6 @@ void RGWPSDeleteTopicOp::execute(optional_yield y) {
// its not an error if no topics exist, just a no-op
op_ret = 0;
}
// upon deletion it is not known if topic is persistent or not
// will try to delete the persistent topic anyway
// doing this regardless of the topic being previously deleted
// to allow for cleanup if only the queue deletion failed
if (const auto ret = rgw::notify::remove_persistent_topic(topic_name, s->yield); ret < 0 && ret != -ENOENT) {
ldpp_dout(this, 1) << "DeleteTopic Action failed to remove queue for "
"persistent topics. error:"
<< ret << dendl;
}
}

using op_generator = RGWOp*(*)(bufferlist);
Expand Down

0 comments on commit 4c50ad6

Please sign in to comment.