Skip to content

Commit

Permalink
rgw: add "--sync-detail" in radosgw-admin sync status
Browse files Browse the repository at this point in the history
when sepcified --sync-detail in radosgw-admin sync status,
it will display lagging buckets belong to the related source zone,
the lagging buckets are related with both behind shards and error
shards.

Signed-off-by: lvshanchun <lvshanchun@gmail.com>
  • Loading branch information
Leeshine committed Dec 29, 2017
1 parent b4169dd commit c77de5d
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions src/rgw/rgw_admin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2045,7 +2045,7 @@ static void get_md_sync_status(list<string>& status)
flush_ss(ss, status);
}

static void get_data_sync_status(const string& source_zone, list<string>& status, int tab)
static void get_data_sync_status(const string& source_zone, list<string>& status, int tab, bool sync_detail)
{
stringstream ss;

Expand Down Expand Up @@ -2202,6 +2202,27 @@ static void get_data_sync_status(const string& source_zone, list<string>& status
push_ss(ss, status, tab) << "error shards: " << "[" << error_shards << "]";
}

if (sync_detail) {
ret = sync.read_lagging_buckets(&sync_status, shards_behind, error_shards); // read error shards
if (ret < 0 && ret != -ENOENT) {
push_ss(ss, status, tab) << string("failed read lagging buckets: ") + cpp_strerror(-ret);
return;
}
set<string> lagging_buckets = sync_status.lagging_buckets;
if (lagging_buckets.size() > 0) {
push_ss(ss, status,tab) << "data is lagging on " << lagging_buckets.size() << " buckets";
string lagging_str = "lagging buckets: ";
set<string>::iterator iter = lagging_buckets.begin();
push_ss(ss, status, tab) << lagging_str << *iter;
++iter;

int new_tab = tab + lagging_str.size();
for (; iter != lagging_buckets.end(); ++iter) {
push_ss(ss, status, new_tab) << *iter;
}
}
}

flush_ss(ss, status);
}

Expand All @@ -2216,7 +2237,7 @@ static void tab_dump(const string& header, int width, const list<string>& entrie
}


static void sync_status(Formatter *formatter)
static void sync_status(Formatter *formatter, bool sync_detail)
{
RGWRealm& realm = store->realm;
RGWZoneGroup& zonegroup = store->get_zonegroup();
Expand Down Expand Up @@ -2249,7 +2270,7 @@ static void sync_status(Formatter *formatter)
s += string(" (") + siter->second.name + ")";
}
data_status.push_back(s);
get_data_sync_status(source_id, data_status, source_str.size());
get_data_sync_status(source_id, data_status, source_str.size(), sync_detail);
}

tab_dump("data sync", width, data_status);
Expand Down Expand Up @@ -2477,6 +2498,7 @@ int main(int argc, const char **argv)
int include_all = false;

int sync_stats = false;
int sync_detail = false;
int bypass_gc = false;
int warnings_only = false;
int inconsistent_index = false;
Expand Down Expand Up @@ -2713,6 +2735,8 @@ int main(int argc, const char **argv)
// do nothing
} else if (ceph_argparse_binary_flag(args, i, &sync_stats, NULL, "--sync-stats", (char*)NULL)) {
// do nothing
} else if (ceph_argparse_binary_flag(args, i, &sync_detail, NULL, "--sync-detail", (char*)NULL)) {
// do nothing
} else if (ceph_argparse_binary_flag(args, i, &include_all, NULL, "--include-all", (char*)NULL)) {
// do nothing
} else if (ceph_argparse_binary_flag(args, i, &extra_info, NULL, "--extra-info", (char*)NULL)) {
Expand Down Expand Up @@ -6363,7 +6387,7 @@ int main(int argc, const char **argv)
}

if (opt_cmd == OPT_SYNC_STATUS) {
sync_status(formatter);
sync_status(formatter, sync_detail);
}

if (opt_cmd == OPT_METADATA_SYNC_STATUS) {
Expand Down

0 comments on commit c77de5d

Please sign in to comment.