]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/notifications: delete bucket notification object when empty 41412/head
authorYuval Lifshitz <ylifshit@redhat.com>
Tue, 9 Mar 2021 10:36:09 +0000 (12:36 +0200)
committerCory Snyder <csnyder@iland.com>
Wed, 19 May 2021 16:12:09 +0000 (12:12 -0400)
Fixes: https://tracker.ceph.com/issues/49650
Signed-off-by: Yuval Lifshitz <ylifshit@redhat.com>
(cherry picked from commit 08e9846fd5a040887e2ddbfca36da97777fc76f6)

 Conflicts:
src/rgw/rgw_pubsub.cc
 - octopus does not have optional_yield arg

src/rgw/rgw_pubsub.cc

index a25544bd7723ebd79a7ef35a91c11f2b78dabb98..5dc49c96bf638d75335d880c3217dd858c0a4d35 100644 (file)
@@ -594,6 +594,17 @@ int RGWPubSub::Bucket::remove_notification(const string& topic_name)
 
   bucket_topics.topics.erase(topic_name);
 
+  if (bucket_topics.topics.empty()) {
+    // no more topics - delete the notification object of the bucket
+    ret = ps->remove(bucket_meta_obj, &objv_tracker);
+    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(bucket_topics, &objv_tracker);
   if (ret < 0) {
     ldout(store->ctx(), 1) << "ERROR: failed to write topics info: ret=" << ret << dendl;