From 281fb678918f3c5abe05efed2c513833c9587351 Mon Sep 17 00:00:00 2001 From: Yuval Lifshitz Date: Tue, 9 Mar 2021 12:36:09 +0200 Subject: [PATCH] rgw/notifications: delete bucket notification object when empty Fixes: https://tracker.ceph.com/issues/49650 Signed-off-by: Yuval Lifshitz (cherry picked from commit 08e9846fd5a040887e2ddbfca36da97777fc76f6) Conflicts: src/rgw/rgw_pubsub.cc - octopus does not have optional_yield arg --- src/rgw/rgw_pubsub.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/rgw/rgw_pubsub.cc b/src/rgw/rgw_pubsub.cc index a25544bd772..5dc49c96bf6 100644 --- a/src/rgw/rgw_pubsub.cc +++ b/src/rgw/rgw_pubsub.cc @@ -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; -- 2.47.3