Skip to content

Commit 694f19b

Browse files
authored
Merge pull request ceph#55503 from smanjara/wip-x-amz-replicated-at
rgw/multisite: add x-rgw-replicated-at header to replicated objects Reviewed-by: Casey Bodley <[email protected]>
2 parents 333aae9 + 626179f commit 694f19b

File tree

5 files changed

+27
-1
lines changed

5 files changed

+27
-1
lines changed

PendingReleaseNotes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
>=19.0.0
22

3+
* RGW: GetObject and HeadObject requests now return a x-rgw-replicated-at
4+
header for replicated objects. This timestamp can be compared against the
5+
Last-Modified header to determine how long the object took to replicate.
36
* The cephfs-shell utility is now packaged for RHEL 9 / CentOS 9 as required
47
python dependencies are now available in EPEL9.
58
* RGW: S3 multipart uploads using Server-Side Encryption now replicate correctly in

src/rgw/driver/rados/rgw_rados.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "common/Formatter.h"
2222
#include "common/Throttle.h"
2323
#include "common/BackTrace.h"
24+
#include "common/ceph_time.h"
2425

2526
#include "rgw_sal.h"
2627
#include "rgw_zone.h"
@@ -4416,6 +4417,13 @@ int RGWRados::fetch_remote_obj(RGWObjectCtx& obj_ctx,
44164417
encode(trace, bl);
44174418
cb.get_attrs()[RGW_ATTR_OBJ_REPLICATION_TRACE] = std::move(bl);
44184419
}
4420+
{
4421+
// add x-amz-replicated-at
4422+
bufferlist bl;
4423+
ceph::real_time timestamp = real_clock::now();
4424+
encode(timestamp, bl);
4425+
cb.get_attrs()[RGW_ATTR_OBJ_REPLICATION_TIMESTAMP] = std::move(bl);
4426+
}
44194427

44204428
if (source_zone.empty()) {
44214429
set_copy_attrs(cb.get_attrs(), attrs, attrs_mod);

src/rgw/rgw_admin.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8378,7 +8378,12 @@ int main(int argc, const char **argv)
83788378

83798379
formatter->open_object_section("attrs");
83808380
for (iter = other_attrs.begin(); iter != other_attrs.end(); ++iter) {
8381-
dump_string(iter->first.c_str(), iter->second, formatter.get());
8381+
bufferlist& bl = iter->second;
8382+
if (iter->first == RGW_ATTR_OBJ_REPLICATION_TIMESTAMP) {
8383+
decode_dump<ceph::real_time>("user.rgw.replicated-at", bl, formatter.get());
8384+
} else {
8385+
dump_string(iter->first.c_str(), iter->second, formatter.get());
8386+
}
83828387
}
83838388
formatter->close_section();
83848389
formatter->close_section();

src/rgw/rgw_common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ using ceph::crypto::MD5;
145145

146146
#define RGW_ATTR_OBJ_REPLICATION_STATUS RGW_ATTR_PREFIX "amz-replication-status"
147147
#define RGW_ATTR_OBJ_REPLICATION_TRACE RGW_ATTR_PREFIX "replication-trace"
148+
#define RGW_ATTR_OBJ_REPLICATION_TIMESTAMP RGW_ATTR_PREFIX "replicated-at"
148149

149150
/* IAM Policy */
150151
#define RGW_ATTR_IAM_POLICY RGW_ATTR_PREFIX "iam-policy"

src/rgw/rgw_rest_s3.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,15 @@ int RGWGetObj_ObjStore_S3::send_response_data(bufferlist& bl, off_t bl_ofs,
464464
}
465465
} catch (const buffer::error&) {} // omit x-rgw-replicated-from headers
466466
}
467+
if (auto i = attrs.find(RGW_ATTR_OBJ_REPLICATION_TIMESTAMP);
468+
i != attrs.end()) {
469+
try {
470+
ceph::real_time replicated_time;
471+
decode(replicated_time, i->second);
472+
dump_time(s, "x-rgw-replicated-at", replicated_time);
473+
} catch (const buffer::error&) {}
474+
}
475+
467476
if (multipart_parts_count) {
468477
dump_header(s, "x-amz-mp-parts-count", *multipart_parts_count);
469478
}

0 commit comments

Comments
 (0)