mirror of https://github.com/ceph/ceph synced 2025-01-20 01:51:34 +00:00

rgw_admin: read master log shards from master's current period

Also make the sync output look similar to the output of data sync
Signed-off-by: Abhishek Lekshmanan <abhishek@suse.com>
This commit is contained in:
Abhishek Lekshmanan 2017-01-13 16:32:55 +01:00
parent 063c949d44
commit cc306c506c

View File

@ -1794,21 +1794,19 @@ static void get_md_sync_status(list<string>& status)
return; return;
} }
map<int, RGWMetadataLogInfo> master_shards_info; map<int, RGWMetadataLogInfo> master_shards_info;
string master_start_period; string master_period = store->get_current_period_id();
ret = sync.read_master_log_shards_info(&master_start_period, &master_shards_info); ret = sync.read_master_log_shards_info(master_period, &master_shards_info);
if (ret < 0) { if (ret < 0) {
status.push_back(string("failed to fetch master sync status: ") + cpp_strerror(-ret)); status.push_back(string("failed to fetch master sync status: ") + cpp_strerror(-ret));
return; return;
} }
map<int, string> shards_behind; map<int, string> shards_behind;
if (store->get_current_period_id() != sync_status.sync_info.period) { if (sync_status.sync_info.period != master_period) {
status.push_back(string("master is on a different period: master_period=" + status.push_back(string("master is on a different period: master_period=" +
store->get_current_period_id() + " local_period=" + master_period + " local_period=" + sync_status.sync_info.period));
sync_status.sync_info.period));
} else { } else {
for (auto local_iter : sync_status.sync_markers) { for (auto local_iter : sync_status.sync_markers) {
int shard_id = local_iter.first; int shard_id = local_iter.first;
@ -1828,7 +1826,7 @@ static void get_md_sync_status(list<string>& status)
int total_behind = shards_behind.size() + (sync_status.sync_info.num_shards - num_inc); int total_behind = shards_behind.size() + (sync_status.sync_info.num_shards - num_inc);
if (total_behind == 0) { if (total_behind == 0) {
status.push_back("metadata is caught up with master"); push_ss(ss, status) << "metadata is caught up with master";
} else { } else {
push_ss(ss, status) << "metadata is behind on " << total_behind << " shards"; push_ss(ss, status) << "metadata is behind on " << total_behind << " shards";