From: Jiffin Tony Thottan Date: Thu, 2 Jan 2025 07:28:13 +0000 (+0530) Subject: rgw/rgw_admin.cc : Make restore attrs readable in admin cli X-Git-Tag: v20.0.0~252^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ff04e0af19297cae92f6dc85e0bbfedb03350381;p=ceph.git rgw/rgw_admin.cc : Make restore attrs readable in admin cli The restore attrs directly stored at the backend which make it difficult to understand via `radosgw-admin object stat` cli. Make it more human readable form. Signed-off-by: Jiffin Tony Thottan --- diff --git a/src/rgw/radosgw-admin/radosgw-admin.cc b/src/rgw/radosgw-admin/radosgw-admin.cc index 182e42b8e31f..29804fc5b87f 100644 --- a/src/rgw/radosgw-admin/radosgw-admin.cc +++ b/src/rgw/radosgw-admin/radosgw-admin.cc @@ -8822,9 +8822,19 @@ next: } else if (iter->first == RGW_ATTR_SOURCE_ZONE) { handled = decode_dump("source_zone", bl, formatter.get()); } else if (iter->first == RGW_ATTR_RESTORE_EXPIRY_DATE) { - handled = decode_dump("restore_expiry_date", bl, formatter.get()); + handled = decode_dump("restore_expiry_date", bl, formatter.get()); } else if (iter->first == RGW_ATTR_RESTORE_TIME) { - handled = decode_dump("restore_time", bl, formatter.get()); + handled = decode_dump("restore_time", bl, formatter.get()); + } else if (iter->first == RGW_ATTR_RESTORE_TYPE) { + rgw::sal::RGWRestoreType rt; + decode(rt, bl); + formatter->dump_string("RestoreType", rgw::sal::rgw_restore_type_dump(rt)); + handled = true; + } else if (iter->first == RGW_ATTR_RESTORE_STATUS) { + rgw::sal::RGWRestoreStatus rs; + decode(rs, bl); + formatter->dump_string("RestoreStatus", rgw::sal::rgw_restore_status_dump(rs)); + handled = true; } if (!handled) @@ -8840,6 +8850,8 @@ next: bufferlist& bl = iter->second; if (iter->first == RGW_ATTR_OBJ_REPLICATION_TIMESTAMP) { decode_dump("user.rgw.replicated-at", bl, formatter.get()); + } else if (iter->first == RGW_ATTR_RESTORE_TIME) { + decode_dump("user.rgw.restore-at", bl, formatter.get()); } else { dump_string(iter->first.c_str(), iter->second, formatter.get()); } diff --git a/src/rgw/rgw_sal.cc b/src/rgw/rgw_sal.cc index b02ad3657e9a..e2a6c78b4f43 100644 --- a/src/rgw/rgw_sal.cc +++ b/src/rgw/rgw_sal.cc @@ -415,4 +415,38 @@ int Object::range_to_ofs(uint64_t obj_size, int64_t &ofs, int64_t &end) } return 0; } -} // namespace rgw::sal + + +std::string_view rgw_restore_status_dump(rgw::sal::RGWRestoreStatus status) +{ + switch (status) + { + case RGWRestoreStatus::None: + return "None"; + case RGWRestoreStatus::RestoreAlreadyInProgress: + return "RestoreAlreadyInProgress"; + case RGWRestoreStatus::CloudRestored: + return "CloudRestored"; + case RGWRestoreStatus::RestoreFailed: + return "RestoreFailed"; + default: + return ""; + } +} + +std::string_view rgw_restore_type_dump(rgw::sal::RGWRestoreType type) +{ + switch (type) + { + case RGWRestoreType::None: + return "None"; + case RGWRestoreType::Temporary: + return "Temporary"; + case RGWRestoreType::Permanent: + return "Permanent"; + default: + return ""; + } +} + +} // namespace rgw::sal \ No newline at end of file diff --git a/src/rgw/rgw_sal.h b/src/rgw/rgw_sal.h index e098c4decf71..afe45b53a33d 100644 --- a/src/rgw/rgw_sal.h +++ b/src/rgw/rgw_sal.h @@ -160,6 +160,7 @@ enum RGWRestoreStatus : uint8_t { RestoreFailed = 3 }; +std::string_view rgw_restore_status_dump(rgw::sal::RGWRestoreStatus status); enum class RGWRestoreType : uint8_t { None = 0, @@ -167,6 +168,7 @@ enum class RGWRestoreType : uint8_t { Permanent = 2 }; +std::string_view rgw_restore_type_dump(rgw::sal::RGWRestoreType type); // a simple streaming data processing abstraction /**