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-2080] Yarn: report HS URL in client mode, correct user in cluster mode. #1002

Closed
wants to merge 2 commits into from

Conversation

vanzin
Copy link
Contributor

@vanzin vanzin commented Jun 6, 2014

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.

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.
@vanzin
Copy link
Contributor Author

vanzin commented Jun 6, 2014

Note: tested with yarn-client, yarn-cluster and local, checked the spark user listed in the history server for each app.

@AmplabJenkins
Copy link

Can one of the admins verify this patch?

@tgravescs
Copy link
Contributor

note that this is jira SPARK-1291

@tgravescs
Copy link
Contributor

Sorry I misunderstood, this is not SPARK-1291, can you please file jira.

@tgravescs
Copy link
Contributor

Can you also please update for yarn-alpha

@vanzin vanzin changed the title Yarn: report HS URL in client mode, correct user in cluster mode. [SPARK-2080] Yarn: report HS URL in client mode, correct user in cluster mode. Jun 9, 2014
@vanzin
Copy link
Contributor Author

vanzin commented Jun 9, 2014

yarn-alpha seems to already do it:

  if (registered) {
    val finishReq = Records.newRecord(classOf[FinishApplicationMasterRequest])
      .asInstanceOf[FinishApplicationMasterRequest]
    ...
    finishReq.setTrackingUrl(sparkConf.get("spark.yarn.historyServer.address", ""))
    resourceManager.finishApplicationMaster(finishReq)
  }

@tgravescs
Copy link
Contributor

I think that is the ApplicationMaster, I was referring to the ExecutorLauncher for yarn-alpha.

def finishApplicationMaster(status: FinalApplicationStatus) {

logInfo("finish ApplicationMaster with " + status)
val finishReq = Records.newRecord(classOf[FinishApplicationMasterRequest])
  .asInstanceOf[FinishApplicationMasterRequest]
finishReq.setAppAttemptId(appAttemptId)
finishReq.setFinishApplicationStatus(status)
resourceManager.finishApplicationMaster(finishReq)

}

We should add a call to finishReq.setTrackingUrl(...)

@vanzin
Copy link
Contributor Author

vanzin commented Jun 10, 2014

D'oh. Will update shortly.

@@ -297,7 +297,7 @@ class SparkContext(config: SparkConf) extends Logging {

// Set SPARK_USER for user who is running SparkContext.
val sparkUser = Option {
Option(System.getProperty("user.name")).getOrElse(System.getenv("SPARK_USER"))
Copy link
Contributor

Choose a reason for hiding this comment

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

@jerryshao I think you had originally added this logic, Is there a usecase where this order is required? It always seemed odd to me since I expect user.name to always be set.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @tgravescs , originally I put SPARK_USER before user.name when I submitted a PR, and someone suggested me to change the order to keep consistent with other Spark parameter, so I changed this. I assume it's OK in standalone and mesos mode, but I didn't test it in Yarn mode.

It looks good to me to change this order if needed. :)

@vanzin
Copy link
Contributor Author

vanzin commented Jun 11, 2014

BTW, just ran into this in SecurityManager.scala:

private val defaultAclUsers = Seq[String](System.getProperty("user.name", ""),
  Option(System.getenv("SPARK_USER")).getOrElse(""))

So that probably needs the same treatment.

@vanzin
Copy link
Contributor Author

vanzin commented Jun 11, 2014

(Oh wait, that's adding both user.name and SPARK_USER to the default users list? Maybe it works. but looks strange.)

@tgravescs
Copy link
Contributor

Yeah the Securitymanager is adding both to handle the case the containers run as one user but is accessing HDFS as whoever specified in SPARK_USER, it also came up in the review.

@vanzin can you tell me your yarn setup where it was showing yarn as the user in web UI? I have a single node setup with daemons running as yarn and then launch job as myself and it shows up as myself (without your change). Are you running your client as super user and then specifying SPARK_USER to access hdfs files?

@tgravescs
Copy link
Contributor

also note that yarn does set the SPARK_USER to UGI in ClientBase

env("SPARK_USER") = UserGroupInformation.getCurrentUser().getShortUserName()

@vanzin
Copy link
Contributor Author

vanzin commented Jun 12, 2014

@tgravescs I have a (non-secured) yarn cluster (where daemons run as "yarn"), and I was launching processes from my own machine (not in the cluster). I'm using the event logger to write app logs to HDFS.

In client mode, my machine is the driver so my user gets correctly written to the app log. But in cluster mode the AM is launched as the same user as the node manager (since it's not a kerberized setup), so the spark user written to the app log is the same user running the node manager, which is "yarn", and not myself.

@vanzin
Copy link
Contributor Author

vanzin commented Jun 12, 2014

(Ah, to clarify, I wasn't looking at the web ui, but at the history server ui. It should sort of show the same info, though, as far as I can tell.)

@tgravescs
Copy link
Contributor

Ah ok, that makes more sense. The history UI just displays what was recorded as the user on application start event from spark. In the case the daemons are running as user yarn without security it appears this is being put in as user yarn:

{"Event":"SparkListenerApplicationStart","App Name":"JavaWordCount","Timestamp":1402600427658,"User":"yarn"}

I'm a little bit surprised that the change you made fixes that for multiple users. is SPARK_USER set to your user when you start the history server? Does it work with multiple users? We should probably change it to put the correct user in the event log. Or perhaps your change is fixing it so that it gets logs properly?

@tgravescs
Copy link
Contributor

Ok so looking more at it that is what is happening the postApplicationStart is just using sparkUser and since you changed it, it is properly logging the right thing now. So ignore my questions.

@tgravescs
Copy link
Contributor

Changes look good. Note that this only fixes the url for unsecure YARN cluster. For secure clusters they generally use the web app proxy which requires more setup and will be handled under SPARK-1291.

Thanks @vanzin

@asfgit asfgit closed this in ecde5b8 Jun 12, 2014
asfgit pushed a commit that referenced this pull request Jun 12, 2014
…ter 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 <vanzin@cloudera.com>

This patch had conflicts when merged, resolved by
Committer: Thomas Graves <tgraves@apache.org>

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.
@tgravescs
Copy link
Contributor

Also committed to branch-1

@vanzin vanzin deleted the yarn-client-url branch June 17, 2014 18:37
pdeyhim pushed a commit to pdeyhim/spark-1 that referenced this pull request Jun 25, 2014
…ter 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 <vanzin@cloudera.com>

This patch had conflicts when merged, resolved by
Committer: Thomas Graves <tgraves@apache.org>

Closes apache#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.
xiliu82 pushed a commit to xiliu82/spark that referenced this pull request Sep 4, 2014
…ter 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 <vanzin@cloudera.com>

This patch had conflicts when merged, resolved by
Committer: Thomas Graves <tgraves@apache.org>

Closes apache#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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants