From: Yuval Lifshitz Date: Tue, 9 Mar 2021 10:36:09 +0000 (+0200) Subject: rgw/notifications: delete bucket notification object when empty X-Git-Tag: v16.2.6~90^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F42631%2Fhead;p=ceph.git 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 Cherry-pick notes: - RGWPubSub methods take a DoutPrefixProvider as first argument in Pacific --- diff --git a/src/rgw/rgw_pubsub.cc b/src/rgw/rgw_pubsub.cc index 00d8ffdc8642..c981fc03f553 100644 --- a/src/rgw/rgw_pubsub.cc +++ b/src/rgw/rgw_pubsub.cc @@ -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;