GH-49949: [C++][S3] Don't call HeadBucket when creating directories - #50793
Open
goel-skd wants to merge 3 commits into
Open
GH-49949: [C++][S3] Don't call HeadBucket when creating directories#50793goel-skd wants to merge 3 commits into
goel-skd wants to merge 3 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rationale for this change
CreateDir(..., recursive=true)calls HeadBucket to decide whether the bucket needs creating. Credentials scoped to a prefix in the bucket are denied that call, so the directory creation fails even though the caller can write there.What changes are included in this PR?
Only call HeadBucket when
allow_bucket_creationis on. There is nothing to do with the answer otherwise, and a missing bucket still fails when the directory entry is written.Are these changes tested?
Yes. A new test sets a bucket policy granting anonymous access to a single prefix, which leaves HeadBucket denied, then creates a directory under that prefix. It fails with the reported error without the fix. The test is skipped on MinGW, where the AWS SDK's
PutBucketPolicyRequest.hmarks an inline definition withAWS_S3_API(__declspec(dllimport)) and GCC rejects it.Are there any user-facing changes?
With
allow_bucket_creationoff and a bucket that does not exist, the error now comes from PutObject instead ofBucket 'x' not found. To create buckets, enable the allow_bucket_creation option.