From d61beb74f66c2fde29fd217bba63892567fd6ac0 Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Tue, 17 Dec 2019 13:30:48 -0500 Subject: [PATCH] radosgw-admin: sync status displays id of shard furthest behind 'radosgw-admin sync status' gives you a timestamp for the "oldest incremental change not applied", but doesn't tell you which shard that came from. add [shard-id] to the output Fixes: https://tracker.ceph.com/issues/43360 Signed-off-by: Casey Bodley --- src/rgw/rgw_admin.cc | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index 7cb99a0544d..ecc9e507a09 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -2104,22 +2104,24 @@ static void get_md_sync_status(list& status) if (ret < 0) { derr << "ERROR: failed to fetch master next positions (" << cpp_strerror(-ret) << ")" << dendl; } else { - ceph::real_time oldest; + std::optional> oldest; + for (auto iter : master_pos) { rgw_mdlog_shard_data& shard_data = iter.second; if (!shard_data.entries.empty()) { rgw_mdlog_entry& entry = shard_data.entries.front(); - if (ceph::real_clock::is_zero(oldest)) { - oldest = entry.timestamp; - } else if (!ceph::real_clock::is_zero(entry.timestamp) && entry.timestamp < oldest) { - oldest = entry.timestamp; + if (!oldest) { + oldest.emplace(iter.first, entry.timestamp); + } else if (!ceph::real_clock::is_zero(entry.timestamp) && entry.timestamp < oldest->second) { + oldest.emplace(iter.first, entry.timestamp); } } } - if (!ceph::real_clock::is_zero(oldest)) { - push_ss(ss, status) << "oldest incremental change not applied: " << oldest; + if (oldest) { + push_ss(ss, status) << "oldest incremental change not applied: " + << oldest->second << " [" << oldest->first << ']'; } } } @@ -2257,22 +2259,24 @@ static void get_data_sync_status(const string& source_zone, list& status if (ret < 0) { derr << "ERROR: failed to fetch next positions (" << cpp_strerror(-ret) << ")" << dendl; } else { - ceph::real_time oldest; + std::optional> oldest; + for (auto iter : master_pos) { rgw_datalog_shard_data& shard_data = iter.second; if (!shard_data.entries.empty()) { rgw_datalog_entry& entry = shard_data.entries.front(); - if (ceph::real_clock::is_zero(oldest)) { - oldest = entry.timestamp; - } else if (!ceph::real_clock::is_zero(entry.timestamp) && entry.timestamp < oldest) { - oldest = entry.timestamp; + if (!oldest) { + oldest.emplace(iter.first, entry.timestamp); + } else if (!ceph::real_clock::is_zero(entry.timestamp) && entry.timestamp < oldest->second) { + oldest.emplace(iter.first, entry.timestamp); } } } - if (!ceph::real_clock::is_zero(oldest)) { - push_ss(ss, status, tab) << "oldest incremental change not applied: " << oldest; + if (oldest) { + push_ss(ss, status, tab) << "oldest incremental change not applied: " + << oldest->second << " [" << oldest->first << ']'; } } } -- 2.39.5