Skip to content

HDDS-16650. Reuse bucket metadata in S3 lifecycle PUT and DELETE - #11372

Merged
adoroszlai merged 6 commits into
apache:masterfrom
rich7420:HDDS-16650
Oct 2, 2026
Merged

adoroszlai merged 6 commits into
apache:masterfrom
rich7420:HDDS-16650

Conversation

@rich7420

@rich7420 rich7420 commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Reuse bucket metadata in S3RequestContext for PUT and DELETE lifecycle configuration requests. Owner verification and the subsequent operation share the same OzoneBucket, avoiding a second InfoBucket RPC when expected-owner verification succeeds. This preserves the existing bucket READ requirement, owner validation, bucket layout handling, and error mapping. GET continues to call ClientProtocol directly.

This combines the PUT change from #11374 with the DELETE change, as suggested in review.

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/HDDS-16650
https://issues.apache.org/jira/browse/HDDS-16649

How was this patch tested?

  • Full S3 Gateway unit suite before the bucket-name simplification: 1176 tests, 0 failures or errors.
  • After the simplification: 118 relevant tests passed; checkstyle passed.
  • Restoring the original lifecycle handlers causes three bucket-lookup-count cases to fail.
  • Context tests cover repeated lookup, different-bucket rejection, lookup failure, and isolation between requests.
  • Checkstyle and RAT passed.
  • Fork CI and 10×10 flaky-test-check for the PUT, DELETE, and request-context suites on Java 21 are in progress.

Copilot AI balanced review requested due to automatic review settings September 30, 2026 12:50

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions github-actions Bot added the s3 S3 Gateway label Sep 30, 2026
}

private void verifyBucketOwner(S3RequestContext context, String bucketName) throws OS3Exception {
private OzoneBucket verifyBucketOwner(S3RequestContext context, String bucketName) throws OS3Exception {

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.

Could we also reuse the verified bucket in the PUT and GET lifecycle paths to avoid the second getBucket() call?

@rich7420 rich7420 Sep 30, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@Russole Thanks for mention that! The PUT change is already prepared under HDDS-16649. GET was addressed in #11355, which is merged and calls ClientProtocol directly without the extra bucket lookup.

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 @rich7420 for the patch. This has overlap with #11374, so there will be conflict for one or the other. It would be nice to create PR only after merge of the other, to reduce both reviewer and CI time. Actually, in this case I think the change is small enough to combine the two PRs.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks, that makes sense. I'll combine the PUT and DELETE changes here and use the request-context approach you suggested in #11374.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated in ab3271f: PUT and DELETE now use S3RequestContext#getBucket. Closed #11374 and kept this PR as draft while fork CI runs.

@Russole Russole 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 @rich7420 for working on this. Left some comments.

@Gargi-jais11 Gargi-jais11 added the s3-lifecycle HDDS-8342 label Oct 1, 2026
@rich7420
rich7420 marked this pull request as draft October 1, 2026 09:04
@rich7420 rich7420 changed the title HDDS-16650. Reuse bucket metadata after owner verification in S3 DeleteBucketLifecycle HDDS-16650. Reuse bucket metadata in S3 lifecycle PUT and DELETE Oct 1, 2026

@adoroszlai adoroszlai 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 @rich7420 for updating the patch.

Comment on lines +64 to +66
bucketName = name;
} else {
Preconditions.assertTrue(bucketName.equals(name), "Multiple buckets in one request are not supported");

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.

minor optimization: bucketName is not needed, since bucket knows its name

Suggested change
bucketName = name;
} else {
Preconditions.assertTrue(bucketName.equals(name), "Multiple buckets in one request are not supported");
} else {
Preconditions.assertEquals(bucket.getName(), name, "Multiple buckets in one request are not supported");

private final EndpointBase endpoint;
private S3GAction action;
private OzoneVolume volume;
private String bucketName;

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.

Suggested change
private String bucketName;

@adoroszlai
adoroszlai marked this pull request as ready for review October 2, 2026 06:26
@adoroszlai
adoroszlai merged commit 037a367 into apache:master Oct 2, 2026
60 checks passed
@rich7420

rich7420 commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

@adoroszlai and @Russole thanks for the review!

@chungen0126

Copy link
Copy Markdown
Contributor

Thanks @rich7420 for working on this, @adoroszlai for the review.

However, This change does not reduce the number of RPCs. The original implementation already caches OzoneBucket, so there wouldn't be a second InfoBucket RPC.

Please verify via distributed tracing after the modification to see if it behaves as expected.

@adoroszlai

Copy link
Copy Markdown
Contributor

change does not reduce the number of RPCs. The original implementation already caches OzoneBucket, so there wouldn't be a second InfoBucket RPC.

@chungen0126 Thanks for checking. Can you please point to the place where OzoneBucket is cached?

@rich7420

rich7420 commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @chungen0126. I verified this with real S3 Gateway → OM RPCs in a MiniOzoneCluster, using paired client/server traces.

For both lifecycle PUT and DELETE, InfoBucket goes from 2 to 1 with a matching expected-owner header; without it, the count stays at 1. Repeated requests give the same counts. The previous context cached the volume, while each getBucket() still issued an RPC.

Traces, reproducer, and before/after results.

@adoroszlai

Copy link
Copy Markdown
Contributor

I have also verified with compose cluster using bucketlifecycle.robot.

@chungen0126

Copy link
Copy Markdown
Contributor

Thanks @chungen0126. I verified this with real S3 Gateway → OM RPCs in a MiniOzoneCluster, using paired client/server traces.

For both lifecycle PUT and DELETE, InfoBucket goes from 2 to 1 with a matching expected-owner header; without it, the count stays at 1. Repeated requests give the same counts. The previous context cached the volume, while each getBucket() still issued an RPC.

Traces, reproducer, and before/after results.

You are right, I missed that case. Thanks for the detailed verification and providing the traces!

@rich7420

rich7420 commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for checking!

@adoroszlai

Copy link
Copy Markdown
Contributor

BTW, it may be easier to check in OM audit log than distributed tracing.

@chungen0126

Copy link
Copy Markdown
Contributor

change does not reduce the number of RPCs. The original implementation already caches OzoneBucket, so there wouldn't be a second InfoBucket RPC.

@chungen0126 Thanks for checking. Can you please point to the place where OzoneBucket is cached?

My bad. I thought it was called from ObjectRequestContext, but it's actually called from OzoneVolume here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

s3-lifecycle HDDS-8342 s3 S3 Gateway

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants