From 8fca9cdb4d95f54449a87cedddacf3167eba744d Mon Sep 17 00:00:00 2001 From: Shilpa Jagannath Date: Wed, 7 Feb 2024 17:56:40 -0500 Subject: [PATCH] rgw/multisite: add x-amx-replicated-at header to replicated objects fixes: https://tracker.ceph.com/issues/64365 Signed-off-by: Shilpa Jagannath --- src/rgw/driver/rados/rgw_rados.cc | 8 ++++++++ src/rgw/rgw_common.h | 1 + src/rgw/rgw_rest_s3.cc | 9 +++++++++ 3 files changed, 18 insertions(+) diff --git a/src/rgw/driver/rados/rgw_rados.cc b/src/rgw/driver/rados/rgw_rados.cc index b802bb114bd..714e7702b1a 100644 --- a/src/rgw/driver/rados/rgw_rados.cc +++ b/src/rgw/driver/rados/rgw_rados.cc @@ -21,6 +21,7 @@ #include "common/Formatter.h" #include "common/Throttle.h" #include "common/BackTrace.h" +#include "common/ceph_time.h" #include "rgw_sal.h" #include "rgw_zone.h" @@ -4412,6 +4413,13 @@ int RGWRados::fetch_remote_obj(RGWObjectCtx& obj_ctx, encode(trace, bl); cb.get_attrs()[RGW_ATTR_OBJ_REPLICATION_TRACE] = std::move(bl); } + { + // add x-amz-replicated-at + bufferlist bl; + ceph::real_time timestamp = real_clock::now(); + encode(timestamp, bl); + cb.get_attrs()[RGW_ATTR_OBJ_REPLICATION_TIMESTAMP] = std::move(bl); + } if (source_zone.empty()) { set_copy_attrs(cb.get_attrs(), attrs, attrs_mod); diff --git a/src/rgw/rgw_common.h b/src/rgw/rgw_common.h index ef9aa542055..f4ab07f97de 100644 --- a/src/rgw/rgw_common.h +++ b/src/rgw/rgw_common.h @@ -145,6 +145,7 @@ using ceph::crypto::MD5; #define RGW_ATTR_OBJ_REPLICATION_STATUS RGW_ATTR_PREFIX "amz-replication-status" #define RGW_ATTR_OBJ_REPLICATION_TRACE RGW_ATTR_PREFIX "replication-trace" +#define RGW_ATTR_OBJ_REPLICATION_TIMESTAMP RGW_ATTR_PREFIX "replicated-at" /* IAM Policy */ #define RGW_ATTR_IAM_POLICY RGW_ATTR_PREFIX "iam-policy" diff --git a/src/rgw/rgw_rest_s3.cc b/src/rgw/rgw_rest_s3.cc index 2117af94d70..60cba8a17f2 100644 --- a/src/rgw/rgw_rest_s3.cc +++ b/src/rgw/rgw_rest_s3.cc @@ -463,6 +463,15 @@ int RGWGetObj_ObjStore_S3::send_response_data(bufferlist& bl, off_t bl_ofs, } } catch (const buffer::error&) {} // omit x-rgw-replicated-from headers } + if (auto i = attrs.find(RGW_ATTR_OBJ_REPLICATION_TIMESTAMP); + i != attrs.end()) { + try { + ceph::real_time replicated_time; + decode(replicated_time, i->second); + dump_time(s, "x-rgw-replicated-at", replicated_time); + } catch (const buffer::error&) {} + } + if (multipart_parts_count) { dump_header(s, "x-amz-mp-parts-count", *multipart_parts_count); } -- 2.39.5