From 703115100233ba98ae8795e130f44a3d9455944c Mon Sep 17 00:00:00 2001 From: fang yuxiang Date: Tue, 9 Jan 2018 11:03:52 +0800 Subject: [PATCH] rgw: add radosgw-admin sync error trim to trim sync error log Signed-off-by: fang yuxiang fang.yuxiang@eisoo.com (cherry picked from commit 233a4d237dca876aebe2891dd5f1a174f6904c62) Conflicts: doc/man/8/radosgw-admin.rst: Resolved for sync commands --- doc/man/8/radosgw-admin.rst | 6 ++++++ src/rgw/rgw_admin.cc | 32 +++++++++++++++++++++++++++++++ src/test/cli/radosgw-admin/help.t | 2 ++ 3 files changed, 40 insertions(+) diff --git a/doc/man/8/radosgw-admin.rst b/doc/man/8/radosgw-admin.rst index ab33f7e8cd77a..4aaeb392285e5 100644 --- a/doc/man/8/radosgw-admin.rst +++ b/doc/man/8/radosgw-admin.rst @@ -131,6 +131,12 @@ which are as follows: :command:`zone list` List all zones set on this cluster. +:command:`sync error list` + list sync error. + +:command:`sync error trim` + trim sync error. + :command:`pool add` Add an existing pool for data placement. diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index 141f3df32490d..d25ae487d07cf 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -198,6 +198,8 @@ void usage() cout << " reshard list list all bucket resharding or scheduled to be reshared\n"; cout << " reshard process process of scheduled reshard jobs\n"; cout << " reshard cancel cancel resharding a bucket\n"; + cout << " sync error list list sync error\n"; + cout << " sync error trim trim sync error\n"; cout << "options:\n"; cout << " --tenant= tenant name\n"; cout << " --uid= user id\n"; @@ -431,6 +433,7 @@ enum { OPT_MDLOG_FETCH, OPT_MDLOG_STATUS, OPT_SYNC_ERROR_LIST, + OPT_SYNC_ERROR_TRIM, OPT_BILOG_LIST, OPT_BILOG_TRIM, OPT_BILOG_STATUS, @@ -844,6 +847,8 @@ static int get_cmd(const char *cmd, const char *prev_cmd, const char *prev_prev_ (strcmp(prev_cmd, "error") == 0)) { if (strcmp(cmd, "list") == 0) return OPT_SYNC_ERROR_LIST; + if (strcmp(cmd, "trim") == 0) + return OPT_SYNC_ERROR_TRIM; } else if (strcmp(prev_cmd, "mdlog") == 0) { if (strcmp(cmd, "list") == 0) return OPT_MDLOG_LIST; @@ -6693,6 +6698,33 @@ next: formatter->flush(cout); } + if (opt_cmd == OPT_SYNC_ERROR_TRIM) { + utime_t start_time, end_time; + int ret = parse_date_str(start_date, start_time); + if (ret < 0) + return -ret; + + ret = parse_date_str(end_date, end_time); + if (ret < 0) + return -ret; + + if (shard_id < 0) { + shard_id = 0; + } + + for (; shard_id < ERROR_LOGGER_SHARDS; ++shard_id) { + string oid = RGWSyncErrorLogger::get_shard_oid(RGW_SYNC_ERROR_LOG_SHARD_PREFIX, shard_id); + ret = store->time_log_trim(oid, start_time.to_real_time(), end_time.to_real_time(), start_marker, end_marker); + if (ret < 0 && ret != -ENODATA) { + cerr << "ERROR: sync error trim: " << cpp_strerror(-ret) << std::endl; + return -ret; + } + if (specified_shard_id) { + break; + } + } + } + if (opt_cmd == OPT_BILOG_TRIM) { if (bucket_name.empty()) { cerr << "ERROR: bucket not specified" << std::endl; diff --git a/src/test/cli/radosgw-admin/help.t b/src/test/cli/radosgw-admin/help.t index 7bfcddf858435..44b6f83015f21 100644 --- a/src/test/cli/radosgw-admin/help.t +++ b/src/test/cli/radosgw-admin/help.t @@ -140,6 +140,8 @@ reshard list list all bucket resharding or scheduled to be reshared reshard process process of scheduled reshard jobs reshard cancel cancel resharding a bucket + sync error list list sync error + sync error trim trim sync error options: --tenant= tenant name --uid= user id -- 2.39.5