Merge pull request #50098 from soumyakoduri/wip-skoduri-cloud-trans-azure

rgw/cloud: Add custom headers for objects transitioned to cloud

Reviewed-by: Casey Bodley <cbodley@redhat.com>
This commit is contained in:
Soumya Koduri 2023-02-23 17:49:31 +05:30 committed by GitHub
commit 9f0440e6d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 2 deletions

View File

@ -302,6 +302,18 @@ Due to API limitations there is no way to preserve original object modification
x-amz-meta-rgwx-source-mtime: 1608546349.757100363
x-amz-meta-rgwx-versioned-epoch: 0
In order to allow some cloud services detect the source and map the user-defined 'x-amz-meta-' attributes, below two additional new attributes are added to the objects being transitioned
::
x-rgw-cloud : true/false
(set to "true", by default, if the object is being transitioned from RGW)
x-rgw-cloud-keep-attrs : true/false
(if set to default value "true", the cloud service should map and store all the x-amz-meta-* attributes. If it cannot, then the operation should fail.
if set to "false", the cloud service can ignore such attributes and just store the object data being sent.)
By default, post transition, the source object gets deleted. But it is possible to retain its metadata but with updated values (like storage-class and object-size) by setting config option 'retain_head_object' to true. However GET on those objects shall still fail with 'InvalidObjectState' error.
For example,

View File

@ -514,8 +514,7 @@ int RGWLCCloudStreamPut::init() {
}
bool RGWLCCloudStreamPut::keep_attr(const string& h) {
return (keep_headers.find(h) != keep_headers.end() ||
boost::algorithm::starts_with(h, "X_AMZ_"));
return (keep_headers.find(h) != keep_headers.end());
}
void RGWLCCloudStreamPut::init_send_attrs(const DoutPrefixProvider *dpp,
@ -531,6 +530,12 @@ void RGWLCCloudStreamPut::init_send_attrs(const DoutPrefixProvider *dpp,
for (auto& hi : rest_obj.attrs) {
if (keep_attr(hi.first)) {
attrs.insert(hi);
} else {
std::string s1 = boost::algorithm::to_lower_copy(hi.first);
const char* k = std::strstr(s1.c_str(), "x-amz");
if (k) {
attrs[k] = hi.second;
}
}
}
@ -633,6 +638,8 @@ void RGWLCCloudStreamPut::init_send_attrs(const DoutPrefixProvider *dpp,
/* New attribute to specify its transitioned from RGW */
attrs["x-amz-meta-rgwx-source"] = "rgw";
attrs["x-rgw-cloud"] = "true";
attrs["x-rgw-cloud-keep-attrs"] = "true";
char buf[32];
snprintf(buf, sizeof(buf), "%llu", (long long)obj_properties.versioned_epoch);