]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
radosgw-admin: reshard execute output adjustments
authorYehuda Sadeh <yehuda@redhat.com>
Wed, 24 May 2017 20:21:43 +0000 (13:21 -0700)
committerYehuda Sadeh <yehuda@redhat.com>
Mon, 5 Jun 2017 20:17:59 +0000 (13:17 -0700)
Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/rgw/rgw_admin.cc
src/rgw/rgw_reshard.cc
src/rgw/rgw_reshard.h

index 7f12c1f36be292c633ae8b61fa2a60df30c7e091..c3400bcc116c2130b58d2b59fef7b7065f706cac 100644 (file)
@@ -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) {
index 7bc885dcdcdc6914af6f4b023a3c25537b2c5790..da43cef42d0fbb9182cf1476597c5a082301a8fc 100644 (file)
@@ -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;
       }
index 2010ac4a478ceb9a7572bfd800c8c14f6bb7bcac..4237d2dc4fc3f3d2c71b094d54da9b6a994297ac 100644 (file)
@@ -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);