]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: Add log types to dencoder 51280/head
authorTom Coldrick <tcoldrick@bloomberg.com>
Wed, 16 Nov 2022 07:51:41 +0000 (02:51 -0500)
committerTom Coldrick <tcoldrick@bloomberg.com>
Wed, 17 May 2023 09:33:27 +0000 (10:33 +0100)
When debugging an issue in RGW multisite replication, we discovered that we had
no way to deserialise data stored in the logs (in particular the datalog) when
attempting to look inside the RADOS objects and work out what's going on. This
commit adds the types to ceph-dencoder, to facilitate future efforts at
debugging. As a bonus, this also allows serialisation for these types to be
tested.

Adds the following types to ceph-dencoder:

- RGWMetadataLogData
- rgw_data_change
- cls_log_entry

Signed-off-by: Tom Coldrick <tcoldrick@bloomberg.com>
src/cls/log/cls_log_types.h
src/rgw/driver/rados/rgw_datalog.cc
src/rgw/driver/rados/rgw_datalog.h
src/rgw/rgw_mdlog.h
src/rgw/rgw_metadata.cc
src/tools/ceph-dencoder/rgw_types.h

index 1746d243e5a14592a06fb92112f85b452aa7cb7d..33b8cce51e5e8c792f4c9253bc2349fb5ec2f59b 100644 (file)
@@ -8,7 +8,11 @@
 
 #include "include/utime.h"
 
+#include "common/ceph_json.h"
+#include "common/Formatter.h"
+
 class JSONObj;
+class JSONDecoder;
 
 
 struct cls_log_entry {
@@ -40,6 +44,34 @@ struct cls_log_entry {
       decode(id, bl);
     DECODE_FINISH(bl);
   }
+
+  void dump(ceph::Formatter* f) const {
+    encode_json("section", section, f);
+    encode_json("name", name, f);
+    encode_json("timestamp", timestamp, f);
+    encode_json("data", data, f);
+    encode_json("id", id, f);
+  }
+
+  void decode_json(JSONObj* obj) {
+    JSONDecoder::decode_json("section", section, obj);
+    JSONDecoder::decode_json("name", name, obj);
+    JSONDecoder::decode_json("timestamp", timestamp, obj);
+    JSONDecoder::decode_json("data", data, obj);
+    JSONDecoder::decode_json("id", id, obj);
+  }
+
+  static void generate_test_instances(std::list<cls_log_entry *>& l) {
+    l.push_back(new cls_log_entry{});
+    l.push_back(new cls_log_entry);
+    l.back()->id = "test_id";
+    l.back()->section = "test_section";
+    l.back()->name = "test_name";
+    l.back()->timestamp = utime_t();
+    ceph::buffer::list bl;
+    ceph::encode(std::string("Test"), bl, 0);
+    l.back()->data = bl;
+  }
 };
 WRITE_CLASS_ENCODER(cls_log_entry)
 
index 7ca37abf684846318b8920a671c1f6a535b86db6..c7c3233cf672a9714b7b5390fc7e13393d27d350 100644 (file)
@@ -61,6 +61,15 @@ void rgw_data_change::decode_json(JSONObj *obj) {
   JSONDecoder::decode_json("gen", gen, obj);
 }
 
+void rgw_data_change::generate_test_instances(std::list<rgw_data_change *>& l) {
+  l.push_back(new rgw_data_change{});
+  l.push_back(new rgw_data_change);
+  l.back()->entity_type = ENTITY_TYPE_BUCKET;
+  l.back()->key = "bucket_name";
+  l.back()->timestamp = ceph::real_clock::zero();
+  l.back()->gen = 0;
+}
+
 void rgw_data_change_log_entry::dump(Formatter *f) const
 {
   encode_json("log_id", log_id, f);
index 174cf86ded13b15f2109222081a96110dcc75fce..58042df2c62e9261013c9d1469711c22c96ce318 100644 (file)
@@ -82,6 +82,7 @@ struct rgw_data_change {
 
   void dump(ceph::Formatter* f) const;
   void decode_json(JSONObj* obj);
+  static void generate_test_instances(std::list<rgw_data_change *>& l);
 };
 WRITE_CLASS_ENCODER(rgw_data_change)
 
index 179cc2aca440c7829c29c5f032bcb4d5a2def4c3..6a6fb67d17a4e444599384d8167f76281cfa9634 100644 (file)
@@ -159,6 +159,7 @@ struct RGWMetadataLogData {
   void decode(bufferlist::const_iterator& bl);
   void dump(Formatter *f) const;
   void decode_json(JSONObj *obj);
+  static void generate_test_instances(std::list<RGWMetadataLogData *>& l);
 };
 WRITE_CLASS_ENCODER(RGWMetadataLogData)
 
index 7fd25ae75879061afd0bff860e23706d532bb1f2..a6d75de0eba12ecffc9d12009f4400443e6482a0 100644 (file)
@@ -101,6 +101,16 @@ void RGWMetadataLogData::decode_json(JSONObj *obj) {
   JSONDecoder::decode_json("status", status, obj);
 }
 
+void RGWMetadataLogData::generate_test_instances(std::list<RGWMetadataLogData *>& l) {
+  l.push_back(new RGWMetadataLogData{});
+  l.push_back(new RGWMetadataLogData);
+  l.back()->read_version = obj_version();
+  l.back()->read_version.tag = "read_tag";
+  l.back()->write_version = obj_version();
+  l.back()->write_version.tag = "write_tag";
+  l.back()->status = MDLOG_STATUS_WRITE;
+}
+
 RGWMetadataHandler_GenericMetaBE::Put::Put(RGWMetadataHandler_GenericMetaBE *_handler,
                                           RGWSI_MetaBackend_Handler::Op *_op,
                                           string& _entry, RGWMetadataObject *_obj,
index dd5c3a8cb7f18180bfbe1f2f0034055fd96a7d2a..7a5f544eca2dfc9dcc56fc4cd913e1b0e7b3b860 100644 (file)
@@ -30,6 +30,9 @@ TYPE(RGWCacheNotifyInfo)
 #include "rgw_lc.h"
 TYPE(RGWLifecycleConfiguration)
 
+#include "cls/log/cls_log_types.h"
+TYPE(cls_log_entry)
+
 #include "cls/rgw/cls_rgw_types.h"
 TYPE(rgw_bucket_pending_info)
 TYPE(rgw_bucket_dir_entry_meta)
@@ -122,6 +125,12 @@ TYPE(rgw_obj)
 #include "rgw_log.h"
 TYPE(rgw_log_entry)
 
+#include "rgw_datalog.h"
+TYPE(rgw_data_change)
+
+#include "rgw_mdlog.h"
+TYPE(RGWMetadataLogData)
+
 #include "rgw_meta_sync_status.h"
 TYPE(rgw_meta_sync_info)
 TYPE(rgw_meta_sync_marker)