]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/notifications: delete bucket notification object when empty 42631/head
authorYuval Lifshitz <ylifshit@redhat.com>
Tue, 9 Mar 2021 10:36:09 +0000 (12:36 +0200)
committerCory Snyder <csnyder@iland.com>
Wed, 4 Aug 2021 13:38:17 +0000 (09:38 -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

Cherry-pick notes:
- RGWPubSub methods take a DoutPrefixProvider as first argument in Pacific

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;