-
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
Changes from 3 commits
b240283
589d1a8
065c331
240e607
63e8c63
7e1fece
050fd91
6a86de7
5fa5ea9
2b72dd0
b9e2fb5
4deddbd
9b16f2d
e6be4c4
f0804eb
ee6929b
28f218b
1ddd6f2
ab59591
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -199,7 +199,9 @@ public AwsCredentialsProvider credentialsProvider( | |
String accessKeyId, String secretAccessKey, String sessionToken) { | ||
if (refreshCredentialsEnabled && !Strings.isNullOrEmpty(refreshCredentialsEndpoint)) { | ||
clientCredentialsProviderProperties.put( | ||
VendedCredentialsProvider.URI, refreshCredentialsEndpoint); | ||
VendedCredentialsProvider.CREDENTIALS_ENDPOINT, refreshCredentialsEndpoint); | ||
clientCredentialsProviderProperties.put( | ||
VendedCredentialsProvider.URI, allProperties.get(CatalogProperties.URI)); | ||
Optional.ofNullable(allProperties.get(OAuth2Properties.TOKEN)) | ||
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. Tangential question: here we are transferring the But what about the other auth properties? I'm especially concerned about The same could be said of properties like The only way currently to pass an auth server URL to the provider would be to "wrap" it in a property like 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. I agree, in hindsight it's probably better to just pass all properties to the credentialsprovider. Could you please update it to
|
||
.ifPresent( | ||
token -> | ||
|
Original file line number | Diff line number | Diff line change | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -24,7 +24,7 @@ | ||||||||||||||||
import java.util.Map; | |||||||||||||||||
import java.util.Optional; | |||||||||||||||||
import java.util.stream.Collectors; | |||||||||||||||||
import org.apache.iceberg.relocated.com.google.common.base.Preconditions; | |||||||||||||||||
import org.apache.hadoop.util.Preconditions; | |||||||||||||||||
import org.apache.iceberg.relocated.com.google.common.base.Strings; | |||||||||||||||||
import org.apache.iceberg.rest.ErrorHandlers; | |||||||||||||||||
import org.apache.iceberg.rest.HTTPClient; | |||||||||||||||||
|
@@ -43,7 +43,8 @@ | ||||||||||||||||
import software.amazon.awssdk.utils.cache.RefreshResult; | |||||||||||||||||
|
|||||||||||||||||
public class VendedCredentialsProvider implements AwsCredentialsProvider, SdkAutoCloseable { | |||||||||||||||||
public static final String URI = "credentials.uri"; | |||||||||||||||||
public static final String URI = "credentials.catalog.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. instead of renaming this and introducing another property, we can do it also like this:
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. can you also please update the tests to
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. sounds good. 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. @wolflex888 I don't see this being applied to the tests. Can you please update the tests so that we can get this merged? |
|||||||||||||||||
public static final String CREDENTIALS_ENDPOINT = "credentials.endpoint"; | |||||||||||||||||
private volatile HTTPClient client; | |||||||||||||||||
private final Map<String, String> properties; | |||||||||||||||||
private final CachedSupplier<AwsCredentials> credentialCache; | |||||||||||||||||
|
@@ -53,6 +54,8 @@ public class VendedCredentialsProvider implements AwsCredentialsProvider, SdkAut | ||||||||||||||||
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(CREDENTIALS_ENDPOINT), "Invalid endpoint: null"); | |||||||||||||||||
this.properties = properties; | |||||||||||||||||
this.credentialCache = | |||||||||||||||||
CachedSupplier.builder(() -> credentialFromProperties().orElseGet(this::refreshCredential)) | |||||||||||||||||
|
@@ -95,7 +98,7 @@ private RESTClient httpClient() { | ||||||||||||||||
private LoadCredentialsResponse fetchCredentials() { | |||||||||||||||||
return httpClient() | |||||||||||||||||
.get( | |||||||||||||||||
properties.get(URI), | |||||||||||||||||
properties.get(CREDENTIALS_ENDPOINT), | |||||||||||||||||
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. I agree we need two properties. But the problem, as I see it, is that this property, even with the changes in this PR, is currently an absolute URL that was computed in this.refreshCredentialsEndpoint =
RESTUtil.resolveEndpoint(
properties.get(CatalogProperties.URI), properties.get(REFRESH_CREDENTIALS_ENDPOINT)); But I think this property must be a relative path instead. this.refreshCredentialsEndpoint = properties.get(REFRESH_CREDENTIALS_ENDPOINT); In that case we would have the following properties:
The HTTP client then must be constructed with 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. see my other comment above. we don't need two properties as we can just pass the catalog URI via
The absolute/relative path handling is already done in iceberg/aws/src/main/java/org/apache/iceberg/aws/AwsClientProperties.java Lines 109 to 111 in 7d0395d
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. Right, but my point was: why bother absolutizing |
|||||||||||||||||
null, | |||||||||||||||||
LoadCredentialsResponse.class, | |||||||||||||||||
Map.of(), | |||||||||||||||||
|
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.
rather than introducing/renaming the existing property, we could just do