-
Notifications
You must be signed in to change notification settings - Fork 443
TEZ-4749: Support SSL/TLS connections to ZooKeeper in ZkAMRegistry and ZkAMRegistryClient #532
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
Open
g3rg0
wants to merge
8
commits into
apache:master
Choose a base branch
from
g3rg0:TEZ-4749
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
3ab0a9c
TEZ-4749: Support SSL/TLS connections to ZooKeeper in ZkAMRegistry an…
aeca114
TEZ-4749: Fix checkstyle violations in ZkConfig
011bcbb
TEZ-4749: Fix checkstyle violations in TestZkAMRegistryClient
f14f7df
TEZ-4749: Exclude ZkConfig.isSslEnabled from NP_BOOLEAN_RETURN_NULL f…
0a9b41c
TEZ-4749: Use Optional<Boolean> for ZkConfig.isSslEnabled() instead o…
9a58d60
TEZ-4749: Use Curator 5.x native zkClientConfig() instead of custom Z…
993662c
TEZ-4749: Remove redundant version tag from curator-test dependency
53723a5
TEZ-4749: Refactor SSL store config in createCuratorFramework()
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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -19,9 +19,13 @@ | |
| package org.apache.tez.client.registry.zookeeper; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
| import static org.junit.jupiter.api.Assertions.assertFalse; | ||
| import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
| import static org.junit.jupiter.api.Assertions.assertNull; | ||
| import static org.junit.jupiter.api.Assertions.assertThrows; | ||
| import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
|
||
| import java.util.Optional; | ||
| import java.util.concurrent.TimeUnit; | ||
|
|
||
| import org.apache.curator.RetryPolicy; | ||
|
|
@@ -231,4 +235,73 @@ public void testDefaultNamespace() { | |
| assertEquals("/tez-external-sessions" + TezConfiguration.TEZ_AM_REGISTRY_NAMESPACE_DEFAULT, | ||
| zkConfig.getZkNamespace()); | ||
| } | ||
|
|
||
| @Test | ||
| public void testZkConfigTezAmZookeeperSslEnableNotSpecified() { | ||
| Configuration conf = new Configuration(); | ||
| conf.set(TezConfiguration.TEZ_AM_ZOOKEEPER_QUORUM, "dummyZkQuorum"); | ||
| ZkConfig zkConf = new ZkConfig(conf); | ||
|
|
||
| assertEquals(Optional.empty(), zkConf.isSslEnabled()); | ||
| assertNull(zkConf.getZookeeperKeyStoreLocation()); | ||
| assertNull(zkConf.getZookeeperKeyStorePassword()); | ||
| assertNull(zkConf.getZookeeperTrustStoreLocation()); | ||
| assertNull(zkConf.getZookeeperTrustStorePassword()); | ||
| } | ||
|
|
||
| @Test | ||
| public void testZkConfigTezAmZookeeperSslEnableEmpty() { | ||
| Configuration conf = new Configuration(); | ||
| conf.set(TezConfiguration.TEZ_AM_ZOOKEEPER_QUORUM, "dummyZkQuorum"); | ||
| conf.set(TezConfiguration.TEZ_AM_ZOOKEEPER_SSL_ENABLE, ""); // empty means not set | ||
| ZkConfig zkConf = new ZkConfig(conf); | ||
|
|
||
| assertEquals(Optional.empty(), zkConf.isSslEnabled()); | ||
| assertNull(zkConf.getZookeeperKeyStoreLocation()); | ||
| assertNull(zkConf.getZookeeperKeyStorePassword()); | ||
| assertNull(zkConf.getZookeeperTrustStoreLocation()); | ||
| assertNull(zkConf.getZookeeperTrustStorePassword()); | ||
| } | ||
|
|
||
| @Test | ||
| public void testZkConfigSslEnabled() { | ||
| Configuration conf = new Configuration(); | ||
| conf.set(TezConfiguration.TEZ_AM_ZOOKEEPER_QUORUM, "dummyZkQuorum"); | ||
| conf.set(TezConfiguration.TEZ_AM_ZOOKEEPER_SSL_ENABLE, "true"); | ||
| conf.set(TezConfiguration.TEZ_AM_ZOOKEEPER_SSL_KEYSTORE_LOCATION, "/keystore.jks"); | ||
| conf.set(TezConfiguration.TEZ_AM_ZOOKEEPER_SSL_KEYSTORE_PASSWORD, "secret"); | ||
| conf.set(TezConfiguration.TEZ_AM_ZOOKEEPER_SSL_TRUSTSTORE_LOCATION, "/truststore.jks"); | ||
| conf.set(TezConfiguration.TEZ_AM_ZOOKEEPER_SSL_TRUSTSTORE_PASSWORD, "changeit"); | ||
| ZkConfig zkConf = new ZkConfig(conf); | ||
|
|
||
| assertTrue(zkConf.isSslEnabled().isPresent()); | ||
| assertTrue(zkConf.isSslEnabled().get()); | ||
| assertEquals(zkConf.getZookeeperKeyStoreLocation(), "/keystore.jks"); | ||
| assertEquals(zkConf.getZookeeperKeyStorePassword(), "secret"); | ||
| assertEquals(zkConf.getZookeeperTrustStoreLocation(), "/truststore.jks"); | ||
| assertEquals(zkConf.getZookeeperTrustStorePassword(), "changeit"); | ||
| } | ||
|
|
||
| @Test | ||
| public void testZkConfigSslDisabled() { | ||
| Configuration conf = new Configuration(); | ||
| conf.set(TezConfiguration.TEZ_AM_ZOOKEEPER_QUORUM, "dummyZkQuorum"); | ||
| conf.set(TezConfiguration.TEZ_AM_ZOOKEEPER_SSL_ENABLE, "False"); | ||
|
Contributor
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. "False" looks strange, even if it's by design, I would keep using "false", and create a separate test case to show valid values |
||
| ZkConfig zkConf = new ZkConfig(conf); | ||
|
|
||
| assertTrue(zkConf.isSslEnabled().isPresent()); | ||
| assertFalse(zkConf.isSslEnabled().get()); | ||
| assertNull(zkConf.getZookeeperKeyStoreLocation()); | ||
| assertNull(zkConf.getZookeeperKeyStorePassword()); | ||
| assertNull(zkConf.getZookeeperTrustStoreLocation()); | ||
| assertNull(zkConf.getZookeeperTrustStorePassword()); | ||
| } | ||
|
|
||
| @Test | ||
| public void testZkConfigAmZookeeperSslEnableInvalid() { | ||
| Configuration conf = new Configuration(); | ||
| conf.set(TezConfiguration.TEZ_AM_ZOOKEEPER_QUORUM, "dummyZkQuorum"); | ||
| conf.set(TezConfiguration.TEZ_AM_ZOOKEEPER_SSL_ENABLE, "invalidValue"); | ||
| assertThrows(IllegalArgumentException.class, () -> new ZkConfig(conf)); | ||
| } | ||
| } | ||
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
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.
Why not use the built-in
.zkClientConfig()method provided by Curator 5.x? It provides native support for managing these SSL properties.SSLZookeeperFactory.javacan we entirely removed and just configure it inline insideZkConfig.javalike this: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.
Makes sense. I've added a commit that removed
SSLZookeeperFactory.javaand uses the build-in curator config.