Skip to content

rgw/set_attrs: Do not modify mtime - #52160

Merged
soumyakoduri merged 1 commit into
ceph:mainfrom
soumyakoduri:wip-skoduri-lc-acl
Jul 3, 2023
Merged

soumyakoduri merged 1 commit into
ceph:mainfrom
soumyakoduri:wip-skoduri-lc-acl

Conversation

@soumyakoduri

@soumyakoduri soumyakoduri commented Jun 22, 2023 •

Copy link
Copy Markdown
Contributor

As per https://docs.aws.amazon.com/AmazonS3/latest/userguide/UsingMetadata.html, the only way for users to modify object metadata is to make a copy of the object and set the metadata. Hence retain old mtime for any other attr changes via set_attrs.

Fixes: https://tracker.ceph.com/issues/61770
Signed-off-by: Soumya Koduri[email protected]

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
Show available Jenkins commands
  • jenkins retest this please
  • jenkins test classic perf
  • jenkins test crimson perf
  • jenkins test signed
  • jenkins test make check
  • jenkins test make check arm64
  • jenkins test submodules
  • jenkins test dashboard
  • jenkins test dashboard cephadm
  • jenkins test api
  • jenkins test docs
  • jenkins render docs
  • jenkins test ceph-volume all
  • jenkins test ceph-volume tox
  • jenkins test windows

@soumyakoduri
soumyakoduri requested a review from a team as a code owner June 22, 2023 17:57
@github-actions github-actions Bot added the rgw label Jun 22, 2023
@soumyakoduri

Copy link
Copy Markdown
Contributor Author

@cbodley
The changes seem to work for the cases even without version-id specified ('s3cmd setacl --acl-public s3://bucket/object'). The caller (PutACLs) calls get_obj_state(..) with follow_olh = true before calling set_attrs with right instance updated. Do we still need the changes to 'append_atomic_testinset_attrs` which you had suggested earlier (just in case other callers do not update version-id)?

@soumyakoduri
soumyakoduri requested review from cbodley and ivancich June 22, 2023 18:09
@soumyakoduri

soumyakoduri commented Jun 22, 2023 •

Copy link
Copy Markdown
Contributor Author

@cbodley @ivancich .. I have noticed that in case if set_attrs is called on non-current versioned object entry, it seem to be getting promoted to current as part of set_olh.

Though as per https://docs.aws.amazon.com/AmazonS3/latest/userguide/add-object-metadata.html, it seems ok to promote non-current to current in case of metadata changes, I am not sure if that applies to all the cases. For eg., when lifecycle transition updates storage class of non-current objects, they do not get promoted to current. Right? But as per the doc, changes to x-amz-storage-class should have moved older version to current.

@mattbenjamin

Copy link
Copy Markdown
Contributor

@cbodley @ivancich .. I have noticed that in case if set_attrs is called on non-current versioned object entry, it seem to be getting promoted to current as part of set_olh.

Though as per https://docs.aws.amazon.com/AmazonS3/latest/userguide/add-object-metadata.html, it seems ok to promote non-current to current in case of metadata changes, I am not sure if that applies to all the cases. For eg., when lifecycle transition updates storage class of non-current objects, they do not get promoted to current. Right?

Do you see text in the AWS doc specifically speaking about promoting non-current to current? That does not seem like kosher behavior to me.

@soumyakoduri

Copy link
Copy Markdown
Contributor Author

@cbodley @ivancich .. I have noticed that in case if set_attrs is called on non-current versioned object entry, it seem to be getting promoted to current as part of set_olh.
Though as per https://docs.aws.amazon.com/AmazonS3/latest/userguide/add-object-metadata.html, it seems ok to promote non-current to current in case of metadata changes, I am not sure if that applies to all the cases. For eg., when lifecycle transition updates storage class of non-current objects, they do not get promoted to current. Right?

Do you see text in the AWS doc specifically speaking about promoting non-current to current? That does not seem like kosher behavior to me.

I found this note in that AWS doc

Note

Consider the following issues when you are editing object metadata in Amazon S3:

This action creates a copy of the object with updated settings and the last-modified date. If S3 Versioning is enabled, a new version of the object is created, and the existing object becomes an older version. If S3 Versioning is not enabled, a new copy of the object replaces the original object. The AWS account associated with the IAM role that changes the property also becomes the owner of the new object or (object version).

<<<

@cbodley cbodley left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

otherwise looks good. can we find a way to test this in s3tests?

Comment thread src/rgw/driver/rados/rgw_rados.cc Outdated
Comment on lines 6086 to 6088

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

epoch and olh_epoch are two different things. i think you just want to pass olh_epoch=0 into set_olh(), which should cause cls_rgw.cc's rgw_bucket_link_olh() -> start_modify() to increment its stored olh_epoch

@cbodley

cbodley commented Jun 22, 2023

Copy link
Copy Markdown
Contributor

Do you see text in the AWS doc specifically speaking about promoting non-current to current? That does not seem like kosher behavior to me.

i agree this seems unexpected here. i think that text was specific to object metadata, where the only way to change it is by copying the object over itself with updated metadata. in a versioned bucket, that would indeed create a new version and make it current

but looking at docs for PutObjectAcl specifically:

Versioning: The ACL of an object is set at the object version level. By default, PUT sets the ACL of the current version of an object. To set the ACL of a different version, use the versionId subresource.

