]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: fetch_remote_obj() adds x-rgw-replicated-from headers 49767/head
authorCasey Bodley <cbodley@redhat.com>
Mon, 22 Aug 2022 20:48:27 +0000 (16:48 -0400)
committerCasey Bodley <cbodley@redhat.com>
Tue, 2 May 2023 21:07:32 +0000 (17:07 -0400)
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>
src/rgw/driver/rados/rgw_rados.cc
src/rgw/rgw_common.h
src/rgw/rgw_rest_s3.cc

index b9ad7d6fbcb14a2b80b58bb7b2f7af32593df113..797d3def5608ecca22a645a8111a1bcdecffbb76 100644 (file)
@@ -4110,6 +4110,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 5dd26e20c174f8dd20b57dbc806ce70a16e3eed7..1b3c95d487ac1b036c197cd144e83c60886c5933 100644 (file)
@@ -138,6 +138,7 @@ using ceph::crypto::MD5;
 #define RGW_ATTR_APPEND_PART_NUM    RGW_ATTR_PREFIX "append_part_num"
 
 #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 54da6d09ca0b515d9ed23df8c978dd476a89083d..588a6660398511eb4f929c7be929b68ecf86c52b 100644 (file)
@@ -436,6 +436,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()) {