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

chore(storage): add UpdateBucketACL implementation #5974

Merged
merged 7 commits into from
May 9, 2022

Conversation

cojenco
Copy link
Contributor

@cojenco cojenco commented May 2, 2022

This adds UpdateBucketACL implementation

  • gRPC implementation per discussion with Chris and Noah
    • Add un-exported fields acl and defaultObjectACL to BucketAttrsToUpdate
    • Let UpdateBucketACL to directly utilize UpdateBucket with BucketAttrsToUpdate. This UPDATE operation requires making a GET call first to retrieve existing ACL
  • HTTP implementation
  • basic emulator test

@product-auto-label product-auto-label bot added size: m Pull request size is medium. api: storage Issues related to the Cloud Storage API. labels May 2, 2022
@cojenco cojenco marked this pull request as ready for review May 3, 2022 23:26
@cojenco cojenco requested review from a team as code owners May 3, 2022 23:26
Copy link
Contributor

@tritone tritone left a comment

Choose a reason for hiding this comment

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

Good start! A few comments.

@@ -986,11 +986,17 @@ func (ua *BucketAttrsToUpdate) toProtoBucket() *storagepb.Bucket {
lifecycle = *ua.Lifecycle
}
var bktACL []*storagepb.BucketAccessControl
if ua.acl != nil {
bktACL = toProtoBucketACL(ua.acl)
}
if ua.PredefinedACL != "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

Very confused about what is going on with PredefinedACL and PredefinedDefaultObjectACL here... it doesn't seem like they are actually being set on the returned 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.

IIUC, one cannot provide both a predefinedAcl and an acl while patching/updating a bucket. I tried out buckets.patch and buckets.update with the JSON API, and it results in a 409 conflict error.

So in the library code here,, PredefinedACL and PredefinedDefaultObjectACL take precedence and therefore clears ACLs.

That being said, I believe I need to handle the updateMask with more care under the update semantics. Let me know if this clarifies your question.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ahh, gotcha. Yeah I think ForceSendFields plays the same role for JSON that the updateMask plays for gRPC

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Appreciate the review, Chris! Added some inline comments. Hopefully that's clearer for readers and our future selves.

Copy link
Contributor

@tritone tritone left a comment

Choose a reason for hiding this comment

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

Nice work! Just a couple more little things

acl, err = req.Do()
aclRule = toBucketACLRule(acl)
return err
}, s.retry, false)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here, use s.idempotent so we can set it above the interface

@@ -986,11 +986,17 @@ func (ua *BucketAttrsToUpdate) toProtoBucket() *storagepb.Bucket {
lifecycle = *ua.Lifecycle
}
var bktACL []*storagepb.BucketAccessControl
if ua.acl != nil {
bktACL = toProtoBucketACL(ua.acl)
}
if ua.PredefinedACL != "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

Ahh, gotcha. Yeah I think ForceSendFields plays the same role for JSON that the updateMask plays for gRPC

if err != nil {
return nil, err
}
aclRule := b.ACL[len(b.ACL)-1]
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's just return the ACLRule we sent rather than picking the last one off the list (I'm not sure if the ordering is guaranteed)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@cojenco cojenco added the automerge Merge the pull request once unit tests and other checks pass. label May 9, 2022
@gcf-merge-on-green gcf-merge-on-green bot merged commit 3be2d0d into googleapis:main May 9, 2022
@gcf-merge-on-green gcf-merge-on-green bot removed the automerge Merge the pull request once unit tests and other checks pass. label May 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: storage Issues related to the Cloud Storage API. size: m Pull request size is medium.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants