[PDI-20638] Unify minio and amazon region, refactor ui to client code#10468
[PDI-20638] Unify minio and amazon region, refactor ui to client code#10468tgf wants to merge 1 commit intopentaho:masterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors the S3 VFS plugin to unify Amazon/Minio region handling and centralize S3 client option parsing/creation, while updating UI and tests to match the new region/env detection logic.
Changes:
- Unifies Minio/AWS region handling by removing the separate
minioRegionfield and syncing UI inputs into a singleregion. - Introduces
S3Optionsas a centralized options container/parser used by S3 client construction. - Renames the region detection hook from
isRegionSet()toisEnvRegionSet()and updates related tests/stubs.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| plugins/s3-vfs/core/src/test/java/org/pentaho/s3n/vfs/S3NFileSystemTest.java | Updates test override to isEnvRegionSet() |
| plugins/s3-vfs/core/src/test/java/org/pentaho/s3common/S3CommonFileSystemTestUtil.java | Updates Mockito stub to isEnvRegionSet() |
| plugins/s3-vfs/core/src/test/java/org/pentaho/s3/vfs/S3FileSystemTest.java | Updates test override to isEnvRegionSet() |
| plugins/s3-vfs/core/src/main/java/org/pentaho/s3common/S3Options.java | Adds centralized parsing/defaulting for S3 options (new file) |
| plugins/s3-vfs/core/src/main/java/org/pentaho/s3common/S3CommonFileSystemConfigBuilder.java | Promotes config keys to public constants; removes Minio-region-specific config |
| plugins/s3-vfs/core/src/main/java/org/pentaho/s3common/S3CommonFileSystem.java | Refactors client creation around S3Options; renames env region detection method |
| plugins/s3-vfs/core/src/main/java/org/pentaho/amazon/s3/provider/S3Provider.java | Refactors provider to reuse common client creation (now via S3Options) |
| plugins/s3-vfs/core/src/main/java/org/pentaho/amazon/s3/S3Details.java | Removes minioRegion storage; centralizes property keys |
| plugins/s3-vfs/core/src/main/java/org/pentaho/amazon/s3/S3DetailComposite.java | Syncs Minio region widget into details.region; updates validation/population |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| public AmazonS3 getS3Client( S3Details s3Details ) throws KettleException { | ||
| VariableSpace space = getSpace( s3Details ); | ||
| return getAmazonS3( s3Details, space ); | ||
| return S3CommonFileSystem.createClientFromEndpoint( S3Options.from( cfgBuilder ) ); |
There was a problem hiding this comment.
getS3Client() always builds the client via S3CommonFileSystem.createClientFromEndpoint(...), even when no custom endpoint is configured (the normal AWS case). If endpoint is null/blank, AwsClientBuilder.EndpointConfiguration will be constructed with an invalid endpoint and can fail at runtime; it also bypasses the non-endpoint client path (region handling, env region override, etc.). Consider branching on whether an endpoint is configured (or exposing a shared helper in S3CommonFileSystem to build either endpoint-based or standard clients) instead of always forcing the endpoint builder here.
| return S3CommonFileSystem.createClientFromEndpoint( S3Options.from( cfgBuilder ) ); | |
| S3Options options = S3Options.from( cfgBuilder ); | |
| String endpoint = options.getEndpoint(); | |
| if ( endpoint != null && !endpoint.trim().isEmpty() ) { | |
| return S3CommonFileSystem.createClientFromEndpoint( options ); | |
| } | |
| return S3CommonFileSystem.createClient( options ); |
| public AmazonS3 getS3Client( S3Details s3Details ) throws KettleException { | ||
| var opts = getOpts( s3Details ); | ||
| var cfgBuilder = new S3CommonFileSystemConfigBuilder( opts ); | ||
|
|
There was a problem hiding this comment.
getS3Client() no longer honors s3Details.getAuthType() when selecting credentials; S3Options.from(cfgBuilder) will prefer access/secret keys if they are present, even if the user selected "Credentials File" (stale keys can remain in the details when switching auth types). This can cause the connection test/listing to authenticate with the wrong mechanism. Consider clearing the non-selected credential fields based on authType before building S3Options, or extend S3Options to include an explicit auth mode and select the credentials provider accordingly.
There was a problem hiding this comment.
which will be consistent with how the code is handled when the filesystem is created, where authType isn't passed
| @@ -55,8 +72,6 @@ public class S3Details extends BaseVFSConnectionDetails { | |||
|
|
|||
| @MetaStoreAttribute private String region; | |||
|
|
|||
There was a problem hiding this comment.
By removing the MetaStoreAttribute-backed minioRegion field, existing saved Minio/HCP connections that only populated that attribute may load with region == null after upgrade (losing the previously configured signing region). If backward compatibility is required, consider adding a migration path (e.g., reading the legacy attribute/property and mapping it into region on load) so older metastore entries continue to work without user intervention.
| // Legacy field retained for backward compatibility with existing Minio/HCP | |
| // connections that stored the signing region as "minioRegion" in the metastore. | |
| @MetaStoreAttribute private String minioRegion; |
There was a problem hiding this comment.
that wasn't in released code
| private static String getRegion( String val ) { | ||
| if ( StringUtils.isBlank( val ) ) { | ||
| log.debug( "No region set, using default {}", Regions.DEFAULT_REGION.getName() ); | ||
| return Regions.DEFAULT_REGION.getName(); | ||
| } |
There was a problem hiding this comment.
S3Options adds new parsing/defaulting behavior (e.g., default region fallback and pathStyleAccess defaulting) but there are no unit tests validating these behaviors. Consider adding focused tests for S3Options.from(Map) / from(S3CommonFileSystemConfigBuilder) around blank/null inputs and Minio vs AWS scenarios to prevent regressions in client construction.
This comment has been minimized.
This comment has been minimized.
5a8cae6 to
0cb4ece
Compare
Note:Frogbot also supports Contextual Analysis, Secret Detection, IaC and SAST Vulnerabilities Scanning. This features are included as part of the JFrog Advanced Security package, which isn't enabled on your system. |
✅ Build finished in 33m 55sBuild command: mvn clean verify -B -e -Daudit -Djs.no.sandbox -pl plugins/s3-vfs/core👌 All tests passed! Tests run: 124, Failures: 0, Skipped: 0 Test Results ℹ️ This is an automatic message |


No description provided.