Skip to content

rgw/lc: report x-amz-expiration only for the current version - #69642

Merged
cbodley merged 1 commit into
ceph:mainfrom
lumir-sliva:rgw-lc-expiration-header-current-version
Jul 22, 2026
Merged

cbodley merged 1 commit into
ceph:mainfrom
lumir-sliva:rgw-lc-expiration-header-current-version

Conversation

@lumir-sliva

Copy link
Copy Markdown
Contributor

What's wrong

x-amz-expiration is supposed to report the current-version Expiration lifecycle action for an object. s3_expiration_header() instead picked between the Expiration and NoncurrentVersionExpiration rule based on whether the object key had an instance id:

const LCExpiration& rule_expiration =
  (obj_key.instance.empty()) ? expiration : noncur_expiration;

Two problems with that:

  • OLH resolution writes the current version's instance id into the key before the header is built, so even a plain GET/HEAD of the current version (no versionId) looked like a non-current request and got a NoncurrentVersionExpiration rule.
  • x-amz-expiration shouldn't surface NoncurrentVersionExpiration at all. It only describes the current-version Expiration action.

Net effect: a versioned bucket whose only rule is NoncurrentVersionExpiration returns a bogus expiry-date/rule-id on the current object, both on a plain request and a versionId request.

Fix

  • Compute the header from the current-version Expiration rule only.
  • Return no header when the request targets a specific version.
  • The helper now passes the client request key (s->object_key) instead of the OLH-resolved key, so a plain current-version GET/HEAD isn't misclassified as a versioned request.

Open question on x-amz-expiration semantics

Worth flagging for reviewers: with this change, a GET/HEAD that names versionId = the current version no longer gets x-amz-expiration, even when a current Expiration rule applies. AWS does still return the header in that case (the targeted version is current). I chose to suppress it for any explicit versionId because:

  • the header is purely informational, and
  • telling "is this versionId the current version" apart requires resolving the OLH (an extra read) on every versioned GET, which seems heavy for a header.

If matching AWS exactly here matters, the alternative is to plumb an is_current flag (resolve OLH, compare the requested instance to the current one) and emit the current Expiration rule when they match. Happy to go that way if you'd prefer, just didn't want to add per-request I/O without a reason.

Testing

  • New unittest_rgw_lc case ExpHdr.S3ExpirationHeaderCurrentVersionOnly: noncurrent-only policy returns no header (plain or versioned); combined policy returns the current Expiration rule for the current version and nothing for a versionId request.
  • Verified on a vstart RGW cluster. A versioned bucket with only NoncurrentVersionExpiration returns no header for plain HEAD, versionId=current, and versionId=noncurrent; a bucket with a current Expiration rule still returns the header on PUT and on a plain current GET/HEAD.

Tracker: https://tracker.ceph.com/issues/77564

Checklist

  • Tracker (select at least one)
    • References tracker ticket
  • Component impact
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • No doc update is appropriate
  • Tests (select at least one)
    • Includes unit test(s)

The x-amz-expiration response header describes the current-version
Expiration lifecycle action for an object. s3_expiration_header() instead
selected between the Expiration and the NoncurrentVersionExpiration rule
based on whether the object key carried an instance id:

  const LCExpiration& rule_expiration =
    (obj_key.instance.empty()) ? expiration : noncur_expiration;

This was wrong in two ways. OLH resolution writes the current version's
instance id into the key before the header is computed, so even a plain
GET/HEAD of the current version (no versionId) was treated as a
non-current request and reported a NoncurrentVersionExpiration rule. And
x-amz-expiration is not meant to surface NoncurrentVersionExpiration at
all. A versioned bucket whose only rule was NoncurrentVersionExpiration
therefore returned a bogus expiry-date and rule-id on the current object,
for both a plain request and a versionId request.

Compute the header from the current-version Expiration rule only, and
return no header when the request targets a specific version. The header
helper now passes the client request key (s->object_key) rather than the
OLH-resolved key, so a plain GET/HEAD of the current version is no longer
misclassified as a versioned request.

Add a unit test covering a noncurrent-only policy (no header for either a
plain or a versioned request) and a combined policy (the current
Expiration rule for the current version, no header for a versionId
request).

Tracker: https://tracker.ceph.com/issues/77564
Reported-by: Saravanan Palanisamy
Signed-off-by: Lumir Sliva <[email protected]>
@lumir-sliva
lumir-sliva requested a review from a team as a code owner June 22, 2026 15:29
@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

14 similar comments
@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@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.

thanks for the comments, very helpful

regarding functional test coverage, i see that s3-tests uses a check_lifecycle_expiration_header() helper for some test cases, but it doesn't look like any of those use NoncurrentVersionExpiration - so hopefully we won't need to update any tests

Comment thread src/rgw/rgw_rest_s3.cc
Comment on lines -126 to +132
s, s->object->get_key(), s->tagset, mtime, s->bucket_attrs);
s, s->object_key, s->tagset, mtime, s->bucket_attrs);

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.

👍

@anrao19

anrao19 commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

pr testing completed and approved by @ivancich, more details : https://tracker.ceph.com/issues/77817.
@lumir-sliva , if no further testing is needed then this pr can be merged

@lumir-sliva

Copy link
Copy Markdown
Contributor Author

pr testing completed and approved by @ivancich, more details : https://tracker.ceph.com/issues/77817. @lumir-sliva , if no further testing is needed then this pr can be merged

thanks! No further testing from me needed. @cbodley Casey can you please merge it 🙏

@cbodley

cbodley commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

ok to test

@cbodley
cbodley merged commit 5dac2a7 into ceph:main Jul 22, 2026
7 checks passed
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.

4 participants