]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: fetch_remote_obj() adds x-amz-replication-status=REPLICA 47743/head
authorCasey Bodley <cbodley@redhat.com>
Mon, 22 Aug 2022 20:39:46 +0000 (16:39 -0400)
committerCasey Bodley <cbodley@redhat.com>
Tue, 17 Jan 2023 16:43:26 +0000 (11:43 -0500)
implements the easy part of amazon's x-amz-replication-status feature:

https://docs.aws.amazon.com/AmazonS3/latest/userguide/replication-status.html#replication-status-overview

Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/rgw/rgw_common.h
src/rgw/rgw_rados.cc
src/rgw/rgw_rest_s3.cc

index 3a5f2cd8824ded45575c4e65dc25973ddcb1c983..6102f6b0dee47fb942c764b397fb7b77f42dd023 100644 (file)
@@ -136,6 +136,8 @@ 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"
+
 /* IAM Policy */
 #define RGW_ATTR_IAM_POLICY    RGW_ATTR_PREFIX "iam-policy"
 #define RGW_ATTR_USER_POLICY    RGW_ATTR_PREFIX "user-policy"
index c5e5d53a3df4766f8fcdea366b70d8a25afe533a..b8fd34161c116524f7d32cb1278138d31c6de3d3 100644 (file)
@@ -4058,6 +4058,12 @@ int RGWRados::fetch_remote_obj(RGWObjectCtx& obj_ctx,
   //erase the append attr
   cb.get_attrs().erase(RGW_ATTR_APPEND_PART_NUM);
 
+  { // add x-amz-replication-status=REPLICA
+    auto& bl = cb.get_attrs()[RGW_ATTR_OBJ_REPLICATION_STATUS];
+    bl.clear(); // overwrite source's status
+    bl.append("REPLICA");
+  }
+
   if (source_zone.empty()) {
     set_copy_attrs(cb.get_attrs(), attrs, attrs_mod);
   } else {
index 932ab0226b96f83e94fb99cea58f47869284f933..87aabcfb85d1402f5dccacb7c5203837b51b1815 100644 (file)
@@ -428,6 +428,11 @@ int RGWGetObj_ObjStore_S3::send_response_data(bufferlist& bl, off_t bl_ofs,
   } else {
     dump_header(s, "x-rgw-object-type", "Normal");
   }
+  // replication status
+  if (auto i = attrs.find(RGW_ATTR_OBJ_REPLICATION_STATUS);
+      i != attrs.end()) {
+    dump_header(s, "x-amz-replication-status", i->second);
+  }
 
   if (! op_ret) {
     if (! lo_etag.empty()) {