diff --git a/doc/radosgw/dynamicresharding.rst b/doc/radosgw/dynamicresharding.rst index 03eb1fdcc7591..6cad736e7f00c 100644 --- a/doc/radosgw/dynamicresharding.rst +++ b/doc/radosgw/dynamicresharding.rst @@ -83,6 +83,54 @@ Bucket resharding status # radosgw-admin reshard status --bucket +The output is a json array of 3 objects (reshard_status, new_bucket_instance_id, num_shards) per shard. + +For example, the output at different Dynamic Resharding stages is shown below: + +``1. Before resharding occurred:`` +:: + + [ + { + "reshard_status": "not-resharding", + "new_bucket_instance_id": "", + "num_shards": -1 + } + ] + +``2. During resharding:`` +:: + + [ + { + "reshard_status": "in-progress", + "new_bucket_instance_id": "1179f470-2ebf-4630-8ec3-c9922da887fd.8652.1", + "num_shards": 2 + }, + { + "reshard_status": "in-progress", + "new_bucket_instance_id": "1179f470-2ebf-4630-8ec3-c9922da887fd.8652.1", + "num_shards": 2 + } + ] + +``3, After resharding completed:`` +:: + + [ + { + "reshard_status": "not-resharding", + "new_bucket_instance_id": "", + "num_shards": -1 + }, + { + "reshard_status": "not-resharding", + "new_bucket_instance_id": "", + "num_shards": -1 + } + ] + + Cancel pending bucket resharding -------------------------------- diff --git a/src/cls/rgw/cls_rgw_types.cc b/src/cls/rgw/cls_rgw_types.cc index c948632bc31ef..f64a624ce2824 100644 --- a/src/cls/rgw/cls_rgw_types.cc +++ b/src/cls/rgw/cls_rgw_types.cc @@ -668,21 +668,7 @@ void cls_rgw_reshard_entry::generate_test_instances(list void cls_rgw_bucket_instance_entry::dump(Formatter *f) const { - string status_str; - switch(reshard_status) { - case CLS_RGW_RESHARD_NONE: - status_str= "none"; - break; - case CLS_RGW_RESHARD_IN_PROGRESS: - status_str = "in-progress"; - break; - case CLS_RGW_RESHARD_DONE: - status_str = "done"; - break; - default: - status_str = "invalid"; - } - encode_json("reshard_status", status_str, f); + encode_json("reshard_status", to_string(reshard_status), f); encode_json("new_bucket_instance_id", new_bucket_instance_id, f); encode_json("num_shards", num_shards, f); diff --git a/src/cls/rgw/cls_rgw_types.h b/src/cls/rgw/cls_rgw_types.h index c50df73b7d0a1..74292482f12ac 100644 --- a/src/cls/rgw/cls_rgw_types.h +++ b/src/cls/rgw/cls_rgw_types.h @@ -610,22 +610,22 @@ struct rgw_bucket_category_stats { WRITE_CLASS_ENCODER(rgw_bucket_category_stats) enum cls_rgw_reshard_status { - CLS_RGW_RESHARD_NONE = 0, - CLS_RGW_RESHARD_IN_PROGRESS = 1, - CLS_RGW_RESHARD_DONE = 2, + CLS_RGW_RESHARD_NOT_RESHARDING = 0, + CLS_RGW_RESHARD_IN_PROGRESS = 1, + CLS_RGW_RESHARD_DONE = 2, }; static inline std::string to_string(const enum cls_rgw_reshard_status status) { switch (status) { - case CLS_RGW_RESHARD_NONE: - return "CLS_RGW_RESHARD_NONE"; + case CLS_RGW_RESHARD_NOT_RESHARDING: + return "not-resharding"; break; case CLS_RGW_RESHARD_IN_PROGRESS: - return "CLS_RGW_RESHARD_IN_PROGRESS"; + return "in-progress"; break; case CLS_RGW_RESHARD_DONE: - return "CLS_RGW_RESHARD_DONE"; + return "done"; break; default: break; @@ -634,7 +634,7 @@ static inline std::string to_string(const enum cls_rgw_reshard_status status) } struct cls_rgw_bucket_instance_entry { - cls_rgw_reshard_status reshard_status{CLS_RGW_RESHARD_NONE}; + cls_rgw_reshard_status reshard_status{CLS_RGW_RESHARD_NOT_RESHARDING}; string new_bucket_instance_id; int32_t num_shards{-1}; @@ -660,7 +660,7 @@ struct cls_rgw_bucket_instance_entry { static void generate_test_instances(list& o); void clear() { - reshard_status = CLS_RGW_RESHARD_NONE; + reshard_status = CLS_RGW_RESHARD_NOT_RESHARDING; new_bucket_instance_id.clear(); } @@ -671,7 +671,7 @@ struct cls_rgw_bucket_instance_entry { } bool resharding() const { - return reshard_status != CLS_RGW_RESHARD_NONE; + return reshard_status != CLS_RGW_RESHARD_NOT_RESHARDING; } bool resharding_in_progress() const { return reshard_status == CLS_RGW_RESHARD_IN_PROGRESS; diff --git a/src/rgw/rgw_reshard.cc b/src/rgw/rgw_reshard.cc index 4d73b18414c86..c01e391bf8554 100644 --- a/src/rgw/rgw_reshard.cc +++ b/src/rgw/rgw_reshard.cc @@ -270,7 +270,7 @@ int RGWBucketReshard::clear_index_shard_reshard_status(RGWRados* store, int ret = set_resharding_status(store, bucket_info, bucket_info.bucket.bucket_id, (num_shards < 1 ? 1 : num_shards), - CLS_RGW_RESHARD_NONE); + CLS_RGW_RESHARD_NOT_RESHARDING); if (ret < 0) { ldout(store->ctx(), 0) << "RGWBucketReshard::" << __func__ << " ERROR: error clearing reshard status from index shard " << @@ -374,7 +374,7 @@ class BucketInfoReshardUpdate " clear_index_shard_status returned " << ret << dendl; } bucket_info.new_bucket_instance_id.clear(); - set_status(CLS_RGW_RESHARD_NONE); // clears new_bucket_instance as well + set_status(CLS_RGW_RESHARD_NOT_RESHARDING); // clears new_bucket_instance as well } }