From f447570a47e053fc43ce5b99d41e4fb805eee777 Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Tue, 6 Oct 2020 17:59:36 -0400 Subject: [PATCH] radosgw-admin: 'bucket sync status' displays new full sync status Signed-off-by: Casey Bodley --- src/rgw/rgw_admin.cc | 52 +++++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index f0a4341a4bc25..355e2c3396537 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -2275,39 +2275,41 @@ static int bucket_source_sync_status(rgw::sal::RGWRadosStore *store, const RGWZo return r; } + out << indented{width, "source bucket"} << source_bucket_info.bucket.get_key() << std::endl; + pipe.source.bucket = source_bucket; pipe.dest.bucket = bucket_info.bucket; + rgw_bucket_sync_status full_status; + r = rgw_read_bucket_full_sync_status(dpp(), store, pipe, &full_status, null_yield); + if (r < 0) { + lderr(store->ctx()) << "failed to read bucket full sync status: " << cpp_strerror(r) << dendl; + return r; + } + + if (full_status.state == BucketSyncState::Init) { + out << indented{width} << "init: bucket sync has not started\n"; + return 0; + } + if (full_status.state == BucketSyncState::Stopped) { + out << indented{width} << "stopped: bucket sync is disabled\n"; + return 0; + } + if (full_status.state == BucketSyncState::Full) { + out << indented{width} << "full sync: " << full_status.full.count << " objects completed\n"; + return 0; + } + std::vector status; r = rgw_read_bucket_inc_sync_status(dpp(), store, pipe, bucket_info, &source_bucket_info, &status); if (r < 0) { - lderr(store->ctx()) << "failed to read bucket sync status: " << cpp_strerror(r) << dendl; + lderr(store->ctx()) << "failed to read bucket incremental sync status: " << cpp_strerror(r) << dendl; return r; } - out << indented{width, "source bucket"} << source_bucket_info.bucket.get_key() << std::endl; - - int num_full = 0; - int num_inc = 0; - uint64_t full_complete = 0; const size_t total_shards = status.size(); - using BucketSyncState = rgw_bucket_shard_sync_info::SyncState; - for (size_t shard_id = 0; shard_id < total_shards; shard_id++) { - auto& m = status[shard_id]; - if (m.state == BucketSyncState::StateFullSync) { - num_full++; - full_complete += m.full_marker.count; - } else if (m.state == BucketSyncState::StateIncrementalSync) { - num_inc++; - } - } - - out << indented{width} << "full sync: " << num_full << "/" << total_shards << " shards\n"; - if (num_full > 0) { - out << indented{width} << "full sync: " << full_complete << " objects completed\n"; - } - out << indented{width} << "incremental sync: " << num_inc << "/" << total_shards << " shards\n"; + out << indented{width} << "incremental sync on " << total_shards << " shards\n"; BucketIndexShardsManager remote_markers; r = rgw_read_remote_bilog_info(conn, source_bucket, remote_markers, null_yield); @@ -2323,15 +2325,15 @@ static int bucket_source_sync_status(rgw::sal::RGWRadosStore *store, const RGWZo if (r.second.empty()) { continue; // empty bucket index shard } - auto pos = BucketIndexShardsManager::get_shard_marker(m.inc_marker.position); - if (m.state != BucketSyncState::StateIncrementalSync || pos != r.second) { + const auto pos = BucketIndexShardsManager::get_shard_marker(m.inc_marker.position); + if (pos < r.second) { shards_behind.insert(shard_id); } } if (!shards_behind.empty()) { out << indented{width} << "bucket is behind on " << shards_behind.size() << " shards\n"; out << indented{width} << "behind shards: [" << shards_behind << "]\n" ; - } else if (!num_full) { + } else { out << indented{width} << "bucket is caught up with source\n"; } return 0; -- 2.39.5