]> 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>
Wed, 10 Apr 2024 17:09:17 +0000 (13:09 -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>
src/rgw/rgw_admin.cc
src/rgw/rgw_pubsub.cc
src/rgw/rgw_rest_pubsub.cc

index 58117e96ea3ccc91f67973834018e19ce711d6f2..dc147f7f132f16fb0947b89d8d47f306d6d964f1 100644 (file)
@@ -11194,13 +11194,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 ce84b38724a3e3bdb277fbb0b2f855b7bcd74752..0f292ab3758f298ea476b57e9a604963c837cc04 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>
@@ -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
@@ -1112,7 +1123,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) {
@@ -1120,5 +1136,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);