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<int, rgw_bucket_shard_sync_info>& 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;
return cr_mgr.run(dpp, stacks);
}
-int RGWBucketPipeSyncStatusManager::read_sync_status(const DoutPrefixProvider *dpp)
+tl::expected<std::map<int, rgw_bucket_shard_sync_info>, int>
+RGWBucketPipeSyncStatusManager::read_sync_status(
+ const DoutPrefixProvider *dpp)
{
+ std::map<int, rgw_bucket_shard_sync_info> sync_status;
list<RGWCoroutinesStack *> stacks;
for (auto& mgr : source_mgrs) {
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)
std::vector<RGWRemoteBucketManager> source_mgrs;
- std::map<int, rgw_bucket_shard_sync_info> sync_status;
-
public:
RGWBucketPipeSyncStatusManager(rgw::sal::RadosStore* store,
std::optional<rgw_zone_id> source_zone,
int init(const DoutPrefixProvider *dpp);
- std::map<int, rgw_bucket_shard_sync_info>& 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);
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<std::map<int, rgw_bucket_shard_sync_info>, int> read_sync_status(
+ const DoutPrefixProvider *dpp);
int run(const DoutPrefixProvider *dpp);
};