[FLINK-39485][filesystem/s3] Support bucket root using HeadBucket for empty object key#27964
[FLINK-39485][filesystem/s3] Support bucket root using HeadBucket for empty object key#27964macdoor wants to merge 1 commit intoapache:masterfrom
Conversation
|
@macdoor Can you alter the PR Description to match as per the default guidelines https://github.com/apache/flink/blob/master/.github/PULL_REQUEST_TEMPLATE.md |
spuru9
left a comment
There was a problem hiding this comment.
As there dont exist any tests for the file, its worth adding a small test to establish the pattern. or else can you add in PR description how the fix was validated against a
real bucket.
|
Hi, @Samrat002 Could you help take a look ? Thank you. |
37c33b3 to
e91ae46
Compare
… empty object key HeadObject requires a non-empty object key in AWS SDK v2. Warehouse URIs such as s3://my-bucket yield an empty key from NativeS3AccessHelper.extractKey, which caused SdkClientException when creating catalogs or checking paths. Use HeadBucket for the bucket root and return a directory FileStatus. Handle NoSuchBucketException as FileNotFoundException. Add S3ClientProvider.createForTesting and NativeS3FileSystemBucketRootTest (DelegatingS3Client-based test double) to verify HeadBucket is used and HeadObject is not called for the bucket root. https: //issues.apache.org/jira/browse/FLINK-39485 Made-with: Cursor
e91ae46 to
1bc7bc8
Compare
|
@flinkbot run azure |
|
I have checked and tried with the S3 bucket. I was not able to reproduce the issue. |
|
@Samrat002 You are right. I can reproduce this on MinIO with warehouse = s3:// (empty key), not S3 |
|
thank you, @macdoor, for confirming. 🙌🏻 let's discuss with the community on
IMO native-s3-fs should support only pure S3 (not S3 compatible fs). |
|
Is this a bug for the vanilla s3 integration or just minio support? |
|
This is not a bug for vanilla S3 integration. I have validated it. This issue is not reproducing with vanilla S3. |
What is the purpose of the change
Fix
NativeS3FileSystem.getFileStatusfor warehouse-style URIss3://bucket(empty object key). AWS SDK v2 rejectsHeadObjectwith an empty key (Key cannot be empty), which breaks catalog creation / existence checks against S3-compatible storage (e.g. MinIO).Brief change log
HeadBucketand return a directoryFileStatuswhen the bucket exists.NoSuchBucketExceptionasFileNotFoundException.S3ClientProvider.createForTestingandNativeS3FileSystemBucketRootTest(mockedS3Client) to lock in the HeadBucket vs HeadObject behavior.Verifying this change
This change added tests and can be verified as follows:
mvn -pl flink-filesystems/flink-s3-fs-native test -Dtest=NativeS3FileSystemBucketRootTestwarehouse = 's3://<bucket>'(no prefix) succeeds with this patch.Does this pull request potentially affect one of the following parts:
mockito-core(version from parent${mockito.version})@Public(Evolving): noDocumentation