Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split GetACL into GetBucketACL and GetObject ACL and the same for PutACL #3408

Merged
merged 4 commits into from
Aug 20, 2024

Conversation

peterrsongg
Copy link
Contributor

@peterrsongg peterrsongg commented Jul 30, 2024

Description

GetACL and PutACL in the SDK is a combination of GetBucketACL and PutBucketACL and there is a customization made to rename the method and exclude the GetObjectACL methods. This PR obsoletes the existing GetACL/PutACL operations and adds the GetBucketACL and GetObjectACL / PutBucketACL and PutObjectACL operations. It also adds the handwritten custom marshallers/request classes etc. and refactors any existing unit/integ test to use the new operations.

I put the GetACL and PutACL into a custom partial AmazonS3Client and did the same thing for IAmazonS3.

Motivation and Context

  1. Currently GetACL and PutACL do not read the contextParams from the model, so it is possible that in the future if these contextParams are used in the endpoint ruleset then we could resolve an incorrect endpoint. Splitting the operations ensures that the contextParams are used in the EndpointResolver.
  2. Parity with other SDKs + maintanability.

Testing

Dry run passes.
Added an integ test.
Also did a manual test and made sure that the old method is still callable.

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project
  • My change requires a change to the documentation
  • I have updated the documentation accordingly
  • I have read the README document
  • I have added tests to cover my changes
  • All new and existing tests passed

License

  • I confirm that this pull request can be released under the Apache 2 license

Copy link
Member

@muhammad-othman muhammad-othman left a comment

Choose a reason for hiding this comment

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

This approach seems a bit complicated IMO. What about removing GetACL and PutACL from the generator and the models, and add them and add them manually?

@peterrsongg
Copy link
Contributor Author

This approach seems a bit complicated IMO. What about removing GetACL and PutACL from the generator and the models, and add them and add them manually?

I agree that it is a bit complicated, but unfortunately it is just the way that customizations work in the generator, especially renames. All it does is point to the original json object in the model but renames the operation. We need to create a copy of this operation basically with the original name to be able to generate both GetACL and GetBucketACL in the client file.

I was thinking maybe we could use this functionality in the future? but you're probably right, it is better to manually add them, and delete this added complexity to the generator. I will see what the team thinks

@peterrsongg peterrsongg force-pushed the petesong/split-acl branch 2 times, most recently from 2eb83db to e83c9f2 Compare August 9, 2024 15:58
}
finally
{
AmazonS3Util.DeleteS3BucketWithObjects(Client, bucketName);
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this finally is correct, the bucketName variable here doesn't refer to the bucket you created but the private static variable with the same name:

I'd either use a different variable name in this method or update it not to create a new bucket at all (you'd need to confirm changing the ACLs doesn't impact the other tests here - as they all share the same bucket).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thank you for pointing that out. I moved the variable outside the try block and renamed it. I also just ran the integ test and confirmed it is deleting the right bucket.

…CL into PutObjectACL and PutBucketACL. Obsolete PutACL and GetACL.
@peterrsongg peterrsongg requested review from dscpinheiro and muhammad-othman and removed request for boblodgett August 9, 2024 20:31
@muhammad-othman
Copy link
Member

Do we have to create this new custom S3 client? What about using the existing extension S3 client file instead?

@peterrsongg
Copy link
Contributor Author

Do we have to create this new custom S3 client? What about using the existing extension S3 client file instead?

Nope, I just moved them to the extension file instead

Copy link
Contributor

@dscpinheiro dscpinheiro left a comment

Choose a reason for hiding this comment

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

I have one general question too: Is there a reason why we're using lowercase for the operation names / request objects? For example, the changelog (and PR title) mention GetACL into GetBucketACL and GetObjectACL but then the classes are named GetBucketAcl and GetObjectAcl.

Comment on lines 69 to 70


Copy link
Contributor

Choose a reason for hiding this comment

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

What are these extra lines for?

@@ -271,6 +271,7 @@ namespace Amazon.S3.Model
/// </para>
/// </li> </ul>
/// </summary>
///
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove this extra line.

@@ -82,8 +82,6 @@
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
Copy link
Contributor

Choose a reason for hiding this comment

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

This <ItemGroup> removal seems odd, I don't see any generator changes included in this PR that could've caused this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this was a manual change I made on accident😅, rerunning the generator removed this.

{
#region GetACL
[Obsolete("GetACL combines both GetBucketAcl and GetObjectAcl and is deprecated. Please use the separated GetObjectAcl and GetBucketAcl operations.")]
Task<GetACLResponse> GetACLAsync(string bucketName, System.Threading.CancellationToken cancellationToken = default(CancellationToken));
Copy link
Contributor

Choose a reason for hiding this comment

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

This method is missing documentation. Also, since this is the bcl folder, shouldn't you also have to include the non-async methods?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good call, i did a manual test and the non-async methods were callable so I thought I was in the clear, but based on the pattern the other methods follow it looks like I missed adding it here.

"serviceName": "S3",
"type": "patch",
"changeLogMessages": [
"Split GetACL into GetBucketACL and GetObjectACL. Split PutACL into PutObjectACL and PutBucketACL. Obsolete PutACL and GetACL"
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd expand this message a bit more (for example, if this goes into the V4 tracker issue, is there enough information for customers to understand why we're doing this?)

@peterrsongg
Copy link
Contributor Author

I have one general question too: Is there a reason why we're using lowercase for the operation names / request objects? For example, the changelog (and PR title) mention GetACL into GetBucketACL and GetObjectACL but then the classes are named GetBucketAcl and GetObjectAcl.

Yeah so when we did the customization for GetACL and PutACL we renamed it to use capital ACL, but generating from the model the operation is generated as GetAcl and PutAcl. I think the name of the files should reflect what is modeled so I will change those to Acl

@peterrsongg
Copy link
Contributor Author

Addressed all comments and the PR is ready for another pass (dry-run also succeeded)

{
"serviceName": "S3",
"type": "patch",
"changeLogMessages": [
Copy link
Contributor

Choose a reason for hiding this comment

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

No need to change, but since this is an array you could also split this into multiple messages so it's easier to read. Like this:

"changeLogMessages": [
    "Split `GetACL` into `GetBucketAcl` and `GetObjectAcl`",
    "Split `PutACL` into `PutObjectACL` and `PutBucketACL`",
    "Obsolete `PutACL` and `GetACL`: These operations are being split ..."
]

@peterrsongg peterrsongg merged commit 6c740df into v4-development Aug 20, 2024
1 check passed
@peterrsongg peterrsongg deleted the petesong/split-acl branch August 20, 2024 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants