Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
spark
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cs525-sp18-g07
spark
Commits
13a19505
Commit
13a19505
authored
11 years ago
by
tgravescs
Browse files
Options
Downloads
Patches
Plain Diff
Don't call the doAs if user is unknown or the same user that is already running
parent
f95cb04e
No related branches found
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
core/src/main/scala/org/apache/spark/deploy/SparkHadoopUtil.scala
+16
-5
16 additions, 5 deletions
.../main/scala/org/apache/spark/deploy/SparkHadoopUtil.scala
core/src/main/scala/org/apache/spark/executor/Executor.scala
+1
-4
1 addition, 4 deletions
core/src/main/scala/org/apache/spark/executor/Executor.scala
with
17 additions
and
9 deletions
core/src/main/scala/org/apache/spark/deploy/SparkHadoopUtil.scala
+
16
−
5
View file @
13a19505
...
...
@@ -23,7 +23,7 @@ import org.apache.hadoop.conf.Configuration
import
org.apache.hadoop.mapred.JobConf
import
org.apache.hadoop.security.UserGroupInformation
import
org.apache.spark.SparkException
import
org.apache.spark.
{
SparkContext
,
SparkException
}
/**
* Contains util methods to interact with Hadoop from Spark.
...
...
@@ -34,10 +34,21 @@ class SparkHadoopUtil {
UserGroupInformation
.
setConfiguration
(
conf
)
def
runAsUser
(
user
:
String
)(
func
:
()
=>
Unit
)
{
val
ugi
=
UserGroupInformation
.
createRemoteUser
(
user
)
ugi
.
doAs
(
new
PrivilegedExceptionAction
[
Unit
]
{
def
run
:
Unit
=
func
()
})
// if we are already running as the user intended there is no reason to do the doAs. It
// will actually break secure HDFS access as it doesn't fill in the credentials. Also if
// the user is UNKNOWN then we shouldn't be creating a remote unknown user
// (this is actually the path spark on yarn takes) since SPARK_USER is initialized only
// in SparkContext.
val
currentUser
=
Option
(
System
.
getProperty
(
"user.name"
)).
getOrElse
(
SparkContext
.
SPARK_UNKNOWN_USER
)
if
(
user
!=
SparkContext
.
SPARK_UNKNOWN_USER
&&
currentUser
!=
user
)
{
val
ugi
=
UserGroupInformation
.
createRemoteUser
(
user
)
ugi
.
doAs
(
new
PrivilegedExceptionAction
[
Unit
]
{
def
run
:
Unit
=
func
()
})
}
else
{
func
()
}
}
/**
...
...
This diff is collapsed.
Click to expand it.
core/src/main/scala/org/apache/spark/executor/Executor.scala
+
1
−
4
View file @
13a19505
...
...
@@ -179,10 +179,7 @@ private[spark] class Executor(
}
}
// the runAsUser breaks secure HDFS access. It needs to add the credentials
// for the user if running as a user. Comment out for now.
//override def run(): Unit = SparkHadoopUtil.get.runAsUser(sparkUser) { () =>
override
def
run
()
:
Unit
=
{
override
def
run
()
:
Unit
=
SparkHadoopUtil
.
get
.
runAsUser
(
sparkUser
)
{
()
=>
val
startTime
=
System
.
currentTimeMillis
()
SparkEnv
.
set
(
env
)
Thread
.
currentThread
.
setContextClassLoader
(
replClassLoader
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment