-
Notifications
You must be signed in to change notification settings - Fork 3k
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
GCS OAuth token #124
GCS OAuth token #124
Conversation
presto-hive/src/main/java/io/prestosql/plugin/hive/gcs/GcsAccessTokenUpdater.java
Outdated
Show resolved
Hide resolved
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.
I am still reviewing the GCS commit, but adding initial comments now, mostly around naming. The overall design and code looks good.
presto-spi/src/main/java/io/prestosql/spi/security/ConnectorIdentity.java
Outdated
Show resolved
Hide resolved
presto-spi/src/main/java/io/prestosql/spi/security/ConnectorIdentity.java
Outdated
Show resolved
Hide resolved
presto-spi/src/main/java/io/prestosql/spi/security/Identity.java
Outdated
Show resolved
Hide resolved
@@ -50,5 +50,7 @@ | |||
public static final String PRESTO_PAGE_NEXT_TOKEN = "X-Presto-Page-End-Sequence-Id"; | |||
public static final String PRESTO_BUFFER_COMPLETE = "X-Presto-Buffer-Complete"; | |||
|
|||
public static final String PRESTO_CONNECTOR_TOKEN = "X-Presto-Connector-Token"; |
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.
We need to figure out a better name here. Maybe one of
X-Presto-Credential
X-Presto-Extra-Credential
X-Presto-User-Credential
presto-jdbc/src/test/java/io/prestosql/jdbc/TestPrestoDriverUri.java
Outdated
Show resolved
Hide resolved
presto-hive/src/main/java/io/prestosql/plugin/hive/HdfsConfigurationStaticUpdater.java
Outdated
Show resolved
Hide resolved
presto-hive/src/main/java/io/prestosql/plugin/hive/DynamicConfigurationUpdater.java
Outdated
Show resolved
Hide resolved
presto-hive/src/main/java/io/prestosql/plugin/hive/DynamicConfigurationUpdater.java
Outdated
Show resolved
Hide resolved
presto-hive/src/main/java/io/prestosql/plugin/hive/HiveClientModule.java
Outdated
Show resolved
Hide resolved
presto-hive/src/main/java/io/prestosql/plugin/hive/HiveHdfsConfiguration.java
Outdated
Show resolved
Hide resolved
@electrum Thanks for the review. I updated the commit to address your comments. I had a really hard time picking names (have used I also updated the naming related to |
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.
Skimmed
presto-spi/src/main/java/io/prestosql/spi/security/ConnectorIdentity.java
Outdated
Show resolved
Hide resolved
presto-spi/src/main/java/io/prestosql/spi/security/ConnectorIdentity.java
Outdated
Show resolved
Hide resolved
presto-spi/src/main/java/io/prestosql/spi/security/Identity.java
Outdated
Show resolved
Hide resolved
@@ -50,5 +50,7 @@ | |||
public static final String PRESTO_PAGE_NEXT_TOKEN = "X-Presto-Page-End-Sequence-Id"; | |||
public static final String PRESTO_BUFFER_COMPLETE = "X-Presto-Buffer-Complete"; | |||
|
|||
public static final String PRESTO_EXTRA_CREDENTIAL = "X-Presto-Extra-Credential"; |
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.
what is going to happen when client does not support this header and header is not empty?
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.
This is a header sent from clients. If they don't support it then they won't send it :)
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.
I would name it to PRESTO_CLIENT_EXTRA_CREDENTIAL
then.
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.
We don't do that for any other headers. For example, X-Presto-User
is how clients specify the username.
Please move the constant up to be after PRESTO_RESOURCE_ESTIMATE
.
presto-main/src/main/java/io/prestosql/server/HttpRequestSessionContext.java
Show resolved
Hide resolved
presto-hive/src/main/java/io/prestosql/plugin/hive/HiveClientModule.java
Show resolved
Hide resolved
presto-geospatial/src/test/java/io/prestosql/plugin/geospatial/TestSpatialJoins.java
Show resolved
Hide resolved
presto-hive/src/main/java/io/prestosql/plugin/hive/gcs/HiveGcsConfig.java
Show resolved
Hide resolved
presto-hive/src/main/java/io/prestosql/plugin/hive/gcs/GasConfigurationInitializer.java
Outdated
Show resolved
Hide resolved
presto-main/src/main/java/io/prestosql/server/HttpRequestSessionContext.java
Show resolved
Hide resolved
presto-jdbc/src/main/java/io/prestosql/jdbc/PrestoConnection.java
Outdated
Show resolved
Hide resolved
presto-hive/src/main/java/io/prestosql/plugin/hive/gcs/GasConfigurationInitializer.java
Outdated
Show resolved
Hide resolved
presto-hive/src/main/java/io/prestosql/plugin/hive/gcs/GasConfigurationInitializer.java
Outdated
Show resolved
Hide resolved
presto-hive/src/main/java/io/prestosql/plugin/hive/HdfsConfigurationInitializer.java
Outdated
Show resolved
Hide resolved
presto-hive/src/main/java/io/prestosql/plugin/hive/gcs/PrestoGasConfigInitializer.java
Outdated
Show resolved
Hide resolved
presto-hive/src/main/java/io/prestosql/plugin/hive/gcs/PrestoGasConfigInitializer.java
Outdated
Show resolved
Hide resolved
presto-hive/src/main/java/io/prestosql/plugin/hive/gcs/PrestoGasConfigInitializer.java
Outdated
Show resolved
Hide resolved
} | ||
|
||
@Override | ||
public void refresh() |
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.
This can be
public void refresh() {}
Since the implementation doesn't throw
presto-hive/src/main/java/io/prestosql/plugin/hive/gcs/GcsAccessTokenProvider.java
Outdated
Show resolved
Hide resolved
presto-hive/src/main/java/io/prestosql/plugin/hive/gcs/GcsAccessTokenProvider.java
Outdated
Show resolved
Hide resolved
presto-hive/src/main/java/io/prestosql/plugin/hive/gcs/GcsConfigurationProvider.java
Outdated
Show resolved
Hide resolved
@@ -50,5 +50,7 @@ | |||
public static final String PRESTO_PAGE_NEXT_TOKEN = "X-Presto-Page-End-Sequence-Id"; | |||
public static final String PRESTO_BUFFER_COMPLETE = "X-Presto-Buffer-Complete"; | |||
|
|||
public static final String PRESTO_EXTRA_CREDENTIAL = "X-Presto-Extra-Credential"; |
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.
I would name it to PRESTO_CLIENT_EXTRA_CREDENTIAL
then.
presto-main/src/main/java/io/prestosql/server/HttpRequestSessionContext.java
Show resolved
Hide resolved
presto-main/src/main/java/io/prestosql/server/TaskUpdateRequest.java
Outdated
Show resolved
Hide resolved
for (ClientExtraCredentials credential : credentials) { | ||
builder.put(credential.getName(), credential.getValue()); | ||
} | ||
return builder.build(); |
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.
I would also change other methods here (as separate commit or PR). Up to you.
|
||
public ClientExtraCredentials(String extraCredentials) | ||
{ | ||
List<String> nameValue = NAME_VALUE_SPLITTER.splitToList(extraCredentials); |
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.
requireNonNull(extraCredentials,...);
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.
@electrum is this guaranteed to be non-null? ClientSessionProperty
and ClientResourceEstimate
doesn't perform this check. I vaguely remember the constructor is called only we pass some non-null string via the options, but don't remember where the related code resides.
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.
Yes, the Airline framework calls the constructor to convert the string argument into an object, so it wouldn't make sense for it to pass a null.
Also, the null check isn't required anyway, since we are immediately using the value and thus the constructor would throw NPE. The normal reason to check for nulls in a constructor is fail immediately (maintain invariants) rather than at some point in the future when you won't know where the null came from.
presto-hive/src/main/java/io/prestosql/plugin/hive/HdfsConfigurationInitializer.java
Show resolved
Hide resolved
presto-hive/src/main/java/io/prestosql/plugin/hive/DynamicConfigurationProvider.java
Outdated
Show resolved
Hide resolved
{ | ||
this(config, ignored -> {}); | ||
} | ||
|
||
@Inject | ||
public HdfsConfigurationUpdater(HiveClientConfig config, S3ConfigurationUpdater s3ConfigurationUpdater) | ||
public HdfsConfigurationInitializer(HiveClientConfig config, S3ConfigurationUpdater s3ConfigurationUpdater) |
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.
Should S3ConfigurationUpdater
become a DynamicConfigurationProvider
?
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.
I thought about that as well, but it has complications, so let's defer that.
presto-hive/src/main/java/io/prestosql/plugin/hive/HiveHdfsConfiguration.java
Outdated
Show resolved
Hide resolved
presto-hive/src/main/java/io/prestosql/plugin/hive/HiveHdfsConfiguration.java
Show resolved
Hide resolved
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.
Nit: capitalize "CLI" in commit message
presto-cli/src/test/java/io/prestosql/cli/TestClientOptions.java
Outdated
Show resolved
Hide resolved
|
||
public ClientExtraCredentials(String extraCredentials) | ||
{ | ||
List<String> nameValue = NAME_VALUE_SPLITTER.splitToList(extraCredentials); |
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.
Yes, the Airline framework calls the constructor to convert the string argument into an object, so it wouldn't make sense for it to pass a null.
Also, the null check isn't required anyway, since we are immediately using the value and thus the constructor would throw NPE. The normal reason to check for nulls in a constructor is fail immediately (maintain invariants) rather than at some point in the future when you won't know where the null came from.
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.
A few minor comments, otherwise this looks ready to merge
presto-main/src/main/java/io/prestosql/server/HttpRequestSessionContext.java
Show resolved
Hide resolved
presto-main/src/main/java/io/prestosql/server/HttpRequestSessionContext.java
Outdated
Show resolved
Hide resolved
presto-main/src/test/java/io/prestosql/server/TestHttpRequestSessionContext.java
Outdated
Show resolved
Hide resolved
|
||
public interface DynamicConfigurationProvider | ||
{ | ||
Configuration updateConfiguration(Configuration configuration, HdfsContext context, URI uri); |
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.
Please remove the return type. It isn't used and the semantics of it are not clear (since the method is supposed to update the passed in configuration object).
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.
This was fixed, but the change is in the Rename
commit by mistake. I moved it to the commit where I introduce DynamicConfigurationProvider
.
presto-hive/src/main/java/io/prestosql/plugin/hive/HiveHdfsConfiguration.java
Outdated
Show resolved
Hide resolved
presto-hive/src/main/java/io/prestosql/plugin/hive/gcs/GcsConfigurationProvider.java
Outdated
Show resolved
Hide resolved
presto-hive/src/main/java/io/prestosql/plugin/hive/gcs/GoogleGcsConfigurationInitializer.java
Outdated
Show resolved
Hide resolved
presto-main/src/main/java/io/prestosql/server/HttpRequestSessionContext.java
Outdated
Show resolved
Hide resolved
presto-jdbc/src/main/java/io/prestosql/jdbc/ConnectionProperties.java
Outdated
Show resolved
Hide resolved
When trinodb/trino#124 is backported in prestodb#13196, the following artifacts are removed: - com.google.cloud.bigdataoss:util - com.google.cloud.bigdataoss:gcsio This is because at that time PrestoDB depends on Airbase 88 with maven-dependency-plugin 2.1. This maven-dependency-plugin is upgraded to 3.1.1 in Airbase 90, and will complain if these two artifacts are not added.
When trinodb/trino#124 is backported in prestodb#13196, the following artifacts are removed: - com.google.cloud.bigdataoss:util - com.google.cloud.bigdataoss:gcsio This is because at that time PrestoDB depends on Airbase 88 with maven-dependency-plugin 2.1. This maven-dependency-plugin is upgraded to 3.1.1 in Airbase 90, and will complain if these two artifacts are not added.
When trinodb/trino#124 is backported in #13196, the following artifacts are removed: - com.google.cloud.bigdataoss:util - com.google.cloud.bigdataoss:gcsio This is because at that time PrestoDB depends on Airbase 88 with maven-dependency-plugin 2.1. This maven-dependency-plugin is upgraded to 3.1.1 in Airbase 90, and will complain if these two artifacts are not added.
When trinodb/trino#124 is backported in prestodb#13196, the following artifacts are removed: - com.google.cloud.bigdataoss:util - com.google.cloud.bigdataoss:gcsio This is because at that time PrestoDB depends on Airbase 88 with maven-dependency-plugin 2.1. This maven-dependency-plugin is upgraded to 3.1.1 in Airbase 90, and will complain if these two artifacts are not added.
This PR adds connector token support in Presto. and GCS module in Hive Connectors.
supersedes #94
@dain @electrum