GitHub user yaooqinn opened a pull request:

    https://github.com/apache/spark/pull/19121

    [SPARK-21906][YARN][Spark Core]Don't runAsSparkUser to switch 
UserGroupInformation in YARN mode

    ## What changes were proposed in this pull request?
    
    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
    ```scala
     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()
        })
      }
    ```
    
    ## How was this patch tested?
     manual tests
    
    cc @vanzin 

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/yaooqinn/spark SPARK-21906

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/19121.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #19121
    
----
commit 5745f2a9f0537487e554131711b7b5f9bb26d53b
Author: Kent Yao <yaooq...@hotmail.com>
Date:   2017-09-04T08:57:23Z

    not switch ugi to itself

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to