]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: when resharding store progress json
authorMark Kogan <mkogan@redhat.com>
Wed, 25 Sep 2019 12:22:20 +0000 (15:22 +0300)
committerNathan Cutler <ncutler@suse.com>
Fri, 15 Nov 2019 21:27:19 +0000 (22:27 +0100)
only when both verbose and out are specified.

Fixes: https://tracker.ceph.com/issues/42051
Signed-off-by: Mark Kogan <mkogan@redhat.com>
(cherry picked from commit 4221452e90e01d5f27cf3ccf92d0b3a359218c30)

src/rgw/rgw_reshard.cc

index 12ba93bd9d86e285de07aed5fb6b91239e0bf2b6..fffa34797746368ed008ac7b890271417493b762 100644 (file)
@@ -527,16 +527,16 @@ int RGWBucketReshard::do_reshard(int num_shards,
 
   BucketReshardManager target_shards_mgr(store, new_bucket_info, num_target_shards);
 
-  verbose = verbose && (formatter != nullptr);
+  bool verbose_json_out = verbose && (formatter != nullptr) && (out != nullptr);
 
-  if (verbose) {
+  if (verbose_json_out) {
     formatter->open_array_section("entries");
   }
 
   uint64_t total_entries = 0;
 
-  if (!verbose) {
-    cout << "total entries:";
+  if (!verbose_json_out && out) {
+    (*out) << "total entries:";
   }
 
   const int num_source_shards =
@@ -555,7 +555,7 @@ int RGWBucketReshard::do_reshard(int num_shards,
 
       for (auto iter = entries.begin(); iter != entries.end(); ++iter) {
        rgw_cls_bi_entry& entry = *iter;
-       if (verbose) {
+       if (verbose_json_out) {
          formatter->open_object_section("entry");
 
          encode_json("shard_id", i, formatter);
@@ -604,11 +604,9 @@ int RGWBucketReshard::do_reshard(int num_shards,
          }
        }
 
-       if (verbose) {
+       if (verbose_json_out) {
          formatter->close_section();
-         if (out) {
-           formatter->flush(*out);
-         }
+         formatter->flush(*out);
        } else if (out && !(total_entries % 1000)) {
          (*out) << " " << total_entries;
        }
@@ -616,11 +614,9 @@ int RGWBucketReshard::do_reshard(int num_shards,
     }
   }
 
-  if (verbose) {
+  if (verbose_json_out) {
     formatter->close_section();
-    if (out) {
-      formatter->flush(*out);
-    }
+    formatter->flush(*out);
   } else if (out) {
     (*out) << " " << total_entries << std::endl;
   }