Skip to content

Commit

Permalink
cli: use rgw-admin reshard stale-instances list/delete
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
theanalyst committed Nov 27, 2018
1 parent 0c35a6f commit bf8f885
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
29 changes: 22 additions & 7 deletions src/rgw/rgw_admin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -7638,9 +7643,19 @@ int main(int argc, const char **argv)

}

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;
}
2 changes: 2 additions & 0 deletions src/test/cli/radosgw-admin/help.t
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@
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
Expand Down

0 comments on commit bf8f885

Please sign in to comment.