Skip to content

Commit ecde5b8

Browse files
Marcelo Vanzintgravescs
authored andcommitted
[SPARK-2080] Yarn: report HS URL in client mode, correct user in cluster mode.
Yarn client mode was not setting the app's tracking URL to the History Server's URL when configured by the user. Now client mode behaves the same as cluster mode. In SparkContext.scala, the "user.name" system property had precedence over the SPARK_USER environment variable. This means that SPARK_USER was never used, since "user.name" is always set by the JVM. In Yarn cluster mode, this means the application always reported itself as being run by user "yarn" (or whatever user was running the Yarn NM). One could argue that the correct fix would be to use UGI.getCurrentUser() here, but at least for Yarn that will match what SPARK_USER is set to. Author: Marcelo Vanzin <[email protected]> This patch had conflicts when merged, resolved by Committer: Thomas Graves <[email protected]> Closes #1002 from vanzin/yarn-client-url and squashes the following commits: 4046e04 [Marcelo Vanzin] Set HS link in yarn-alpha also. 4c692d9 [Marcelo Vanzin] Yarn: report HS URL in client mode, correct user in cluster mode.
1 parent 83c226d commit ecde5b8

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ class SparkContext(config: SparkConf) extends Logging {
297297

298298
// Set SPARK_USER for user who is running SparkContext.
299299
val sparkUser = Option {
300-
Option(System.getProperty("user.name")).getOrElse(System.getenv("SPARK_USER"))
300+
Option(System.getenv("SPARK_USER")).getOrElse(System.getProperty("user.name"))
301301
}.getOrElse {
302302
SparkContext.SPARK_UNKNOWN_USER
303303
}

yarn/alpha/src/main/scala/org/apache/spark/deploy/yarn/ExecutorLauncher.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ class ExecutorLauncher(args: ApplicationMasterArguments, conf: Configuration, sp
271271
.asInstanceOf[FinishApplicationMasterRequest]
272272
finishReq.setAppAttemptId(appAttemptId)
273273
finishReq.setFinishApplicationStatus(status)
274+
finishReq.setTrackingUrl(sparkConf.get("spark.yarn.historyServer.address", ""))
274275
resourceManager.finishApplicationMaster(finishReq)
275276
}
276277

yarn/stable/src/main/scala/org/apache/spark/deploy/yarn/ExecutorLauncher.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ class ExecutorLauncher(args: ApplicationMasterArguments, conf: Configuration, sp
115115
val interval = math.min(timeoutInterval / 2, schedulerInterval)
116116

117117
reporterThread = launchReporterThread(interval)
118-
118+
119119

120120
// Wait for the reporter thread to Finish.
121121
reporterThread.join()
@@ -134,12 +134,12 @@ class ExecutorLauncher(args: ApplicationMasterArguments, conf: Configuration, sp
134134
// LOCAL_DIRS => 2.X, YARN_LOCAL_DIRS => 0.23.X
135135
val localDirs = Option(System.getenv("YARN_LOCAL_DIRS"))
136136
.orElse(Option(System.getenv("LOCAL_DIRS")))
137-
137+
138138
localDirs match {
139139
case None => throw new Exception("Yarn Local dirs can't be empty")
140140
case Some(l) => l
141141
}
142-
}
142+
}
143143

144144
private def registerApplicationMaster(): RegisterApplicationMasterResponse = {
145145
logInfo("Registering the ApplicationMaster")

0 commit comments

Comments
 (0)