it sounds like the intent is to apply the updated ACLs to those existing versions without changing the current version. as you point out, set_olh() isn't doing what we want in this case

@cbodley

cbodley commented Jun 22, 2023

Copy link
Copy Markdown
Contributor

it's actually not clear to me that PutObjectACL is supposed to update the mtime. while i wouldn't consider the "Sample Responses" in https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutObjectAcl.html to be conclusive evidence, they return wildly different header values for Date vs. Last-Modified:

Date: Wed, 28 Oct 2009 22:32:00 GMT
Last-Modified: Sun, 1 Jan 2006 12:00:00 GMT

going back to the doc about object metadata https://docs.aws.amazon.com/AmazonS3/latest/userguide/UsingMetadata.html, the very first paragraph reads:

You can set object metadata in Amazon S3 at the time you upload the object. Object metadata is a set of name-value pairs. After you upload the object, you cannot modify object metadata. The only way to modify object metadata is to make a copy of the object and set the metadata.

and because Last-Modified is listed under 'System-defined object metadata':

Last-Modified | The object creation date or the last modified date, whichever is the latest.

i would conclude that the only way to modify that mtime is by copying the object, not by calling PutObjectACL

@cbodley

cbodley commented Jun 22, 2023

Copy link
Copy Markdown
Contributor

i used my free aws account to test this out with boto3, and found that the value of LastModified returned by list_object_versions()/head_object() does not change after a call to put_object_acl(). in all cases, it returned the 'LastModified': datetime.datetime(2023, 6, 22, 21, 52, 48, tzinfo=tzutc()) corresponding to the initial upload

@soumyakoduri

Copy link
Copy Markdown
Contributor Author

Thanks Casey and Matt.

i would conclude that the only way to modify that mtime is by copying the object, not by calling PutObjectACL

So would it apply to any metadata change via set_attrs. Or should I make changes not to update mtime just for PutObjectACL op for now?

@cbodley

cbodley commented Jun 23, 2023

Copy link
Copy Markdown
Contributor

So would it apply to any metadata change via set_attrs.

the ops that are supposed to update the mtime should already be going through the copy path that handles this correctly. i think set_attrs() should preserve the existing mtime

@soumyakoduri soumyakoduri changed the title rgw: Update index entry for any metadata changes rgw/set_attrs: Do not modify mtime Jun 24, 2023
@soumyakoduri

Copy link
Copy Markdown
Contributor Author

the ops that are supposed to update the mtime should already be going through the copy path that handles this correctly. i think set_attrs() should preserve the existing mtime

Thanks Casey. Updated the PR. Since there is no change in mtime, I think there is no need to update bi entry now.

@cbodley

cbodley commented Jun 26, 2023

Copy link
Copy Markdown
Contributor

looks good, thanks. would you be willing to add test cases for ListObjects and HeadObject to verify that neither mtime changes on PutObjectACL?

@soumyakoduri

Copy link
Copy Markdown
Contributor Author

looks good, thanks. would you be willing to add test cases for ListObjects and HeadObject to verify that neither mtime changes on PutObjectACL?

sure..will add testcases and update.

As per https://docs.aws.amazon.com/AmazonS3/latest/userguide/UsingMetadata.html,
the only way for users to modify object metadata is to make a copy of the object and
set the metadata. Hence retain old mtime for any other attr changes

Signed-off-by: Soumya Koduri <[email protected]>
@cbodley

cbodley commented Jun 29, 2023

Copy link
Copy Markdown
Contributor

confirmed that the test case fails against main:

FAILED s3tests_boto3/functional/test_s3.py::test_object_put_acl_mtime - assert datetime.datetime(2023, 6, 29, 15, 36, 58, tzinfo=tzutc()) == datetime.datetime(2023, 6, 29, 15, 37, tzinfo=tzutc())

and passes against this pr 👍

@mattbenjamin mattbenjamin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ack, thanks soumya, casey

@cbodley

cbodley commented Jun 29, 2023

Copy link
Copy Markdown
Contributor

(note that my #51842 is using set_attrs() to override the object's mtime, but i'll rebase that on top of your changes)

@soumyakoduri

Copy link
Copy Markdown
Contributor Author

confirmed that the test case fails against main:

FAILED s3tests_boto3/functional/test_s3.py::test_object_put_acl_mtime - assert datetime.datetime(2023, 6, 29, 15, 36, 58, tzinfo=tzutc()) == datetime.datetime(2023, 6, 29, 15, 37, tzinfo=tzutc())

and passes against this pr 👍

Thanks Casey

@soumyakoduri soumyakoduri reopened this Jun 30, 2023
@soumyakoduri
soumyakoduri merged commit 0c5a77f into ceph:main Jul 3, 2023
yuvalif pushed a commit to yuvalif/ceph that referenced this pull request Aug 14, 2023
As per https://docs.aws.amazon.com/AmazonS3/latest/userguide/UsingMetadata.html,
the only way for users to modify object metadata is to make a copy of the object and
set the metadata. Hence retain old mtime for any other attr changes

Resolves: rhbz#2213801

Fixes: https://tracker.ceph.com/issues/61770
References: ceph#52160

Signed-off-by: Soumya Koduri <[email protected]>
(cherry picked from commit 31666d7)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants