-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Changes to enable ssl/tls in hms #24745
Conversation
|
93d3e50
to
237591e
Compare
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.
2e8df56
to
cf2e4dc
Compare
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 of formatting in the Metastore Configuration Properties table.
dd36298
to
a62601e
Compare
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.
Just one nit of formatting in the text, looks good other than that. Thanks for the quick turnaround!
9ebeb22
to
577afe2
Compare
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.
LGTM! (docs)
Pull updated branch, new local doc build, looks good.
Thanks for the doc!
private File metastoreTlsKeystorePath; | ||
private String metastoreTlsKeystorePassword; | ||
private File metastoreTlsTruststorePath; | ||
private String metastoreTlsTruststorePassword; |
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.
Since these are already metastore configs, I think we can shorten these variable and call it like in other SSL enabled class -
private boolean tlsEnabled;
private File keystorePath;
private String keystorePassword;
private File truststorePath;
private String trustStorePassword;
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.
@agrawalreetika Changed as per the suggestion. Please check
* @param metastoreTrustStorePassword | ||
* @return SSLContext | ||
*/ | ||
private static Optional<SSLContext> metastoreSslContext(boolean metastoreTlsEnabled, Optional<File> metastoreKeyStorePath, Optional<String> metastoreKeyStorePassword, Optional<File> metastoreTrustStorePath, Optional<String> metastoreTrustStorePassword) |
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 can call this method something like - buildSslContext
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.
@agrawalreetika Changed as per the suggestion. Please check
*/ | ||
private static Optional<SSLContext> metastoreSslContext(boolean metastoreTlsEnabled, Optional<File> metastoreKeyStorePath, Optional<String> metastoreKeyStorePassword, Optional<File> metastoreTrustStorePath, Optional<String> metastoreTrustStorePassword) | ||
{ | ||
if (!metastoreTlsEnabled || (!metastoreKeyStorePath.isPresent() && !metastoreTrustStorePath.isPresent())) { |
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 think we can simply this here -
if (!metastoreTlsEnabled || (!metastoreKeyStorePath.isPresent() && !metastoreTrustStorePath.isPresent())) { | |
if (!metastoreTlsEnabled || (metastoreKeyStorePath.isEmpty() && metastoreTrustStorePath.isEmpty()) { | |
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.
@agrawalreetika Optional#isEmpty() is a Java 11 method. Not available in java 8
// get X509TrustManager | ||
final TrustManager[] trustManagers = trustManagerFactory.getTrustManagers(); | ||
if (trustManagers.length != 1 || !(trustManagers[0] instanceof X509TrustManager)) { | ||
throw new RuntimeException("Unexpected default trust managers:" + Arrays.toString(trustManagers)); |
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 could be more clear here based on the condition here -
throw new RuntimeException("Unexpected default trust managers:" + Arrays.toString(trustManagers)); | |
throw new RuntimeException("Expected exactly one X509TrustManager, but found: " + Arrays.toString(trustManagers)); | |
; |
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.
@agrawalreetika Changed as per the suggestion. Please check
testTable)); | ||
computeActual(format("INSERT INTO %s values(1, 'TestName1')", testTable)); | ||
computeActual(format("INSERT INTO %s values(1, 'TestName2')", testTable)); | ||
assertQuery(format("SELECT count(*) FROM %s", testTable), "SELECT 2"); |
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.
Add one more assert for checking the expected SELECT *
values from a table
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.
@agrawalreetika added assert for select * also
computeActual(format("INSERT INTO %s values(1, 'TestName1')", testTable)); | ||
computeActual(format("INSERT INTO %s values(1, 'TestName2')", testTable)); | ||
assertQuery(format("SELECT count(*) FROM %s", testTable), "SELECT 2"); | ||
} |
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 could add some more combinations of test and provide different combination of sslConfigurations
in queryRunner -
- When just truststore is set
- When just keystore is set
- When both truststore + keystore is set
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.
@agrawalreetika added test cases with all the above mentioned connfigurations
2bb324a
to
49127b4
Compare
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.
LGTM, Thanks for adding the support
Please plan to squash your commits into one with relevant commit message.
d92d49d
to
e794b25
Compare
Done |
@@ -232,7 +232,17 @@ Property Name Descriptio | |||
``hive.invalidate-metastore-cache-procedure-enabled`` When enabled, users will be able to invalidate metastore false | |||
cache on demand. | |||
|
|||
======================================================= ============================================================= ============ | |||
``hive.metastore.thrift.client.tls.enabled`` Whether TLS security is enabled. false |
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.
The release notes shall show these property names. E.g. "Add a configuration property plan-checker.config-dir to set the configuration directory for PlanCheckerProvider configurations. #23955"
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.
@yingsu00 Updated release notes with newly added properties
@@ -232,7 +232,17 @@ Property Name Descriptio | |||
``hive.invalidate-metastore-cache-procedure-enabled`` When enabled, users will be able to invalidate metastore false | |||
cache on demand. | |||
|
|||
======================================================= ============================================================= ============ | |||
``hive.metastore.thrift.client.tls.enabled`` Whether TLS security is enabled. false |
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.
Why are they all dot separated?
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 think we can follow the similar config naming like other connectors with TLS configs -
https://prestodb.io/docs/current/connector/elasticsearch.html#tls-security
.keystore.path
-> .keystore-path
.keystore.password
-> .keystore-password
.truststore.path
-> .truststore-path
.truststore.password
-> .truststore-password
WDYT @yingsu00?
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.
@agrawalreetika @yingsu00 existing properties specified in below format
hive.metastore-thrift-client-tls-enabled
Can we follow the same ?
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.
@agrawalreetika @yingsu00 existing properties specified in below format
hive.metastore-thrift-client-tls-enabled
Can we follow the same ?
Please see my comments inline.
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.
@yingsu00 Changed as per the suggestion
@@ -49,12 +72,138 @@ public HiveMetastoreClientFactory( | |||
@Inject | |||
public HiveMetastoreClientFactory(MetastoreClientConfig metastoreClientConfig, HiveMetastoreAuthentication metastoreAuthentication) | |||
{ | |||
this(Optional.empty(), Optional.ofNullable(metastoreClientConfig.getMetastoreSocksProxy()), metastoreClientConfig.getMetastoreTimeout(), metastoreAuthentication); | |||
this(buildSslContext(metastoreClientConfig.isTlsEnabled(), Optional.ofNullable(metastoreClientConfig.getKeystorePath()), Optional.ofNullable(metastoreClientConfig.getKeystorePassword()), Optional.ofNullable(metastoreClientConfig.getTruststorePath()), Optional.ofNullable(metastoreClientConfig.getTrustStorePassword())), Optional.ofNullable(metastoreClientConfig.getMetastoreSocksProxy()), metastoreClientConfig.getMetastoreTimeout(), metastoreAuthentication); |
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.
Line too long. Put each parameter on a separate line
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.
@yingsu00 Updated it by adding parameters in separate lines
* @param trustStorePassword | ||
* @return SSLContext | ||
*/ | ||
private static Optional<SSLContext> buildSslContext(boolean tlsEnabled, Optional<File> keystorePath, Optional<String> keystorePassword, Optional<File> truststorePath, Optional<String> trustStorePassword) |
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.
Line too long. Put each parameter on a separate line
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.
@yingsu00 Updated it by adding parameters in separate lines
@@ -317,4 +324,60 @@ public MetastoreClientConfig setInvalidateMetastoreCacheProcedureEnabled(boolean | |||
this.invalidateMetastoreCacheProcedureEnabled = invalidateMetastoreCacheProcedureEnabled; | |||
return this; | |||
} | |||
|
|||
@Config("hive.metastore.thrift.client.tls.enabled") |
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.
these config properties are specific to the thrift metastore, and they are all used by com/facebook/presto/hive/metastore/thrift/HiveMetastoreClientFactory.java. I think we should create a separate config class under com/facebook/presto/hive/metastore/thrift/. We can name it as ThriftHiveMetastoreConfig.java. All config properties in it shall start with hive.metastore.thrift
.
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'd suggest we name these new config properties prefix in ThriftHiveMetastoreConfig.java hive.metastore.thrift.client.tls.xxx
. e.g.
hive.metastore.thrift.client.tls.enabled
hive.metastore.thrift.client.tls.keystore-path
"hive.metastore.thrift.client.tls.keystore-password
...
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.
@yingsu00 created a separate class 'ThriftHiveMetastoreConfig' and moved all the ssl related properties to that
private String keystorePassword; | ||
private File truststorePath; | ||
private String trustStorePassword; | ||
|
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 comment is for line 64-74
Move it to the new com/facebook/presto/hive/metastore/thrift/ThriftHiveMetastoreConfig.java
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.
@yingsu00 when checked i could see that moving this field require changes in many files. Can we do that as a seperate follow-up PR?
cc : @agrawalreetika @imjalpreet
public String getTrustStorePassword() | ||
{ | ||
return trustStorePassword; | ||
} |
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 comment is for line 302 to 314
Move "hive.metastore.thrift.delete-files-on-table-drop" to the new com/facebook/presto/hive/metastore/thrift/ThriftHiveMetastoreConfig.java
I'm not sure if this is only for the thrift client? If it is then it's better to rename it to "hive.metastore.thrift.client.delete-files-on-table-drop" and deprecate "hive.metastore.thrift.delete-files-on-table-drop". I think it is not. @imjalpreet Could you please confirm?
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, we can move this to the ThriftHiveMetastoreConfig
. The config is only valid when Thrift Hive Metastore is used as the metastore in Hive connector due to a limitation observed a few years back: #17369
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.
@yingsu00 when checked i could see that moving this field require changes in many files. Can we do that as a seperate follow-up PR?
cc : @agrawalreetika @imjalpreet
@bibith4 can you fix the CLA check? also the failing test |
64e2a10
to
bcc1294
Compare
Co-authored-by: Arin Mathew <[email protected]> Changes to move ssl related properties to seperate class
60d92c5
to
693c872
Compare
@ethanyzhang Corrected. Please check |
Thanks for the release note entry! Some suggestions for formatting and to follow the Order of changes in the Release Notes Guidelines:
|
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.
LGTM! (docs)
Pull branch, local doc build. Thanks!
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.
The release note should only have Hive Connector changes. Could you please move them? Also cc @steveburnett for a second round of the release note section review
@yingsu00 changed release note as per suggestion. @steveburnett Can you please verify |
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.
Code changes, LGTM
Yes, verified. Thank you! |
@bibith4 Could you please squash the 3 bullet points of the release notes into one? The second bullet point can be removed. |
Description
Added SSL/TLS support for hive metastore
Impact
The connection to HMS will be encrypted with TLS for secure communication.
Test Plan
Executed basic queries after enabling TLS in HMS.

Queries got executed successfully.
Contributor checklist
Release Notes
Please follow release notes guidelines and fill in the release notes below.