]> 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>
Wed, 6 Mar 2019 14:45:49 +0000 (15:45 +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)

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

index f17ae539ed5fb49510881837f2023a4e90acfdba..1bd89a59a1e538353bccddccc24d7730402155f7 100644 (file)
@@ -213,6 +213,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 << "  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";
@@ -516,7 +518,8 @@ enum {
   OPT_MFA_LIST,
   OPT_MFA_CHECK,
   OPT_MFA_RESYNC,
-  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)
@@ -988,11 +991,13 @@ static int get_cmd(const char *cmd, const char *prev_cmd, const char *prev_prev_
       return OPT_MFA_CHECK;
     if (strcmp(cmd, "resync") == 0)
       return OPT_MFA_RESYNC;
-  } 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 (match_str(cmd, "rm", "delete"))
+      return OPT_RESHARD_STALE_INSTANCES_DELETE;
   }
-
   return -EINVAL;
 }
 
@@ -7937,9 +7942,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 bf2f9b94f3a9cb7db990c2aa5447d1ddc416829c..912c500c54b3390616fee0fae045034d4ed68df1 100644 (file)
     reshard status             read bucket resharding status
     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: