Skip to content

Commit 2286e6b

Browse files
ignore spark.driver.host in yarn-cluster mode
1 parent 5f13759 commit 2286e6b

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

core/src/main/scala/org/apache/spark/SparkContext.scala

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,6 @@ class SparkContext(config: SparkConf) extends SparkStatusAPI with Logging {
175175
logInfo("Spark configuration:\n" + conf.toDebugString)
176176
}
177177

178-
// Set Spark driver host and port system properties
179-
conf.setIfMissing("spark.driver.host", Utils.localHostName())
180-
conf.setIfMissing("spark.driver.port", "0")
181-
182178
val jars: Seq[String] =
183179
conf.getOption("spark.jars").map(_.split(",")).map(_.filter(_.size != 0)).toSeq.flatten
184180

@@ -206,6 +202,14 @@ class SparkContext(config: SparkConf) extends SparkStatusAPI with Logging {
206202

207203
if (master == "yarn-client") System.setProperty("SPARK_YARN_MODE", "true")
208204

205+
// Set Spark driver host and port system properties. Ignore host setting in yarn-cluster mode.
206+
if (master == "yarn-cluster") {
207+
conf.set("spark.driver.host", Utils.localHostName())
208+
} else {
209+
conf.setIfMissing("spark.driver.host", Utils.localHostName())
210+
}
211+
conf.setIfMissing("spark.driver.port", "0")
212+
209213
// An asynchronous listener bus for Spark events
210214
private[spark] val listenerBus = new LiveListenerBus
211215

0 commit comments

Comments
 (0)