-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
AWS: Fix Catalog URI within VendedCredentialsProvider #12612
Merged
nastra
merged 19 commits into
apache:main
from
wolflex888:vended-credentials-provider-uri
Apr 1, 2025
Merged
Changes from 11 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
b240283
correct URI in VendedCredentialsProvider
589d1a8
fix uri within VendedCredentialsProvider
065c331
spotless
240e607
pass in all properties and resolve endpoint in vended credentials
63e8c63
spotless
7e1fece
modify tests
050fd91
add missing condition check
6a86de7
add checks in invalidOrMissingUrl
5fa5ea9
add catalog uri check
2b72dd0
Merge branch 'main' into vended-credentials-provider-uri
b9e2fb5
spotless
4deddbd
fix tests
9b16f2d
spotless
e6be4c4
remove restutil resolve endpoint
f0804eb
fix catalog uri errors in aws client properties test
ee6929b
fix tests
28f218b
fix endpoint tests
1ddd6f2
Apply suggestions from code review
nastra ab59591
Update AwsClientPropertiesTest.java
nastra File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,11 +24,13 @@ | |
import java.util.Map; | ||
import java.util.Optional; | ||
import java.util.stream.Collectors; | ||
import org.apache.iceberg.CatalogProperties; | ||
import org.apache.iceberg.relocated.com.google.common.base.Preconditions; | ||
import org.apache.iceberg.relocated.com.google.common.base.Strings; | ||
import org.apache.iceberg.rest.ErrorHandlers; | ||
import org.apache.iceberg.rest.HTTPClient; | ||
import org.apache.iceberg.rest.RESTClient; | ||
import org.apache.iceberg.rest.RESTUtil; | ||
import org.apache.iceberg.rest.auth.AuthManager; | ||
import org.apache.iceberg.rest.auth.AuthManagers; | ||
import org.apache.iceberg.rest.auth.AuthSession; | ||
|
@@ -47,17 +49,23 @@ public class VendedCredentialsProvider implements AwsCredentialsProvider, SdkAut | |
private volatile HTTPClient client; | ||
private final Map<String, String> properties; | ||
private final CachedSupplier<AwsCredentials> credentialCache; | ||
private final String catalogEndpoint; | ||
private final String credentialsEndpoint; | ||
private AuthManager authManager; | ||
private AuthSession authSession; | ||
|
||
private VendedCredentialsProvider(Map<String, String> properties) { | ||
Preconditions.checkArgument(null != properties, "Invalid properties: null"); | ||
Preconditions.checkArgument(null != properties.get(URI), "Invalid URI: null"); | ||
Preconditions.checkArgument(null != properties.get(URI), "Invalid credentials endpoint: null"); | ||
Preconditions.checkArgument( | ||
null != properties.get(CatalogProperties.URI), "Invalid catalog endpoint: null"); | ||
this.properties = properties; | ||
this.credentialCache = | ||
CachedSupplier.builder(() -> credentialFromProperties().orElseGet(this::refreshCredential)) | ||
.cachedValueName(VendedCredentialsProvider.class.getName()) | ||
.build(); | ||
this.catalogEndpoint = properties.get(CatalogProperties.URI); | ||
this.credentialsEndpoint = RESTUtil.resolveEndpoint(catalogEndpoint, properties.get(URI)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is already being done in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is corrected. |
||
} | ||
|
||
@Override | ||
|
@@ -82,7 +90,7 @@ private RESTClient httpClient() { | |
synchronized (this) { | ||
if (null == client) { | ||
authManager = AuthManagers.loadAuthManager("s3-credentials-refresh", properties); | ||
HTTPClient httpClient = HTTPClient.builder(properties).uri(properties.get(URI)).build(); | ||
HTTPClient httpClient = HTTPClient.builder(properties).uri(catalogEndpoint).build(); | ||
authSession = authManager.catalogSession(httpClient, properties); | ||
client = httpClient.withAuthSession(authSession); | ||
} | ||
|
@@ -95,7 +103,7 @@ private RESTClient httpClient() { | |
private LoadCredentialsResponse fetchCredentials() { | ||
return httpClient() | ||
.get( | ||
properties.get(URI), | ||
credentialsEndpoint, | ||
null, | ||
LoadCredentialsResponse.class, | ||
Map.of(), | ||
|
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you please update
Preconditions.checkArgument(null != properties.get(URI), "Invalid URI: null");
toPreconditions.checkArgument(null != properties.get(URI), "Invalid credentials endpoint: null");
and also addPreconditions.checkArgument(null != properties.get(CatalogProperties.URI), "Invalid catalog endpoint: null");
.Please also update
invalidOrMissingUri()
and add a check where the catalog URI isn't provided