Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SPARK-4253]Ignore spark.driver.host in yarn-cluster and standalone-cluster mode #3112

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions core/src/main/scala/org/apache/spark/SparkContext.scala
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,6 @@ class SparkContext(config: SparkConf) extends SparkStatusAPI with Logging {
logInfo("Spark configuration:\n" + conf.toDebugString)
}

// Set Spark driver host and port system properties
conf.setIfMissing("spark.driver.host", Utils.localHostName())
conf.setIfMissing("spark.driver.port", "0")

val jars: Seq[String] =
conf.getOption("spark.jars").map(_.split(",")).map(_.filter(_.size != 0)).toSeq.flatten

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

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

// Set Spark driver host and port system properties. Ignore host setting in yarn-cluster mode.
if (master.contains("cluster")) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Substring search seems like a dangerous / brittle way to detect whether we're running in a cluster deployment mode, since it's plausible that a user might have a master hostname which also contains 'cluster', e.g. "spark://testcluster".

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact, we even have a local-cluster mode that would be broken by this.

It looks like yarn uses yarn-cluster, so we can probably perform exact matching on that string.

conf.set("spark.driver.host", Utils.localHostName())
} else {
conf.setIfMissing("spark.driver.host", Utils.localHostName())
}
conf.setIfMissing("spark.driver.port", "0")

// An asynchronous listener bus for Spark events
private[spark] val listenerBus = new LiveListenerBus

Expand Down
8 changes: 8 additions & 0 deletions core/src/main/scala/org/apache/spark/deploy/Client.scala
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,14 @@ object Client {
}
conf.set("spark.akka.askTimeout", "10")
conf.set("akka.loglevel", driverArgs.logLevel.toString.replace("WARN", "WARNING"))

// Set the web ui port to be ephemeral so we don't conflict with other spark processes
// running on the same box
conf.set("spark.ui.port", "0")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this change? We already have logic that tries to bind to a higher-numbered port if the desired port is unavailable.


// Set the master property to match the requested mode.
conf.set("spark.master", "standalone-cluster")

Logger.getRootLogger.setLevel(driverArgs.logLevel)

val (actorSystem, _) = AkkaUtils.createActorSystem(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class ApplicationMasterArguments(val args: Array[String]) {

var args = inputArgs

while (! args.isEmpty) {
while (!args.isEmpty) {
// --num-workers, --worker-memory, and --worker-cores are deprecated since 1.0,
// the properties with executor in their names are preferred.
args match {
Expand Down