You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@zookeeper.apache.org by GitBox <gi...@apache.org> on 2021/03/16 16:17:51 UTC

[GitHub] [zookeeper] aihuaxu opened a new pull request #1643: ZOOKEEPER-4250: Resolve zookeeper quorum from DNS entry.

aihuaxu opened a new pull request #1643:
URL: https://github.com/apache/zookeeper/pull/1643


   This is to support resolving configured DNS entry to the list of quorum hosts.  It will resolve the DNS into multiple ip addresses and then reverse lookup the host names from the ip addresses. The host name is needed in secured cluster for Kerberos authentication.
   
   To use this feature, the client needs to:
   1. create ZKClientConfig to set 'zookeeper.quorum.resolve-needed' to true
   2. create ZooKeeper from the constructor with provided ZKClientConfig
   
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [zookeeper] muse-dev[bot] commented on a change in pull request #1643: ZOOKEEPER-4250: Resolve zookeeper quorum from DNS entry.

Posted by GitBox <gi...@apache.org>.
muse-dev[bot] commented on a change in pull request #1643:
URL: https://github.com/apache/zookeeper/pull/1643#discussion_r595342699



##########
File path: zookeeper-server/src/main/java/org/apache/zookeeper/ZooKeeper.java
##########
@@ -655,6 +676,39 @@ public ZooKeeper(
         cnxn.start();
     }
 
+    /**
+     * Resolve configured zookeeper quorum DNS into the quorum string if necessary.
+     * Otherwise, the original quorum is returned.
+     *
+     * @param zkHostPort    zookeeper quorum string or DNS string
+     * @return The zookeeper quorum string
+     * @throws IOException If there are issues resolving the addresses.
+     */
+    private String resolveQuorumIfNecessary(String zkHostPort)
+            throws UnknownHostException {
+        if (zkHostPort == null || !this.resolveQuorumNeeded) {
+            // Early return is no resolve is necessary
+            return zkHostPort;
+        }
+
+        // decide whether to access server by IP or by host name
+        // If the address needs to be resolved, get all of the IP addresses
+        // from this address and pass them into the proxy
+        LOG.info(String.format("Zookeeper quorum will be resolved with %s",
+                resolver.getClass().getName()));
+
+        List<String> resolvedHosts = new ArrayList<>();
+        ConnectStringParser parser = new ConnectStringParser(zkHostPort);
+        for (InetSocketAddress address : parser.getServerAddresses()) {

Review comment:
       *NULL_DEREFERENCE:*  object returned by `getServerAddresses(parser)` could be null and is dereferenced at line 702.
   (at-me [in a reply](https://docs.muse.dev/docs/talk-to-muse/) with `help` or `ignore`)




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [zookeeper] aihuaxu commented on a change in pull request #1643: ZOOKEEPER-4250: Resolve zookeeper quorum from DNS entry.

Posted by GitBox <gi...@apache.org>.
aihuaxu commented on a change in pull request #1643:
URL: https://github.com/apache/zookeeper/pull/1643#discussion_r599154190



##########
File path: zookeeper-server/src/main/java/org/apache/zookeeper/ZooKeeper.java
##########
@@ -655,6 +676,39 @@ public ZooKeeper(
         cnxn.start();
     }
 
+    /**
+     * Resolve configured zookeeper quorum DNS into the quorum string if necessary.
+     * Otherwise, the original quorum is returned.
+     *
+     * @param zkHostPort    zookeeper quorum string or DNS string
+     * @return The zookeeper quorum string
+     * @throws IOException If there are issues resolving the addresses.
+     */
+    private String resolveQuorumIfNecessary(String zkHostPort)
+            throws UnknownHostException {
+        if (zkHostPort == null || !this.resolveQuorumNeeded) {
+            // Early return is no resolve is necessary
+            return zkHostPort;
+        }
+
+        // decide whether to access server by IP or by host name
+        // If the address needs to be resolved, get all of the IP addresses
+        // from this address and pass them into the proxy
+        LOG.info(String.format("Zookeeper quorum will be resolved with %s",
+                resolver.getClass().getName()));
+
+        List<String> resolvedHosts = new ArrayList<>();
+        ConnectStringParser parser = new ConnectStringParser(zkHostPort);
+        for (InetSocketAddress address : parser.getServerAddresses()) {

Review comment:
       Actually it won't be null since it's always initialized in ConnectStringParser. 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org