]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/rgw/rgw_pubsub.cc
import ceph 16.2.6
[ceph.git] / ceph / src / rgw / rgw_pubsub.cc
index 00d8ffdc8642e54e9223d6619ff11d48216840d1..c981fc03f553f6a19a9e5c501d1d457fe669593f 100644 (file)
@@ -602,6 +602,17 @@ int RGWPubSub::Bucket::remove_notification(const DoutPrefixProvider *dpp, const
 
   bucket_topics.topics.erase(topic_name);
 
+  if (bucket_topics.topics.empty()) {
+    // no more topics - delete the notification object of the bucket
+    ret = ps->remove(dpp, bucket_meta_obj, &objv_tracker, y);
+    if (ret < 0 && ret != -ENOENT) {
+      ldout(ps->store->ctx(), 1) << "ERROR: failed to remove bucket topics: ret=" << ret << dendl;
+      return ret;
+    }
+    return 0;
+  }
+
+  // write back the notifications without the deleted one
   ret = write_topics(dpp, bucket_topics, &objv_tracker, y);
   if (ret < 0) {
     ldpp_dout(dpp, 1) << "ERROR: failed to write topics info: ret=" << ret << dendl;
@@ -630,7 +641,7 @@ int RGWPubSub::Bucket::remove_notifications(const DoutPrefixProvider *dpp, optio
     }
   }
 
-  // delete all notification of on a bucket
+  // delete the notification object of the bucket
   ret = ps->remove(dpp, bucket_meta_obj, nullptr, y);
   if (ret < 0 && ret != -ENOENT) {
     ldpp_dout(dpp, 1) << "ERROR: failed to remove bucket topics: ret=" << ret << dendl;