Skip to content
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

Merged
merged 7 commits into from
Feb 6, 2019
Merged

GCS OAuth token #124

merged 7 commits into from
Feb 6, 2019

Conversation

luohao
Copy link
Member

@luohao luohao commented Jan 31, 2019

This PR adds connector token support in Presto. and GCS module in Hive Connectors.

  • ea2df20..1b7d68c: allow client to pass connector tokens to connector
  • fedc801: add dynamic configuration provider
  • c661834: add HiveGcsModule to support OAuth token authentication with Google Cloud Storage

supersedes #94

@dain @electrum

@cla-bot cla-bot bot added the cla-signed label Jan 31, 2019
Copy link
Member

@electrum electrum left a 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.

@@ -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";
Copy link
Member

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

@luohao
Copy link
Member Author

luohao commented Feb 4, 2019

@electrum Thanks for the review. I updated the commit to address your comments.

I had a really hard time picking names (have used credential, connector-credential and connector-token during the development)... I think ExtraCredential is a better name.

I also updated the naming related to *ConfigurationInitializer and *ConfigurationProvider.

Copy link
Member

@kokosing kokosing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skimmed

@@ -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";
Copy link
Member

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?

Copy link
Member

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 :)

Copy link
Member

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.

Copy link
Member

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.

pom.xml Show resolved Hide resolved
}

@Override
public void refresh()
Copy link
Member

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

@@ -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";
Copy link
Member

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.

for (ClientExtraCredentials credential : credentials) {
builder.put(credential.getName(), credential.getValue());
}
return builder.build();
Copy link
Member

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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

requireNonNull(extraCredentials,...);

Copy link
Member Author

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.

Copy link
Member

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.

{
this(config, ignored -> {});
}

@Inject
public HdfsConfigurationUpdater(HiveClientConfig config, S3ConfigurationUpdater s3ConfigurationUpdater)
public HdfsConfigurationInitializer(HiveClientConfig config, S3ConfigurationUpdater s3ConfigurationUpdater)
Copy link
Member

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?

Copy link
Member

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.

Copy link
Member

@electrum electrum left a 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


public ClientExtraCredentials(String extraCredentials)
{
List<String> nameValue = NAME_VALUE_SPLITTER.splitToList(extraCredentials);
Copy link
Member

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.

Copy link
Member

@electrum electrum left a 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-docs/src/main/sphinx/installation/jdbc.rst Outdated Show resolved Hide resolved

public interface DynamicConfigurationProvider
{
Configuration updateConfiguration(Configuration configuration, HdfsContext context, URI uri);
Copy link
Member

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).

Copy link
Member Author

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.

pom.xml Show resolved Hide resolved
@electrum electrum merged commit 50224b3 into trinodb:master Feb 6, 2019
wenleix added a commit to wenleix/presto that referenced this pull request Oct 15, 2019
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.
wenleix added a commit to wenleix/presto that referenced this pull request Oct 17, 2019
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.
wenleix added a commit to prestodb/presto that referenced this pull request Oct 17, 2019
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.
kaikalur pushed a commit to kaikalur/presto that referenced this pull request Jan 22, 2020
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.
rice668 pushed a commit to rice668/trino that referenced this pull request Jan 31, 2023
rice668 pushed a commit to rice668/trino that referenced this pull request Jul 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

4 participants