]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: add radosgw-admin sync error trim to trim sync error log 19854/head
authorfang yuxiang <fang.yuxiang@eisoo.com>
Tue, 9 Jan 2018 03:03:52 +0000 (11:03 +0800)
committerfang yuxiang <fang.yuxiang@eisoo.com>
Tue, 9 Jan 2018 06:24:42 +0000 (14:24 +0800)
Signed-off-by: fang yuxiang fang.yuxiang@eisoo.com
doc/man/8/radosgw-admin.rst
src/rgw/rgw_admin.cc
src/test/cli/radosgw-admin/help.t

index b883176a8d6dbbc4a4cfa1594b28ed41806eef7d..057b070561baaf30f73c406dda31cc8977638377 100644 (file)
@@ -290,6 +290,12 @@ which are as follows:
 :command:`data sync run`
   Run data sync for the specified source zone.
 
+:command:`sync error list`
+  list sync error.
+
+:command:`sync error trim`
+  trim sync error.
+
 :command:`zone rename`
   Rename a zone.
 
index 03066016731305b67403c48ebba88dc3e2d46a2e..abf4f0d3199b63113de076c2f4461cffa1d7e63f 100644 (file)
@@ -207,6 +207,8 @@ void usage()
   cout << "  reshard status             read bucket resharding status\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>         tenant name\n";
   cout << "   --uid=<id>                user id\n";
@@ -441,6 +443,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,
@@ -851,6 +854,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;
@@ -6750,6 +6755,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;
index b83b04841fd0a030f5f43dedaae1c0e83224ce6b..f4d0e0849ddb6e73758236ea06bcb8b77e10ecac 100644 (file)
     reshard status             read bucket resharding status
     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>         tenant name
      --uid=<id>                user id