]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/notifications: delete bucket notification object when empty 39944/head
authorYuval Lifshitz <ylifshit@redhat.com>
Tue, 9 Mar 2021 10:36:09 +0000 (12:36 +0200)
committerYuval Lifshitz <ylifshit@redhat.com>
Tue, 9 Mar 2021 10:36:09 +0000 (12:36 +0200)
Fixes: https://tracker.ceph.com/issues/49650
Signed-off-by: Yuval Lifshitz <ylifshit@redhat.com>
src/rgw/rgw_pubsub.cc

index 33f650914c55f8747c2b3f4eef0bf4d55ce019f5..8d0256d197476c878ee0f2fad0f75f14890d3d4f 100644 (file)
@@ -603,6 +603,17 @@ int RGWPubSub::Bucket::remove_notification(const string& topic_name, optional_yi
 
   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, 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(bucket_topics, &objv_tracker, y);
   if (ret < 0) {
     ldout(store->ctx(), 1) << "ERROR: failed to write topics info: ret=" << ret << dendl;
@@ -631,7 +642,7 @@ int RGWPubSub::Bucket::remove_notifications(optional_yield y)
     }
   }
 
-  // delete all notification of on a bucket
+  // delete the notification object of the bucket
   ret = ps->remove(bucket_meta_obj, nullptr, y);
   if (ret < 0 && ret != -ENOENT) {
     ldout(ps->store->ctx(), 1) << "ERROR: failed to remove bucket topics: ret=" << ret << dendl;