Skip to content

Commit

Permalink
[SPARK-21124][UI] Show correct application user in UI.
Browse files Browse the repository at this point in the history
The jobs page currently shows the application user, but it assumes
the OS user is the same as the user running the application, which
may not be true in all scenarios (e.g., kerberos). While it might be
useful to show both in the UI, this change just chooses the application
user over the OS user, since the latter can be found in the environment
page if needed.

Tested in live application and in history server.

Author: Marcelo Vanzin <vanzin@cloudera.com>

Closes #18331 from vanzin/SPARK-21124.
  • Loading branch information
Marcelo Vanzin committed Jun 19, 2017
1 parent 0a4b7e4 commit 581565d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion core/src/main/scala/org/apache/spark/ui/SparkUI.scala
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ private[spark] class SparkUI private (
initialize()

def getSparkUser: String = {
environmentListener.systemProperties.toMap.getOrElse("user.name", "<unknown>")
environmentListener.sparkUser
.orElse(environmentListener.systemProperties.toMap.get("user.name"))
.getOrElse("<unknown>")
}

def getAppName: String = appName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,16 @@ private[ui] class EnvironmentTab(parent: SparkUI) extends SparkUITab(parent, "en
@DeveloperApi
@deprecated("This class will be removed in a future release.", "2.2.0")
class EnvironmentListener extends SparkListener {
var sparkUser: Option[String] = None
var jvmInformation = Seq[(String, String)]()
var sparkProperties = Seq[(String, String)]()
var systemProperties = Seq[(String, String)]()
var classpathEntries = Seq[(String, String)]()

override def onApplicationStart(event: SparkListenerApplicationStart): Unit = {
sparkUser = Some(event.sparkUser)
}

override def onEnvironmentUpdate(environmentUpdate: SparkListenerEnvironmentUpdate) {
synchronized {
val environmentDetails = environmentUpdate.environmentDetails
Expand Down

0 comments on commit 581565d

Please sign in to comment.