You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kyuubi.apache.org by fe...@apache.org on 2022/06/28 13:54:14 UTC

[incubator-kyuubi] branch master updated: [KYUUBI #2957] [SUB-TASK][KPIP-4] Use canonical host name for kyuubi instance

This is an automated email from the ASF dual-hosted git repository.

feiwang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-kyuubi.git


The following commit(s) were added to refs/heads/master by this push:
     new defae6bdf [KYUUBI #2957] [SUB-TASK][KPIP-4] Use canonical host name for kyuubi instance
defae6bdf is described below

commit defae6bdf6382917102da1ff3b51992b4c9ef0ea
Author: Fei Wang <fw...@ebay.com>
AuthorDate: Tue Jun 28 21:54:07 2022 +0800

    [KYUUBI #2957] [SUB-TASK][KPIP-4] Use canonical host name for kyuubi instance
    
    ### _Why are the changes needed?_
    
    We have to use canonical host name as kyuubi instance, otherwise, the ip is always change after pod restart, and the kyuubi instance can not get recovered.
    ### _How was this patch tested?_
    - [ ] Add some test cases that check the changes thoroughly including negative and positive cases if possible
    
    - [ ] Add screenshots for manual tests if appropriate
    
    - [x] [Run test](https://kyuubi.apache.org/docs/latest/develop_tools/testing.html#running-tests) locally before make a pull request
    
    Closes #2957 from turboFei/kyuubi_instance_url.
    
    Closes #2957
    
    ac8d9df4 [Fei Wang] respect FRONTEND_CONNECTION_URL_USE_HOSTNAME
    c4dcd7d3 [Fei Wang] use getCanonicalHostName for EmbeddedZookeeper
    c183b41f [Fei Wang] use getCanonicalHostName for TFrontendService
    59f3c0a6 [Fei Wang] Use getCanonicalHostName
    
    Authored-by: Fei Wang <fw...@ebay.com>
    Signed-off-by: Fei Wang <fw...@ebay.com>
---
 .../main/scala/org/apache/kyuubi/service/TFrontendService.scala   | 2 +-
 .../org/apache/kyuubi/server/KyuubiRestFrontendService.scala      | 8 +++++++-
 .../scala/org/apache/kyuubi/zookeeper/EmbeddedZookeeper.scala     | 2 +-
 3 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/kyuubi-common/src/main/scala/org/apache/kyuubi/service/TFrontendService.scala b/kyuubi-common/src/main/scala/org/apache/kyuubi/service/TFrontendService.scala
index 31de60080..c34fe8099 100644
--- a/kyuubi-common/src/main/scala/org/apache/kyuubi/service/TFrontendService.scala
+++ b/kyuubi-common/src/main/scala/org/apache/kyuubi/service/TFrontendService.scala
@@ -114,7 +114,7 @@ abstract class TFrontendService(name: String)
     val host = serverHost match {
       case Some(h) => h // respect user's setting ahead
       case None if conf.get(FRONTEND_CONNECTION_URL_USE_HOSTNAME) =>
-        serverAddr.getHostName
+        serverAddr.getCanonicalHostName
       case None =>
         serverAddr.getHostAddress
     }
diff --git a/kyuubi-server/src/main/scala/org/apache/kyuubi/server/KyuubiRestFrontendService.scala b/kyuubi-server/src/main/scala/org/apache/kyuubi/server/KyuubiRestFrontendService.scala
index 8da83a726..ae73206c0 100644
--- a/kyuubi-server/src/main/scala/org/apache/kyuubi/server/KyuubiRestFrontendService.scala
+++ b/kyuubi-server/src/main/scala/org/apache/kyuubi/server/KyuubiRestFrontendService.scala
@@ -56,7 +56,13 @@ class KyuubiRestFrontendService(override val serverable: Serverable)
 
   override def initialize(conf: KyuubiConf): Unit = synchronized {
     val host = conf.get(FRONTEND_REST_BIND_HOST)
-      .getOrElse(Utils.findLocalInetAddress.getHostAddress)
+      .getOrElse {
+        if (conf.get(KyuubiConf.FRONTEND_CONNECTION_URL_USE_HOSTNAME)) {
+          Utils.findLocalInetAddress.getCanonicalHostName
+        } else {
+          Utils.findLocalInetAddress.getHostAddress
+        }
+      }
     server = JettyServer(getName, host, conf.get(FRONTEND_REST_BIND_PORT))
     super.initialize(conf)
   }
diff --git a/kyuubi-zookeeper/src/main/scala/org/apache/kyuubi/zookeeper/EmbeddedZookeeper.scala b/kyuubi-zookeeper/src/main/scala/org/apache/kyuubi/zookeeper/EmbeddedZookeeper.scala
index 72d65e8e0..0e980132a 100644
--- a/kyuubi-zookeeper/src/main/scala/org/apache/kyuubi/zookeeper/EmbeddedZookeeper.scala
+++ b/kyuubi-zookeeper/src/main/scala/org/apache/kyuubi/zookeeper/EmbeddedZookeeper.scala
@@ -43,7 +43,7 @@ class EmbeddedZookeeper extends AbstractService("EmbeddedZookeeper") {
     val maxClientCnxns = conf.get(ZK_MAX_CLIENT_CONNECTIONS)
     val minSessionTimeout = conf.get(ZK_MIN_SESSION_TIMEOUT)
     val maxSessionTimeout = conf.get(ZK_MAX_SESSION_TIMEOUT)
-    host = conf.get(ZK_CLIENT_PORT_ADDRESS).getOrElse(findLocalInetAddress.getHostName)
+    host = conf.get(ZK_CLIENT_PORT_ADDRESS).getOrElse(findLocalInetAddress.getCanonicalHostName)
 
     zks = new ZooKeeperServer(dataDirectory, dataDirectory, tickTime)
     zks.setMinSessionTimeout(minSessionTimeout)