]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: add radosgw-admin sync error trim to trim sync error log 20859/head
authorfang yuxiang <fang.yuxiang@eisoo.com>
Tue, 9 Jan 2018 03:03:52 +0000 (11:03 +0800)
committerPrashant D <pdhange@redhat.com>
Tue, 13 Mar 2018 05:17:11 +0000 (01:17 -0400)
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
src/rgw/rgw_admin.cc
src/test/cli/radosgw-admin/help.t

index ab33f7e8cd77a87f6601fb679b8bf00883d96dfe..4aaeb392285e5d083b17de783a2be0dde68ff340 100644 (file)
@@ -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.
 
index 141f3df32490de23674cc4c668b873b6668f7ab6..d25ae487d07cf0f879c8df49c6122932172518d9 100644 (file)
@@ -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>         tenant name\n";
   cout << "   --uid=<id>                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;
index 7bfcddf85843553d21a12081e8898cf8d455998f..44b6f83015f2170dd48e553eac42cf3d10fb1628 100644 (file)
     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>         tenant name
      --uid=<id>                user id