From d6a753e576818e5957fa734c49d55003e3b06d44 Mon Sep 17 00:00:00 2001 From: lvshanchun Date: Mon, 5 Feb 2018 20:53:39 +0800 Subject: [PATCH] rgw: add --shard-id for data sync status when specified --shard-id with data sync status, it'll display the realated pending and recovering bucket shards, as well as sync marker, besides this, we can specified --max-entries to limit the number of datalog entries(for pending buckets) or omapkey entries(for recovering buckets) be consumed. Signed-off-by: lvshanchun (cherry picked from commit 1dc7f5ea207dc17c743bfa1e06db446e16d31aa6) --- src/rgw/rgw_admin.cc | 82 ++++++++++++++++++++++++++++---------------- 1 file changed, 52 insertions(+), 30 deletions(-) diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index 7754d7fff5d99..b46fca2c1bdcf 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -219,18 +219,21 @@ void usage() cout << " --max-buckets max number of buckets for a user\n"; cout << " --admin set the admin flag on the user\n"; cout << " --system set the system flag on the user\n"; - cout << " --bucket=\n"; - cout << " --pool=\n"; - cout << " --object=\n"; - cout << " --date=\n"; - cout << " --start-date=\n"; - cout << " --end-date=\n"; - cout << " --bucket-id=\n"; - cout << " --shard-id= optional for mdlog list\n"; + cout << " --bucket= Specify the bucket name. Also used by the quota command.\n"; + cout << " --pool= Specify the pool name. Also used to scan for leaked rados objects.\n"; + cout << " --object= object name\n"; + cout << " --date= date in the format yyyy-mm-dd\n"; + cout << " --start-date= start date in the format yyyy-mm-dd\n"; + cout << " --end-date= end date in the format yyyy-mm-dd\n"; + cout << " --bucket-id= bucket id\n"; + cout << " --shard-id= optional for: \n"; + cout << " mdlog list\n"; + cout << " data sync status\n"; cout << " required for: \n"; cout << " mdlog trim\n"; cout << " replica mdlog get/delete\n"; cout << " replica datalog get/delete\n"; + cout << " --max-entries= max entries for listing operations\n"; cout << " --metadata-key= key to retrieve metadata from with metadata get\n"; cout << " --remote= zone or zonegroup id of remote gateway\n"; cout << " --period= period id\n"; @@ -6458,34 +6461,53 @@ next: } rgw_data_sync_status sync_status; - ret = sync.read_sync_status(&sync_status); - if (ret < 0 && ret != -ENOENT) { - cerr << "ERROR: sync.read_sync_status() returned ret=" << ret << std::endl; - return -ret; - } + if (specified_shard_id) { + set pending_buckets; + set recovering_buckets; + rgw_data_sync_marker sync_marker; + ret = sync.read_shard_status(shard_id, pending_buckets, recovering_buckets, &sync_marker, + max_entries_specified ? max_entries : 20); + if (ret < 0 && ret != -ENOENT) { + cerr << "ERROR: sync.read_shard_status() returned ret=" << ret << std::endl; + return -ret; + } + formatter->open_object_section("summary"); + encode_json("shard_id", shard_id, formatter); + encode_json("marker", sync_marker, formatter); + encode_json("pending_buckets", pending_buckets, formatter); + encode_json("recovering_buckets", recovering_buckets, formatter); + formatter->close_section(); + formatter->flush(cout); + } else { + ret = sync.read_sync_status(&sync_status); + if (ret < 0 && ret != -ENOENT) { + cerr << "ERROR: sync.read_sync_status() returned ret=" << ret << std::endl; + return -ret; + } - formatter->open_object_section("summary"); - encode_json("sync_status", sync_status, formatter); + formatter->open_object_section("summary"); + encode_json("sync_status", sync_status, formatter); - uint64_t full_total = 0; - uint64_t full_complete = 0; + uint64_t full_total = 0; + uint64_t full_complete = 0; - for (auto marker_iter : sync_status.sync_markers) { - full_total += marker_iter.second.total_entries; - if (marker_iter.second.state == rgw_meta_sync_marker::SyncState::FullSync) { - full_complete += marker_iter.second.pos; - } else { - full_complete += marker_iter.second.total_entries; + for (auto marker_iter : sync_status.sync_markers) { + full_total += marker_iter.second.total_entries; + if (marker_iter.second.state == rgw_meta_sync_marker::SyncState::FullSync) { + full_complete += marker_iter.second.pos; + } else { + full_complete += marker_iter.second.total_entries; + } } - } - formatter->open_object_section("full_sync"); - encode_json("total", full_total, formatter); - encode_json("complete", full_complete, formatter); - formatter->close_section(); - formatter->close_section(); + formatter->open_object_section("full_sync"); + encode_json("total", full_total, formatter); + encode_json("complete", full_complete, formatter); + formatter->close_section(); + formatter->close_section(); - formatter->flush(cout); + formatter->flush(cout); + } } if (opt_cmd == OPT_DATA_SYNC_INIT) { -- 2.39.5