From 16af9ff82c578767caa61b43043c889f48a20237 Mon Sep 17 00:00:00 2001 From: Abhishek Lekshmanan Date: Mon, 15 Oct 2018 19:34:28 +0200 Subject: [PATCH] cli: use rgw-admin reshard stale-instances list/delete 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 (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 | 31 ++++++++++++++++++++++++------- src/test/cli/radosgw-admin/help.t | 2 ++ 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index 3dc40d309dba2..09ce3b206f3aa 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -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; } diff --git a/src/test/cli/radosgw-admin/help.t b/src/test/cli/radosgw-admin/help.t index f847c7677eb07..706a5673932de 100644 --- a/src/test/cli/radosgw-admin/help.t +++ b/src/test/cli/radosgw-admin/help.t @@ -140,6 +140,8 @@ 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: -- 2.39.5