From: J. Eric Ivancich Date: Wed, 14 Dec 2022 23:37:22 +0000 (-0500) Subject: rgw: add logging to radosgw-admin bi list X-Git-Tag: v18.1.0~511^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=256f91c61dc0a2e67368dd9cb5384547b8f65214;p=ceph.git rgw: add logging to radosgw-admin bi list On a nautilus version we ran into an issue where bi list was not listing out all entries and also not reporting any errors. Even after turning up logging it was impossible to follow the code paths. This adds level 20 logging in order to follow the code paths even if no error is generated, so we can better handle such situations in the future. Signed-off-by: J. Eric Ivancich --- diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index f18ce8cfbfb7..74eb168029dc 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -7121,6 +7121,10 @@ int main(int argc, const char **argv) cerr << "ERROR: driver->list_objects(): " << cpp_strerror(-ret) << std::endl; return -ret; } + ldpp_dout(dpp(), 20) << "INFO: " << __func__ << + ": list() returned without error; results.objs.sizie()=" << + results.objs.size() << "results.is_truncated=" << results.is_truncated << ", marker=" << + params.marker << dendl; count += results.objs.size(); @@ -7129,6 +7133,7 @@ int main(int argc, const char **argv) } formatter->flush(cout); } while (results.is_truncated && count < max_entries); + ldpp_dout(dpp(), 20) << "INFO: " << __func__ << ": done" << dendl; formatter->close_section(); formatter->flush(cout); @@ -7640,7 +7645,6 @@ next: } rgw_cls_bi_entry entry; - ret = static_cast(driver)->getRados()->bi_get(dpp(), bucket->get_info(), obj, bi_index_type, &entry); if (ret < 0) { cerr << "ERROR: bi_get(): " << cpp_strerror(-ret) << std::endl; @@ -7683,25 +7687,30 @@ next: cerr << "ERROR: bucket name not specified" << std::endl; return EINVAL; } + int ret = init_bucket(user.get(), tenant, bucket_name, bucket_id, &bucket); if (ret < 0) { cerr << "ERROR: could not init bucket: " << cpp_strerror(-ret) << std::endl; return -ret; } - list entries; + std::list entries; bool is_truncated; + const auto& index = bucket->get_info().layout.current_index; + const int max_shards = rgw::num_shards(index); if (max_entries < 0) { max_entries = 1000; } - const auto& index = bucket->get_info().layout.current_index; - const int max_shards = rgw::num_shards(index); + ldpp_dout(dpp(), 20) << "INFO: " << __func__ << ": max_entries=" << max_entries << + ", index=" << index << ", max_shards=" << max_shards << dendl; formatter->open_array_section("entries"); int i = (specified_shard_id ? shard_id : 0); for (; i < max_shards; i++) { + ldpp_dout(dpp(), 20) << "INFO: " << __func__ << ": starting shard=" << i << dendl; + RGWRados::BucketShard bs(static_cast(driver)->getRados()); int ret = bs.init(dpp(), bucket->get_info(), index, i); marker.clear(); @@ -7719,20 +7728,26 @@ next: cerr << "ERROR: bi_list(): " << cpp_strerror(-ret) << std::endl; return -ret; } + ldpp_dout(dpp(), 20) << "INFO: " << __func__ << + ": bi_list() returned without error; entries.size()=" << + entries.size() << ", is_truncated=" << is_truncated << + ", marker=" << marker << dendl; - list::iterator iter; - for (iter = entries.begin(); iter != entries.end(); ++iter) { - rgw_cls_bi_entry& entry = *iter; + for (const auto& entry : entries) { encode_json("entry", entry, formatter.get()); marker = entry.idx; } formatter->flush(cout); } while (is_truncated); + formatter->flush(cout); - if (specified_shard_id) + if (specified_shard_id) { break; + } } + ldpp_dout(dpp(), 20) << "INFO: " << __func__ << ": done" << dendl; + formatter->close_section(); formatter->flush(cout); } diff --git a/src/rgw/rgw_bucket_layout.h b/src/rgw/rgw_bucket_layout.h index 80607e70aed4..c974852cbae9 100644 --- a/src/rgw/rgw_bucket_layout.h +++ b/src/rgw/rgw_bucket_layout.h @@ -55,8 +55,12 @@ struct bucket_index_normal_layout { uint32_t num_shards = 1; BucketHashType hash_type = BucketHashType::Mod; -}; + friend std::ostream& operator<<(std::ostream& out, const bucket_index_normal_layout& l) { + out << "num_shards=" << l.num_shards << ", hash_type=" << to_string(l.hash_type); + return out; + } +}; inline bool operator==(const bucket_index_normal_layout& l, const bucket_index_normal_layout& r) { @@ -78,6 +82,11 @@ struct bucket_index_layout { // TODO: variant of layout types? bucket_index_normal_layout normal; + + friend std::ostream& operator<<(std::ostream& out, const bucket_index_layout& l) { + out << "type=" << to_string(l.type) << ", normal=" << l.normal; + return out; + } }; inline bool operator==(const bucket_index_layout& l, @@ -97,6 +106,11 @@ void decode_json_obj(bucket_index_layout& l, JSONObj *obj); struct bucket_index_layout_generation { uint64_t gen = 0; bucket_index_layout layout; + + friend std::ostream& operator<<(std::ostream& out, const bucket_index_layout_generation& g) { + out << "gen=" << g.gen; + return out; + } }; inline bool operator==(const bucket_index_layout_generation& l, @@ -155,6 +169,11 @@ struct bucket_log_layout { BucketLogType type = BucketLogType::InIndex; bucket_index_log_layout in_index; + + friend std::ostream& operator<<(std::ostream& out, const bucket_log_layout& l) { + out << "type=" << to_string(l.type); + return out; + } }; void encode(const bucket_log_layout& l, bufferlist& bl, uint64_t f=0); @@ -165,6 +184,11 @@ void decode_json_obj(bucket_log_layout& l, JSONObj *obj); struct bucket_log_layout_generation { uint64_t gen = 0; bucket_log_layout layout; + + friend std::ostream& operator<<(std::ostream& out, const bucket_log_layout_generation& g) { + out << "gen=" << g.gen << ", layout=[ " << g.layout << " ]"; + return out; + } }; void encode(const bucket_log_layout_generation& l, bufferlist& bl, uint64_t f=0); @@ -215,6 +239,20 @@ struct BucketLayout { // history of untrimmed bucket log layout generations, with the current // generation at the back() std::vector logs; + + friend std::ostream& operator<<(std::ostream& out, const BucketLayout& l) { + std::stringstream ss; + if (l.target_index) { + ss << *l.target_index; + } else { + ss << "none"; + } + out << "resharding=" << to_string(l.resharding) << + ", current_index=[" << l.current_index << "], target_index=[" << + ss.str() << "], logs.size()=" << l.logs.size(); + + return out; + } }; void encode(const BucketLayout& l, bufferlist& bl, uint64_t f=0);