summaryrefslogtreecommitdiffstats
path: root/src/rgw/rgw_admin.cc
diff options
context:
space:
mode:
authorAli Masarwa <amasarwa@redhat.com>2024-09-29 14:00:13 +0200
committerAli Masarwa <amasarwa@redhat.com>2024-10-21 09:42:33 +0200
commit575a19d2a81e959d21f64d1a9ed39a5db3b92957 (patch)
tree9f4abd33afb7d9831ac4b062e67ffcf6a4cafadd /src/rgw/rgw_admin.cc
parentMerge pull request #60212 from VallariAg/nvmeof-labeler (diff)
downloadceph-575a19d2a81e959d21f64d1a9ed39a5db3b92957.tar.xz
ceph-575a19d2a81e959d21f64d1a9ed39a5db3b92957.zip
RGW|Bucket notification: fix for v2 topics rgw-admin list operation
Signed-off-by: Ali Masarwa <amasarwa@redhat.com>
Diffstat (limited to 'src/rgw/rgw_admin.cc')
-rw-r--r--src/rgw/rgw_admin.cc50
1 files changed, 28 insertions, 22 deletions
diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc
index a8874195217..b00dfaa1ec5 100644
--- a/src/rgw/rgw_admin.cc
+++ b/src/rgw/rgw_admin.cc
@@ -11187,22 +11187,22 @@ next:
}
formatter->open_object_section("result");
- formatter->open_array_section("topics");
- do {
- rgw_pubsub_topics result;
- int ret = ps.get_topics(dpp(), next_token, max_entries,
- result, next_token, null_yield);
- if (ret < 0 && ret != -ENOENT) {
- cerr << "ERROR: could not get topics: " << cpp_strerror(-ret) << std::endl;
- return -ret;
- }
- for (const auto& [_, topic] : result.topics) {
- if (owner && *owner != topic.owner) {
- continue;
+ rgw_pubsub_topics result;
+ if (rgw::all_zonegroups_support(*site, rgw::zone_features::notification_v2) &&
+ driver->stat_topics_v1(tenant, null_yield, dpp()) == -ENOENT) {
+ formatter->open_array_section("topics");
+ do {
+ int ret = ps.get_topics_v2(dpp(), next_token, max_entries,
+ result, next_token, null_yield);
+ if (ret < 0 && ret != -ENOENT) {
+ cerr << "ERROR: could not get topics: " << cpp_strerror(-ret) << std::endl;
+ return -ret;
}
- std::set<std::string> subscribed_buckets;
- if (rgw::all_zonegroups_support(*site, rgw::zone_features::notification_v2) &&
- driver->stat_topics_v1(tenant, null_yield, dpp()) == -ENOENT) {
+ for (const auto& [_, topic] : result.topics) {
+ if (owner && *owner != topic.owner) {
+ continue;
+ }
+ std::set<std::string> subscribed_buckets;
ret = driver->get_bucket_topic_mapping(topic, subscribed_buckets,
null_yield, dpp());
if (ret < 0) {
@@ -11210,15 +11210,21 @@ next:
<< topic.name << ", ret=" << ret << std::endl;
}
show_topics_info_v2(topic, subscribed_buckets, formatter.get());
- } else {
- encode_json("result", result, formatter.get());
- }
- if (max_entries_specified) {
- --max_entries;
+ if (max_entries_specified) {
+ --max_entries;
+ }
}
+ result.topics.clear();
+ } while (!next_token.empty() && max_entries > 0);
+ formatter->close_section(); // topics
+ } else { // v1, list all topics
+ int ret = ps.get_topics_v1(dpp(), result, null_yield);
+ if (ret < 0 && ret != -ENOENT) {
+ cerr << "ERROR: could not get topics: " << cpp_strerror(-ret) << std::endl;
+ return -ret;
}
- } while (!next_token.empty() && max_entries > 0);
- formatter->close_section(); // topics
+ encode_json("result", result, formatter.get());
+ }
if (max_entries_specified) {
encode_json("truncated", !next_token.empty(), formatter.get());
if (!next_token.empty()) {