]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: fetch_remote_obj() adds x-rgw-replicated-from headers
authorCasey Bodley <cbodley@redhat.com>
Mon, 22 Aug 2022 20:48:27 +0000 (16:48 -0400)
committerMark Kogan <mkogan@redhat.com>
Sun, 18 Jun 2023 10:39:08 +0000 (10:39 +0000)
adds x-rgw-replicated-from headers for each zone in the object's
replication path. the RGW_ATTR_OBJ_REPLICATION_TRACE attribute is stored
as a vector instead of a set to preserve the replication order

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 9ec4fd7e4977b3b68b22a3f759e29c0ffc2b088b)

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

index 00bcc0ba5b02755790c560930b8c866bf32f0204..02ca98f2498ac64ec26160c5cc2b4596a51b59b7 100644 (file)
@@ -4102,6 +4102,21 @@ int RGWRados::fetch_remote_obj(RGWObjectCtx& obj_ctx,
     bl.clear(); // overwrite source's status
     bl.append("REPLICA");
   }
+  { // update replication trace
+    std::vector<rgw_zone_set_entry> trace;
+    if (auto i = cb.get_attrs().find(RGW_ATTR_OBJ_REPLICATION_TRACE);
+        i != cb.get_attrs().end()) {
+      try {
+        decode(trace, i->second);
+      } catch (const buffer::error&) {}
+    }
+    // add the source entry to the end
+    trace.push_back(source_trace_entry);
+
+    bufferlist bl;
+    encode(trace, bl);
+    cb.get_attrs()[RGW_ATTR_OBJ_REPLICATION_TRACE] = std::move(bl);
+  }
 
   if (source_zone.empty()) {
     set_copy_attrs(cb.get_attrs(), attrs, attrs_mod);
index f768a5e81cc6a9f0e211631042b3575306a8add5..d0bd47253a847480cbb642169e95ca8d26d3d920 100644 (file)
@@ -143,6 +143,7 @@ using ceph::crypto::MD5;
 #define RGW_ATTR_CLOUD_TIER_CONFIG    RGW_ATTR_PREFIX "cloud_tier_config"
 
 #define RGW_ATTR_OBJ_REPLICATION_STATUS RGW_ATTR_PREFIX "amz-replication-status"
+#define RGW_ATTR_OBJ_REPLICATION_TRACE RGW_ATTR_PREFIX "replication-trace"
 
 /* IAM Policy */
 #define RGW_ATTR_IAM_POLICY    RGW_ATTR_PREFIX "iam-policy"
index e57f42b2bf36b8c412a81ed740450c3c35a4b74a..eb68d004af5dd4451d4f33b08764ee94ec4758d7 100644 (file)
@@ -437,6 +437,17 @@ int RGWGetObj_ObjStore_S3::send_response_data(bufferlist& bl, off_t bl_ofs,
       i != attrs.end()) {
     dump_header(s, "x-amz-replication-status", i->second);
   }
+  if (auto i = attrs.find(RGW_ATTR_OBJ_REPLICATION_TRACE);
+      i != attrs.end()) {
+    try {
+      std::vector<rgw_zone_set_entry> zones;
+      auto p = i->second.cbegin();
+      decode(zones, p);
+      for (const auto& zone : zones) {
+        dump_header(s, "x-rgw-replicated-from", zone.to_str());
+      }
+    } catch (const buffer::error&) {} // omit x-rgw-replicated-from headers
+  }
 
   if (! op_ret) {
     if (! lo_etag.empty()) {