Skip to content

HDDS-15182. [STS] Remove latent extra read on CopyObject api - make CopyPart work similarly#10203

Open
fmorg-git wants to merge 2 commits into
apache:HDDS-13323-stsfrom
fmorg-git:HDDS-15182
Open

HDDS-15182. [STS] Remove latent extra read on CopyObject api - make CopyPart work similarly#10203
fmorg-git wants to merge 2 commits into
apache:HDDS-13323-stsfrom
fmorg-git:HDDS-15182

Conversation

@fmorg-git

@fmorg-git fmorg-git commented May 6, 2026

Copy link
Copy Markdown
Contributor

Please describe your PR in detail:

  • In STS, CopyObject requires s3:GetObject action on source and s3:PutObject action on destination in order to successfully invoke the api. In the latent S3 implementation, the code was doing an additional read on the destination object to get the eTag and modificationTime when the file was created. This is problematic, because AWS doesn't require s3:GetObject action on the destination file, so this extra read was causing STS smoke tests to fail.

In order to address, don't do the extra read (which will help performance as well) and instead make the commit key call return the modification time in the response and use that. Furthermore, the code already knows what the md5Hash/eTag is, so there is no need to read the destination object.

For consistency, make uploadPartCopy similarly return the modification time as well.

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/HDDS-15182

How was this patch tested?

unit tests, smoke tests

@fmorg-git fmorg-git changed the base branch from master to HDDS-13323-sts May 6, 2026 19:07
@fmorg-git fmorg-git marked this pull request as draft May 6, 2026 19:36
@fmorg-git fmorg-git force-pushed the HDDS-15182 branch 3 times, most recently from fdbfdd7 to a6364b3 Compare May 16, 2026 02:21
@github-actions

github-actions Bot commented Jun 7, 2026

Copy link
Copy Markdown

This PR has been marked as stale due to 21 days of inactivity. Please comment or remove the stale label to keep it open. Otherwise, it will be automatically closed in 7 days.

@github-actions github-actions Bot added the stale label Jun 7, 2026
@fmorg-git

Copy link
Copy Markdown
Contributor Author

commenting to remove stale label

@github-actions github-actions Bot removed the stale label Jun 8, 2026
…arly

 Conflicts:
	hadoop-ozone/interface-client/src/main/proto/OmClientProtocol.proto
@fmorg-git fmorg-git marked this pull request as ready for review June 12, 2026 10:17
@fmorg-git

Copy link
Copy Markdown
Contributor Author

hi @ChenSammi - this PR has been rebased and ready to review once the workflow checks pass. Thanks!

@ChenSammi

ChenSammi commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

In the latent S3 implementation, the code was doing an additional read on the destination object to get the eTag and modificationTime when the file was created.

Fabian, Can you point to the code which is doing this?

This is problematic, because AWS doesn't require s3:GetObject action on the destination file, so this extra read was causing STS smoke tests to fail

Can you point out failed smoke test?

* This is backward compatible with older OM versions which do not return
* the value in {@code CommitKeyResponse}.
*/
default OptionalLong commitKeyWithModificationTime(OmKeyArgs args, long clientID) throws IOException {

@ChenSammi ChenSammi Jun 16, 2026

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.

It looks like that LastModified element is a mandatory part of CopyObject and UploadPartCopy.

https://docs.aws.amazon.com/AmazonS3/latest/API/API_CopyObject.html
https://docs.aws.amazon.com/AmazonS3/latest/API/API_UploadPartCopy.html

So without this patch, Ozone now returns incorrect LastModified? Since there is already lastModified field in CopyObjectResponse and CopyPartResult.

Since it's mandatory for S3, we don't need to maintain both commitKeyWithModificationTime and commitKey, update commitKey to return long, instead of OptionalLong, making sure lastModified is returned after a successful commit, so we can get a clean logic and code.

@fmorg-git fmorg-git Jun 17, 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.

So without this patch, Ozone now returns incorrect LastModified?

There were two cases previously per my understanding:

  1. CopyObject: the current time was set when the key is committed. Then an extra lookup is performed in getClientProtocol().getKeyDetails() to find what that modification time is (so it was correct). This patch changes to return the modification time in the CommitKeyResponse itself so the extra lookup isn't needed (and this extra lookup was breaking STS).
  2. UploadPartCopy: it was just doing an Instant.now() in the CopyPartResult constructor, so the returned LastModified was the gateway's wall‑clock at response time, not the OM‑side commit time of the part key, so it was not correct but was approximate

For both these cases, the patch now returns the actual lastModified that was set at the time the key was committed in the response itself so that a) no extra fetch is needed and b) it is more accurate

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.

Since it's mandatory for S3, we don't need to maintain both commitKeyWithModificationTime and commitKey, update commitKey to return long,

@ChenSammi - would this be a breaking api change to commitKey for older clients or mixed client versions?

EchoRPCResponse echoRPCReq(byte[] payloadReq, int payloadSizeResp,
boolean writeToRatis) throws IOException;


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.

This can be reverted.

{
"name": "CommitKeyResponse"
"name": "CommitKeyResponse",
"fields": [

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.

proto.lock change doesn't need be included in patch. It will be updated as a whole during Ozone release.

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.

proto.lock change doesn't need be included in patch. It will be updated as a whole during Ozone release.

Small, but important correction: proto.lock shouldn't be changed (in regular 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.

updated - cd3d5b2

@@ -46,8 +46,12 @@ public CopyPartResult() {
}

public CopyPartResult(String eTag) {

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.

Remove this constructor if it's not used anymore.

private final Long modificationTime;

public OmMultipartCommitUploadPartInfo(String partName, String eTag) {
this(partName, eTag, null);

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.

Remove this constructor if it's not used anymore.

omClient.commitKey(buildKeyArgs(), openID);
final OptionalLong modificationTime = omClient.commitKeyWithModificationTime(buildKeyArgs(), openID);
if (modificationTime.isPresent()) {
metadata.put(OzoneConsts.MODIFICATION_TIME, String.valueOf(modificationTime.getAsLong()));

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.

metadata is to persist in OM DB, a different goal. Please add a new field for LastModified value.

@ChenSammi

Copy link
Copy Markdown
Contributor

@fabian, could you also add some tests for the new changes?

{
"name": "CommitKeyResponse"
"name": "CommitKeyResponse",
"fields": [

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.

proto.lock change doesn't need be included in patch. It will be updated as a whole during Ozone release.

Small, but important correction: proto.lock shouldn't be changed (in regular PRs).

@fmorg-git

fmorg-git commented Jun 17, 2026

Copy link
Copy Markdown
Contributor Author

In the latent S3 implementation, the code was doing an additional read on the destination object to get the eTag and modificationTime when the file was created.

Fabian, Can you point to the code which is doing this?

This is problematic, because AWS doesn't require s3:GetObject action on the destination file, so this extra read was causing STS smoke tests to fail

Can you point out failed smoke test?

I removed the code that was doing the additional read on the destination object. Copilot flagged it as an issue in the previous PR as well but had an incorrect suggested fix: #10197 (comment) (open this link in a new tab for it to go to the correct comment)

This series of smoke tests will fail without this fix: https://github.com/fmorg-git/ozone/blob/0ece11555841b68822e0f5a87c77fc4830ec4fda/hadoop-ozone/dist/src/main/smoketest/security/ozone-secure-sts.robot#L927-L984

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants