[repository-s3] remove endpointOverride and let AWS SDK V2 S3 determine the s3 url based on bucket name or arn provided#20345
Conversation
…ne the s3 url based on bucket name or arn provided Signed-off-by: Craig Perkins <cwperx@amazon.com>
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the 📝 WalkthroughWalkthroughThis PR refactors S3 endpoint override handling in the repository-s3 plugin to conditionally apply explicit endpoint configurations while allowing AWS SDK V2 to dynamically determine S3 URLs based on bucket names or ARNs when no override is specified. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
Comment |
Signed-off-by: Craig Perkins <cwperx@amazon.com>
Signed-off-by: Craig Perkins <cwperx@amazon.com>
|
❌ Gradle check result for cdcb47e: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #20345 +/- ##
============================================
- Coverage 73.33% 73.33% -0.01%
+ Complexity 72004 71970 -34
============================================
Files 5793 5793
Lines 329110 329114 +4
Branches 47402 47400 -2
============================================
- Hits 241364 241354 -10
- Misses 68394 68402 +8
- Partials 19352 19358 +6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
plugins/repository-s3/src/main/java/org/opensearch/repositories/s3/S3Service.java (1)
259-263: Consider validating for unexpected URI schemes.The current logic prepends the protocol only when http:// or https:// is not present. If a user accidentally provides an endpoint with a different scheme (e.g., "s3://..."), it would result in "https://s3://..." which is invalid.
While S3 endpoints should always be HTTP(S) URLs, consider adding validation to reject endpoints with non-HTTP schemes upfront for clearer error messages.
🔎 Proposed enhancement
String endpoint = clientSettings.endpoint; +// Check for unexpected schemes before processing +if (endpoint.contains("://") && !endpoint.startsWith("http://") && !endpoint.startsWith("https://")) { + throw new IllegalArgumentException("Invalid endpoint scheme. S3 endpoints must use http:// or https://, but got: " + endpoint); +} if ((endpoint.startsWith("http://") || endpoint.startsWith("https://")) == false) { // Manually add the schema to the endpoint to work around https://github.com/aws/aws-sdk-java/issues/2274 // TODO: Remove this once fixed in the AWS SDK endpoint = clientSettings.protocol.toString() + "://" + endpoint; }
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
CHANGELOG.mdplugins/repository-s3/src/main/java/org/opensearch/repositories/s3/S3Service.javaplugins/repository-s3/src/test/java/org/opensearch/repositories/s3/S3ArnEndpointResolutionTests.javaplugins/repository-s3/src/test/java/org/opensearch/repositories/s3/S3ServiceTests.java
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-12-12T18:40:08.452Z
Learnt from: reta
Repo: opensearch-project/OpenSearch PR: 20017
File: plugins/transport-reactor-netty4/src/test/java/org/opensearch/http/reactor/netty4/ssl/SecureReactorNetty4HttpServerTransportTests.java:256-256
Timestamp: 2025-12-12T18:40:08.452Z
Learning: In the OpenSearch ReactorNetty4 secure HTTP transport tests (plugins/transport-reactor-netty4/src/test/java/org/opensearch/http/reactor/netty4/ssl/SecureReactorNetty4HttpServerTransportTests.java), URI limit validation has been moved from the protocol layer to the transport layer, making it protocol-agnostic. The random protocol selection in ReactorHttpClient.https(settings) is intentional to ensure all tests validate correct behavior across HTTP/1.1, HTTP/2, and HTTP/3.
Applied to files:
plugins/repository-s3/src/test/java/org/opensearch/repositories/s3/S3ArnEndpointResolutionTests.javaplugins/repository-s3/src/test/java/org/opensearch/repositories/s3/S3ServiceTests.java
🔇 Additional comments (13)
CHANGELOG.md (1)
28-28: LGTM!The changelog entry accurately documents the change and follows the correct format.
plugins/repository-s3/src/main/java/org/opensearch/repositories/s3/S3Service.java (2)
98-98: LGTM!The Optional import is necessary for the new endpoint resolution method.
225-228: LGTM!The conditional endpoint override application correctly preserves dynamic SDK resolution for ARN-based buckets while still supporting explicit endpoint configuration for S3-compatible services.
plugins/repository-s3/src/test/java/org/opensearch/repositories/s3/S3ServiceTests.java (4)
39-41: LGTM!The imports are necessary for the new test methods.
89-101: LGTM!The test correctly verifies that no endpoint override is returned when the endpoint setting is absent.
103-119: LGTM!The test correctly verifies scheme addition. The comment appropriately documents the assumption about the default protocol.
121-130: LGTM!The test correctly verifies that explicit schemes are preserved, which is essential for S3-compatible services like MinIO.
plugins/repository-s3/src/test/java/org/opensearch/repositories/s3/S3ArnEndpointResolutionTests.java (6)
29-40: LGTM!The class documentation clearly explains the no-network testing strategy, and the dummy credentials are appropriate for endpoint resolution tests.
44-71: LGTM!The CapturingInterceptor correctly extracts the endpoint URI and signing service name from the AWS Signature V4 Authorization header. The parsing logic accurately targets the service name in the credential scope.
73-104: LGTM!The helper methods effectively implement the no-network testing strategy. The failing HTTP client ensures tests verify endpoint resolution logic without making actual network calls.
108-140: LGTM!The test correctly verifies that the AWS SDK resolves Outposts ARN buckets to s3-outposts endpoints and uses the correct signing service. The comment on line 126 appropriately emphasizes not setting endpointOverride to ensure testing SDK behavior.
142-167: LGTM!The test correctly verifies AWS SDK resolution for Access Point ARNs and validates that access points use the standard "s3" signing service (unlike Outposts which use "s3-outposts").
169-195: LGTM!The test correctly verifies that regular bucket names resolve to standard S3 endpoints. The defensive assertions (checking what the endpoint is NOT) make the test resilient to SDK version differences and regional variations.
plugins/repository-s3/src/main/java/org/opensearch/repositories/s3/S3Service.java
Show resolved
Hide resolved
Signed-off-by: Craig Perkins <cwperx@amazon.com>
|
@ashking94 @reta @andrross wdyt of the changes in this PR? I see we have another similar PR open to address a similar issue: #20386 |
|
❌ Gradle check result for 139d818: null Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
plugins/repository-s3/src/main/java/org/opensearch/repositories/s3/S3Service.java
Show resolved
Hide resolved
plugins/repository-s3/src/main/java/org/opensearch/repositories/s3/S3Service.java
Show resolved
Hide resolved
Thanks @cwperks , I think the change looks reasonable, thank you. If few minor comments, plus we may need to update the documentation for S3 plugin to highlight new resolution strategy (and document the fallback to use |
plugins/repository-s3/src/main/java/org/opensearch/repositories/s3/S3Service.java
Show resolved
Hide resolved
…penSearch into repository-s3-outposts
Signed-off-by: Craig Perkins <cwperx@amazon.com>
|
❌ Gradle check result for 8096a37: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
|
❌ Gradle check result for 8096a37: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
…ne the s3 url based on bucket name or arn provided (opensearch-project#20345) * [repository-s3] remove endpointOverride and let AWS SDK V2 S3 determine the s3 url based on bucket name or arn provided Signed-off-by: Craig Perkins <cwperx@amazon.com> * Prove correct signing service by extracting header Signed-off-by: Craig Perkins <cwperx@amazon.com> * Add to CHANGELOG Signed-off-by: Craig Perkins <cwperx@amazon.com> * Also apply to S3AsyncService Signed-off-by: Craig Perkins <cwperx@amazon.com> --------- Signed-off-by: Craig Perkins <cwperx@amazon.com>
…ne the s3 url based on bucket name or arn provided (opensearch-project#20345) * [repository-s3] remove endpointOverride and let AWS SDK V2 S3 determine the s3 url based on bucket name or arn provided Signed-off-by: Craig Perkins <cwperx@amazon.com> * Prove correct signing service by extracting header Signed-off-by: Craig Perkins <cwperx@amazon.com> * Add to CHANGELOG Signed-off-by: Craig Perkins <cwperx@amazon.com> * Also apply to S3AsyncService Signed-off-by: Craig Perkins <cwperx@amazon.com> --------- Signed-off-by: Craig Perkins <cwperx@amazon.com>
Description
This PR removes the hardcoding of endpointOverride in the repository-s3 plugin and delegating this to the AWS SDK based on the bucket provided (arn or not).
Here are some examples of creating a snapshot repository:
Standard Bucket (No ARN, name of the bucket + region)
Access Point ARN:
S3 Outposts access point ARN as bucket
S3 compatible endpoint (contains endpoint override)
Related Issues
Attempt to resolve:
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.
Summary by CodeRabbit
Bug Fixes
Tests
✏️ Tip: You can customize this high-level summary in your review settings.