You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2021/04/12 04:29:57 UTC

[GitHub] [spark] HyukjinKwon commented on a change in pull request #32126: [WIP][SPARK-35002][YARN][TESTS][FOLLOW-UP] Fix java.net.BindException in MiniYARNCluster

HyukjinKwon commented on a change in pull request #32126:
URL: https://github.com/apache/spark/pull/32126#discussion_r611320198



##########
File path: resource-managers/yarn/src/test/scala/org/apache/spark/deploy/yarn/BaseYarnClusterSuite.scala
##########
@@ -90,9 +90,31 @@ abstract class BaseYarnClusterSuite
     yarnConf.set("yarn.scheduler.capacity.root.default.acl_administer_queue", "*")
     yarnConf.setInt("yarn.scheduler.capacity.node-locality-delay", -1)
 
-    yarnCluster = new MiniYARNCluster(getClass().getName(), 1, 1, 1)
-    yarnCluster.init(yarnConf)
-    yarnCluster.start()
+    try {
+      yarnCluster = new MiniYARNCluster(getClass().getName(), 1, 1, 1)
+      yarnCluster.init(yarnConf)
+      yarnCluster.start()
+    } catch {
+      case _: java.net.BindException =>
+        // When InetAddress.getLocalHost returns a wrong address, see also SPARK-35002.
+        val original = System.getSecurityManager
+        System.setSecurityManager(new java.lang.SecurityManager() {
+          override def checkConnect(host: String, port: Int): Unit = {
+            if (host != "localhost" || host != "127.0.0.1") {
+              // Reject all hosts except loopback.
+              throw new SecurityException("Loopback only allowed")

Review comment:
       This forces `InetAddress.getLocalHost` to return the loopback address.




-- 
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



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