You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by gu...@apache.org on 2022/08/10 02:42:36 UTC

[spark] branch master updated: [SPARK-39559][CORE][FOLLOWUP] Use INADDR_ANY and IN6ADDR_ANY in WebUI

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

gurwls223 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/master by this push:
     new 5cdbf1e5064 [SPARK-39559][CORE][FOLLOWUP] Use INADDR_ANY and IN6ADDR_ANY in WebUI
5cdbf1e5064 is described below

commit 5cdbf1e50644b402381f439cc81485d6656ffe62
Author: Dongjoon Hyun <do...@apache.org>
AuthorDate: Wed Aug 10 11:42:25 2022 +0900

    [SPARK-39559][CORE][FOLLOWUP] Use INADDR_ANY and IN6ADDR_ANY in WebUI
    
    ### What changes were proposed in this pull request?
    
    This is a partial revert of SPARK-39559 which used `localHostNameForURI` to get `hostName`.
    This PR aims to use INADDR_ANY back on IPv4 and IN6ADDR_ANY on IPv6.
    
    ### Why are the changes needed?
    
    Although `localHostNameForURI` works for both IPv4 and IPv6, K8s `port-forward` assumes local loop back address like `127.0.0.1` or `[::1]` instead of PodIP.
    ```
    $ k port-forward pi 4040
    Forwarding from 127.0.0.1:4040 -> 4040
    Forwarding from [::1]:4040 -> 4040
    ```
    
    ### Does this PR introduce _any_ user-facing change?
    
    No.
    
    ### How was this patch tested?
    
    Pass the CIs.
    
    Closes #37456 from dongjoon-hyun/SPARK-39559.
    
    Authored-by: Dongjoon Hyun <do...@apache.org>
    Signed-off-by: Hyukjin Kwon <gu...@apache.org>
---
 core/src/main/scala/org/apache/spark/ui/WebUI.scala | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/core/src/main/scala/org/apache/spark/ui/WebUI.scala b/core/src/main/scala/org/apache/spark/ui/WebUI.scala
index 2b96016476e..b3c8ddb44c4 100644
--- a/core/src/main/scala/org/apache/spark/ui/WebUI.scala
+++ b/core/src/main/scala/org/apache/spark/ui/WebUI.scala
@@ -140,7 +140,8 @@ private[spark] abstract class WebUI(
   def initialize(): Unit
 
   def initServer(): ServerInfo = {
-    val hostName = Utils.localHostNameForURI()
+    val hostName = Option(conf.getenv("SPARK_LOCAL_IP"))
+        .getOrElse(if (Utils.preferIPv6) "[::]" else "0.0.0.0")
     val server = startJettyServer(hostName, port, sslOptions, conf, name, poolSize)
     server
   }
@@ -152,7 +153,9 @@ private[spark] abstract class WebUI(
       val server = initServer()
       handlers.foreach(server.addHandler(_, securityManager))
       serverInfo = Some(server)
-      logInfo(s"Bound $className to ${Utils.localHostNameForURI()}, and started at $webUrl")
+      val hostName = Option(conf.getenv("SPARK_LOCAL_IP"))
+          .getOrElse(if (Utils.preferIPv6) "[::]" else "0.0.0.0")
+      logInfo(s"Bound $className to $hostName, and started at $webUrl")
     } catch {
       case e: Exception =>
         logError(s"Failed to bind $className", e)


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org