]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: add logging to radosgw-admin bi list 49463/head
authorJ. Eric Ivancich <ivancich@redhat.com>
Wed, 14 Dec 2022 23:37:22 +0000 (18:37 -0500)
committerJ. Eric Ivancich <ivancich@redhat.com>
Thu, 15 Dec 2022 18:50:59 +0000 (13:50 -0500)
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 <ivancich@redhat.com>
src/rgw/rgw_admin.cc
src/rgw/rgw_bucket_layout.h

index f18ce8cfbfb78f9b4b25f3c04dcd8d77e9c9a729..74eb168029dcca8dce834a7d2a20d3dfaa0330e7 100644 (file)
@@ -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<rgw::sal::RadosStore*>(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<rgw_cls_bi_entry> entries;
+    std::list<rgw_cls_bi_entry> 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<rgw::sal::RadosStore*>(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<rgw_cls_bi_entry>::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);
   }
index 80607e70aed414290ef4184e41da6b511989bb1b..c974852cbae92ce826c927ea8f84a97f72cc5820 100644 (file)
@@ -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<bucket_log_layout_generation> 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);