]> git-server-git.apps.pok.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>
Tue, 27 Nov 2018 15:15:51 +0000 (16:15 +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>
src/rgw/rgw_admin.cc
src/test/cli/radosgw-admin/help.t

index 2ce8cfde3444516eb7bb575d4c6cb9bd077f1160..e453c81aafcb838255fddaf178dfe3260093ac16 100644 (file)
@@ -219,6 +219,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 << "  mfa create                 create a new MFA TOTP token\n";
@@ -525,7 +527,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)
@@ -979,11 +982,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;
 }
 
@@ -7638,9 +7643,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 21c904a0c991c02c4e60b5c759c4b7c46ff36587..68cd5a49eedabff7ebfbea1d5ca22815d8bdd9ae 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
     mfa create                 create a new MFA TOTP token