From 1ca25b50ad23582f669033ea96096f269e62614d Mon Sep 17 00:00:00 2001 From: "Adam C. Emerson" Date: Tue, 12 Apr 2022 16:46:46 -0400 Subject: [PATCH] rgw: Get rid of RGWBucketPipeSyncStatusManager::get_sync_status Instead of one function that sets a variable and another function that returns it and nobody else touches it, just return the sync status. Signed-off-by: Adam C. Emerson --- src/rgw/rgw_admin.cc | 13 ++++++------- src/rgw/rgw_data_sync.cc | 11 +++++++---- src/rgw/rgw_data_sync.h | 9 +++------ 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index f98a436c7d2..5d23d5ce8bf 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -8955,19 +8955,18 @@ next: return -ret; } - ret = sync.read_sync_status(dpp()); - if (ret < 0) { - cerr << "ERROR: sync.read_sync_status() returned ret=" << ret << std::endl; + auto sync_status = sync.read_sync_status(dpp()); + if (!sync_status) { + cerr << "ERROR: sync.read_sync_status() returned error=" + << sync_status.error() << std::endl; return -ret; } - map& sync_status = sync.get_sync_status(); - - encode_json("sync_status", sync_status, formatter.get()); + encode_json("sync_status", *sync_status, formatter.get()); formatter->flush(cout); } - if (opt_cmd == OPT::BUCKET_SYNC_RUN) { + if (opt_cmd == OPT::BUCKET_SYNC_RUN) { if (source_zone.empty()) { cerr << "ERROR: source zone not specified" << std::endl; return EINVAL; diff --git a/src/rgw/rgw_data_sync.cc b/src/rgw/rgw_data_sync.cc index e45aab5b67b..c9701bf3824 100644 --- a/src/rgw/rgw_data_sync.cc +++ b/src/rgw/rgw_data_sync.cc @@ -5469,8 +5469,11 @@ int RGWBucketPipeSyncStatusManager::init_sync_status(const DoutPrefixProvider *d return cr_mgr.run(dpp, stacks); } -int RGWBucketPipeSyncStatusManager::read_sync_status(const DoutPrefixProvider *dpp) +tl::expected, int> +RGWBucketPipeSyncStatusManager::read_sync_status( + const DoutPrefixProvider *dpp) { + std::map sync_status; list stacks; for (auto& mgr : source_mgrs) { @@ -5485,11 +5488,11 @@ int RGWBucketPipeSyncStatusManager::read_sync_status(const DoutPrefixProvider *d int ret = cr_mgr.run(dpp, stacks); if (ret < 0) { ldpp_dout(this, 0) << "ERROR: failed to read sync status for " - << bucket_str{dest_bucket} << dendl; - return ret; + << bucket_str{dest_bucket} << dendl; + return tl::unexpected(ret); } - return 0; + return sync_status; } int RGWBucketPipeSyncStatusManager::run(const DoutPrefixProvider *dpp) diff --git a/src/rgw/rgw_data_sync.h b/src/rgw/rgw_data_sync.h index 8beb3fba772..d54a20bc079 100644 --- a/src/rgw/rgw_data_sync.h +++ b/src/rgw/rgw_data_sync.h @@ -730,8 +730,6 @@ class RGWBucketPipeSyncStatusManager : public DoutPrefixProvider { std::vector source_mgrs; - std::map sync_status; - public: RGWBucketPipeSyncStatusManager(rgw::sal::RadosStore* store, std::optional source_zone, @@ -743,9 +741,6 @@ public: int init(const DoutPrefixProvider *dpp); - std::map& get_sync_status() { return sync_status; } - int init_sync_status(const DoutPrefixProvider *dpp); - static std::string full_status_oid(const rgw_zone_id& source_zone, const rgw_bucket& source_bucket, const rgw_bucket& dest_bucket); @@ -762,7 +757,9 @@ public: unsigned get_subsys() const override; std::ostream& gen_prefix(std::ostream& out) const override; - int read_sync_status(const DoutPrefixProvider *dpp); + int init_sync_status(const DoutPrefixProvider *dpp); + tl::expected, int> read_sync_status( + const DoutPrefixProvider *dpp); int run(const DoutPrefixProvider *dpp); }; -- 2.39.5