]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/pubsub: RGWPubSub::remove_topic() removes persistent queue
authorCasey Bodley <cbodley@redhat.com>
Wed, 20 Mar 2024 18:14:29 +0000 (14:14 -0400)
committerCasey Bodley <cbodley@redhat.com>
Fri, 12 Apr 2024 19:34:30 +0000 (15:34 -0400)
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>
(cherry picked from commit 4c50ad69c37110d42f1f68f6e567cdf5ac506a32)

src/rgw/rgw_admin.cc
src/rgw/rgw_pubsub.cc
src/rgw/rgw_rest_pubsub.cc

index 3fbb39121ac65a985c1c2bb95f8bff0b36669177..127a225ea363e1ef940575700058268b8fe84ad2 100644 (file)
@@ -11187,13 +11187,6 @@ next:
       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) {
index 98bc57016d6453e640cd0a04cee5082180bf7089..641381e8b6b9f8d04cc5abb6335492eb9f6a62cc 100644 (file)
@@ -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>
@@ -1078,7 +1079,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
@@ -1104,7 +1115,12 @@ 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) {
@@ -1112,5 +1128,13 @@ int RGWPubSub::remove_topic(const DoutPrefixProvider *dpp, const std::string& na
     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;
 }
index 7e1b0491a19397579bfc843778df70be03357709..ff5c824a6be6d87a26cdcc9a16a9ff5d86e77198 100644 (file)
@@ -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);