Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rgw/multisite: add x-rgw-replicated-at header to replicated objects #55503

Merged
merged 2 commits into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 @@ -4412,6 +4413,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 @@ -8355,7 +8355,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());
smanjara marked this conversation as resolved.
Show resolved Hide resolved
} 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 @@ -463,6 +463,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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@smanjara i think we want to use dump_time_header() here instead? dump_time() is calling s->formatter->dump_string() to format this as json/xml

i'm tracking a regression here in https://tracker.ceph.com/issues/65373

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix in #56765

} catch (const buffer::error&) {}
}

if (multipart_parts_count) {
dump_header(s, "x-amz-mp-parts-count", *multipart_parts_count);
}
Expand Down