From: Yehuda Sadeh Date: Wed, 24 May 2017 20:21:43 +0000 (-0700) Subject: radosgw-admin: reshard execute output adjustments X-Git-Tag: ses5-milestone6~8^2~7^2~17 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=40faa8d952a25022cefd6fb6005f09a806be5219;p=ceph.git radosgw-admin: reshard execute output adjustments Signed-off-by: Yehuda Sadeh --- diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index 7f12c1f36be..c3400bcc116 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -493,7 +493,6 @@ static int get_cmd(const char *cmd, const char *prev_cmd, const char *prev_prev_ // NOTE: please keep the checks in alphabetical order !!! if (strcmp(cmd, "bi") == 0 || strcmp(cmd, "bilog") == 0 || - strcmp(cmd, "bucket") == 0 || strcmp(cmd, "buckets") == 0 || strcmp(cmd, "caps") == 0 || strcmp(cmd, "data") == 0 || @@ -531,11 +530,19 @@ static int get_cmd(const char *cmd, const char *prev_cmd, const char *prev_prev_ return 0; } + /* + * can do both radosgw-admin bucket reshard, and radosgw-admin reshard bucket + */ if (strcmp(cmd, "reshard") == 0 && !(prev_cmd && strcmp(prev_cmd, "bucket") == 0)) { *need_more = true; return 0; } + if (strcmp(cmd, "bucket") == 0 && + !(prev_cmd && strcmp(prev_cmd, "reshard") == 0)) { + *need_more = true; + return 0; + } if (strcmp(cmd, "policy") == 0) return OPT_POLICY; @@ -910,6 +917,8 @@ static int get_cmd(const char *cmd, const char *prev_cmd, const char *prev_prev_ if (strcmp(cmd, "delete") == 0) return OPT_ROLE_POLICY_DELETE; } else if (strcmp(prev_cmd, "reshard") == 0) { + if (strcmp(cmd, "bucket") == 0) + return OPT_BUCKET_RESHARD; if (strcmp(cmd, "add") == 0) return OPT_RESHARD_ADD; if (strcmp(cmd, "list") == 0) @@ -5695,7 +5704,7 @@ next: } if (opt_cmd == OPT_RESHARD_EXECUTE) { - RGWReshard reshard(store); + RGWReshard reshard(store, true, &cout); int ret = reshard.process_all_logshards(); if (ret < 0) { diff --git a/src/rgw/rgw_reshard.cc b/src/rgw/rgw_reshard.cc index 7bc885dcdcd..da43cef42d0 100644 --- a/src/rgw/rgw_reshard.cc +++ b/src/rgw/rgw_reshard.cc @@ -294,6 +294,8 @@ int RGWBucketReshard::do_reshard( if (out) { (*out) << "*** NOTICE: operation will not remove old bucket index objects ***" << std::endl; (*out) << "*** these will need to be removed manually ***" << std::endl; + (*out) << "tenant: " << bucket_info.bucket.tenant << std::endl; + (*out) << "bucket name: " << bucket_info.bucket.name << std::endl; (*out) << "old bucket instance id: " << bucket_info.bucket.bucket_id << std::endl; (*out) << "new bucket instance id: " << new_bucket_info.bucket.bucket_id << std::endl; } @@ -477,7 +479,9 @@ sleep(10); } -RGWReshard::RGWReshard(RGWRados* _store): store(_store), instance_lock(bucket_instance_lock_name) +RGWReshard::RGWReshard(RGWRados* _store, bool _verbose, ostream *_out, + Formatter *_formatter) : store(_store), instance_lock(bucket_instance_lock_name), + verbose(_verbose), out(_out), formatter(_formatter) { num_logshards = store->ctx()->_conf->rgw_reshard_num_logs; } @@ -736,7 +740,7 @@ int RGWReshard::process_single_logshard(int logshard_num) RGWBucketAdminOpState bucket_op; RGWBucketReshard reshard_op(store, bucket_info, attrs); ret = reshard_op.do_reshard(entry.new_num_shards, new_bucket_info, - max_entries, false, nullptr, nullptr); + max_entries, verbose, out, formatter); if (ret < 0) { return ret; } diff --git a/src/rgw/rgw_reshard.h b/src/rgw/rgw_reshard.h index 2010ac4a478..4237d2dc4fc 100644 --- a/src/rgw/rgw_reshard.h +++ b/src/rgw/rgw_reshard.h @@ -54,6 +54,10 @@ class RGWReshard { rados::cls::lock::Lock instance_lock; int num_logshards; + bool verbose; + ostream *out; + Formatter *formatter; + void get_logshard_oid(int shard_num, string *shard); protected: class ReshardWorker : public Thread { @@ -81,7 +85,7 @@ protected: void get_bucket_logshard_oid(const string& tenant, const string& bucket_name, string *oid); public: - RGWReshard(RGWRados* _store); + RGWReshard(RGWRados* _store, bool _verbose = false, ostream *_out = nullptr, Formatter *_formatter = nullptr); int add(cls_rgw_reshard_entry& entry); int get(cls_rgw_reshard_entry& entry); int remove(cls_rgw_reshard_entry& entry);