]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/multisite: add x-amx-replicated-at header to replicated objects
authorShilpa Jagannath <smanjara@redhat.com>
Wed, 7 Feb 2024 22:56:40 +0000 (17:56 -0500)
committerCasey Bodley <cbodley@redhat.com>
Fri, 15 Mar 2024 15:21:53 +0000 (11:21 -0400)
fixes: https://tracker.ceph.com/issues/64365
Signed-off-by: Shilpa Jagannath <smanjara@redhat.com>
(cherry picked from commit 8fca9cdb4d95f54449a87cedddacf3167eba744d)

src/rgw/driver/rados/rgw_rados.cc
src/rgw/rgw_common.h
src/rgw/rgw_rest_s3.cc

index 8837dd56b920c45996ce9775f594a42f2937ab3e..f9247a1e22a086be52a11651b93a526f4e745c84 100644 (file)
@@ -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"
@@ -4413,6 +4414,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);
index e76e552a938521b04560bc18242707a1281270d5..390196a50e9320de079401e710cc357bdc76d6ab 100644 (file)
@@ -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"
index 1b964742a6854b0804b913da1251f98add25b845..f3985d54d024a4b12dc4bee8752dd34a5f1af01b 100644 (file)
@@ -464,6 +464,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);
   }