Skip to content

Commit

Permalink
Merge pull request #55503 from smanjara/wip-x-amz-replicated-at
Browse files Browse the repository at this point in the history
rgw/multisite: add x-rgw-replicated-at header to replicated objects

Reviewed-by: Casey Bodley <cbodley@redhat.com>
  • Loading branch information
cbodley committed Mar 15, 2024
2 parents 333aae9 + 626179f commit 694f19b
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 1 deletion.
3 changes: 3 additions & 0 deletions PendingReleaseNotes
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
>=19.0.0

* RGW: GetObject and HeadObject requests now return a x-rgw-replicated-at
header for replicated objects. This timestamp can be compared against the
Last-Modified header to determine how long the object took to replicate.
* The cephfs-shell utility is now packaged for RHEL 9 / CentOS 9 as required
python dependencies are now available in EPEL9.
* RGW: S3 multipart uploads using Server-Side Encryption now replicate correctly in
Expand Down
8 changes: 8 additions & 0 deletions src/rgw/driver/rados/rgw_rados.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -4416,6 +4417,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);
Expand Down
7 changes: 6 additions & 1 deletion src/rgw/rgw_admin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8378,7 +8378,12 @@ int main(int argc, const char **argv)

formatter->open_object_section("attrs");
for (iter = other_attrs.begin(); iter != other_attrs.end(); ++iter) {
dump_string(iter->first.c_str(), iter->second, formatter.get());
bufferlist& bl = iter->second;
if (iter->first == RGW_ATTR_OBJ_REPLICATION_TIMESTAMP) {
decode_dump<ceph::real_time>("user.rgw.replicated-at", bl, formatter.get());
} else {
dump_string(iter->first.c_str(), iter->second, formatter.get());
}
}
formatter->close_section();
formatter->close_section();
Expand Down
1 change: 1 addition & 0 deletions src/rgw/rgw_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
9 changes: 9 additions & 0 deletions src/rgw/rgw_rest_s3.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 694f19b

Please sign in to comment.