From: Tom Coldrick Date: Wed, 16 Nov 2022 07:51:41 +0000 (-0500) Subject: rgw: Add log types to dencoder X-Git-Tag: v19.0.0~1131^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=7b2a0504d4e9ac67f7de268a94d9b486885db076;p=ceph.git rgw: Add log types to dencoder 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 --- diff --git a/src/cls/log/cls_log_types.h b/src/cls/log/cls_log_types.h index 1746d243e5a1..33b8cce51e5e 100644 --- a/src/cls/log/cls_log_types.h +++ b/src/cls/log/cls_log_types.h @@ -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& 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) diff --git a/src/rgw/driver/rados/rgw_datalog.cc b/src/rgw/driver/rados/rgw_datalog.cc index 7ca37abf6848..c7c3233cf672 100644 --- a/src/rgw/driver/rados/rgw_datalog.cc +++ b/src/rgw/driver/rados/rgw_datalog.cc @@ -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& 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); diff --git a/src/rgw/driver/rados/rgw_datalog.h b/src/rgw/driver/rados/rgw_datalog.h index 174cf86ded13..58042df2c62e 100644 --- a/src/rgw/driver/rados/rgw_datalog.h +++ b/src/rgw/driver/rados/rgw_datalog.h @@ -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& l); }; WRITE_CLASS_ENCODER(rgw_data_change) diff --git a/src/rgw/rgw_mdlog.h b/src/rgw/rgw_mdlog.h index 179cc2aca440..6a6fb67d17a4 100644 --- a/src/rgw/rgw_mdlog.h +++ b/src/rgw/rgw_mdlog.h @@ -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& l); }; WRITE_CLASS_ENCODER(RGWMetadataLogData) diff --git a/src/rgw/rgw_metadata.cc b/src/rgw/rgw_metadata.cc index 7fd25ae75879..a6d75de0eba1 100644 --- a/src/rgw/rgw_metadata.cc +++ b/src/rgw/rgw_metadata.cc @@ -101,6 +101,16 @@ void RGWMetadataLogData::decode_json(JSONObj *obj) { JSONDecoder::decode_json("status", status, obj); } +void RGWMetadataLogData::generate_test_instances(std::list& 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, diff --git a/src/tools/ceph-dencoder/rgw_types.h b/src/tools/ceph-dencoder/rgw_types.h index dd5c3a8cb7f1..7a5f544eca2d 100644 --- a/src/tools/ceph-dencoder/rgw_types.h +++ b/src/tools/ceph-dencoder/rgw_types.h @@ -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)