You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Kent Yao (JIRA)" <ji...@apache.org> on 2017/09/04 08:53:01 UTC

[jira] [Created] (SPARK-21906) No need to runAsSparkUser to switch UserGroupInformation in YARN mode

Kent Yao created SPARK-21906:
--------------------------------

             Summary: No need to runAsSparkUser to switch UserGroupInformation in YARN mode
                 Key: SPARK-21906
                 URL: https://issues.apache.org/jira/browse/SPARK-21906
             Project: Spark
          Issue Type: Improvement
          Components: Spark Core, YARN
    Affects Versions: 2.2.0
            Reporter: Kent Yao


1、The Yarn application‘s ugi is determined by the ugi launching it
2、 runAsSparkUser is used to switch a ugi as same as itself, because we have already set ` env("SPARK_USER") = UserGroupInformation.getCurrentUser().getShortUserName()
` in the am container context
{code|java}
 def runAsSparkUser(func: () => Unit) {
    val user = Utils.getCurrentUserName()  // get the user itself
    logDebug("running as user: " + user)
    val ugi = UserGroupInformation.createRemoteUser(user) // create a new ugi use itself
    transferCredentials(UserGroupInformation.getCurrentUser(), ugi) // transfer its own credentials 
    ugi.doAs(new PrivilegedExceptionAction[Unit] { // doAs as itseft
      def run: Unit = func()
    })
  }
{code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org