]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cli: use rgw-admin reshard stale-instances list/delete
authorAbhishek Lekshmanan <abhishek@suse.com>
Mon, 15 Oct 2018 17:34:28 +0000 (19:34 +0200)
committerAbhishek Lekshmanan <abhishek@suse.com>
Thu, 29 Nov 2018 12:55:11 +0000 (13:55 +0100)
Add a delete command as well that clears the resharded instances. We print out
the json status to indicate success or error state

Signed-off-by: Abhishek Lekshmanan <abhishek@suse.com>
(cherry picked from commit bf8f885016a588130f05c25fdef3d3b6e1216c40)

 Conflicts:
src/rgw/rgw_admin.cc:
  ceph::util::match_str and the related rm/delete normalizations introduced in
  mimic are not backported

src/rgw/rgw_admin.cc
src/test/cli/radosgw-admin/help.t

index 3dc40d309dba2b37e6390fe829a2b9df4ec89264..09ce3b206f3aa507d21ab522a81216ea80d5547e 100644 (file)
@@ -201,6 +201,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 << "  reshard stale-instances list list stale-instances from bucket resharding\n";
+  cout << "  reshard stale-instances rm   cleanup stale-instances from bucket resharding\n";
   cout << "  sync error list            list sync error\n";
   cout << "  sync error trim            trim sync error\n";
   cout << "options:\n";
@@ -497,7 +499,8 @@ enum {
   OPT_RESHARD_STATUS,
   OPT_RESHARD_PROCESS,
   OPT_RESHARD_CANCEL,
-  OPT_STALE_INSTANCES_LIST
+  OPT_RESHARD_STALE_INSTANCES_LIST,
+  OPT_RESHARD_STALE_INSTANCES_DELETE
 };
 
 static int get_cmd(const char *cmd, const char *prev_cmd, const char *prev_prev_cmd, bool *need_more)
@@ -953,9 +956,13 @@ static int get_cmd(const char *cmd, const char *prev_cmd, const char *prev_prev_
       return OPT_RESHARD_PROCESS;
     if (strcmp(cmd, "cancel") == 0)
       return OPT_RESHARD_CANCEL;
-  } else if (strcmp(prev_cmd, "stale-instances") == 0) {
+  } else if ((prev_prev_cmd && strcmp(prev_prev_cmd, "reshard") == 0) &&
+            (strcmp(prev_cmd, "stale-instances") == 0)) {
     if (strcmp(cmd, "list") == 0)
-      return OPT_STALE_INSTANCES_LIST;
+      return OPT_RESHARD_STALE_INSTANCES_LIST;
+    if (strcmp(cmd, "rm") == 0 ||
+        strcmp(cmd, "delete") == 0)
+      return OPT_RESHARD_STALE_INSTANCES_DELETE;
   }
 
   return -EINVAL;
@@ -7501,9 +7508,19 @@ next:
     }
   }
 
-  if (opt_cmd == OPT_STALE_INSTANCES_LIST) {
-    RGWBucketAdminOp::list_stale_instances(store, bucket_op,f);
-  }
+ if (opt_cmd == OPT_RESHARD_STALE_INSTANCES_LIST) {
+   ret = RGWBucketAdminOp::list_stale_instances(store, bucket_op,f);
+   if (ret < 0) {
+     cerr << "ERROR: listing stale instances" << cpp_strerror(-ret) << std::endl;
+   }
+ }
 
-  return 0;
+ if (opt_cmd == OPT_RESHARD_STALE_INSTANCES_DELETE) {
+   ret = RGWBucketAdminOp::clear_stale_instances(store, bucket_op,f);
+   if (ret < 0) {
+     cerr << "ERROR: deleting stale instances" << cpp_strerror(-ret) << std::endl;
+   }
+ }
+
+ return 0;
 }
index f847c7677eb0736d07807e09e8b8098dd67512ac..706a5673932de0a711c4b5073fc3dd2ba53aba16 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
+    reshard stale-instances list list stale-instances from bucket resharding
+    reshard stale-instances rm   cleanup stale-instances from bucket resharding
     sync error list            list sync error
     sync error trim            trim sync error
   options: