]> git.apps.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)
committerShilpa Jagannath <smanjara@redhat.com>
Tue, 13 Feb 2024 16:02:51 +0000 (11:02 -0500)
fixes: https://tracker.ceph.com/issues/64365
Signed-off-by: Shilpa Jagannath <smanjara@redhat.com>
src/rgw/driver/rados/rgw_rados.cc
src/rgw/rgw_common.h
src/rgw/rgw_rest_s3.cc

index b802bb114bd7fcc443a715c7c023b902b7c0c2f8..714e7702b1a06dc9395a65eeab54f1ca914e7815 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"
@@ -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);
index ef9aa5420558285ac61fc0a1040728b6b3228d04..f4ab07f97de17d4653db811916d4786cb0f4d791 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 2117af94d70db1be8b6bbc73e8002976ca1ddc91..60cba8a17f2d72904e7651978627b7d4a1f8cf12 100644 (file)
@@ -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);
   }