Skip to content

Commit f4fd711

Browse files
Fix SparkConf usage.
1 parent 2debcea commit f4fd711

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

yarn/src/main/scala/org/apache/spark/deploy/yarn/YarnSparkHadoopUtil.scala

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,8 @@ class YarnSparkHadoopUtil extends SparkHadoopUtil {
101101
}
102102

103103
private[spark] override def scheduleLoginFromKeytab(): Unit = {
104-
val principal = sparkConf.get("spark.yarn.principal")
105-
val keytab = sparkConf.get("spark.yarn.keytab")
106-
if (principal != null) {
104+
sparkConf.getOption("spark.yarn.principal").foreach { principal =>
105+
val keytab = sparkConf.get("spark.yarn.keytab")
107106
val delegationTokenRenewerRunnable =
108107
new Runnable {
109108
override def run(): Unit = {
@@ -155,8 +154,7 @@ class YarnSparkHadoopUtil extends SparkHadoopUtil {
155154

156155
override def updateCredentialsIfRequired(): Unit = {
157156
try {
158-
val credentialsFile = sparkConf.get("spark.yarn.credentials.file")
159-
if (credentialsFile != null && !credentialsFile.isEmpty) {
157+
sparkConf.getOption("spark.yarn.credentials.file").foreach { credentialsFile =>
160158
val credentialsFilePath = new Path(credentialsFile)
161159
val remoteFs = FileSystem.get(conf)
162160
val stagingDirPath = new Path(remoteFs.getHomeDirectory, credentialsFilePath.getParent)

yarn/src/test/scala/org/apache/spark/deploy/yarn/YarnClusterSuite.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ class YarnClusterSuite extends FunSuite with BeforeAndAfterAll with Matchers wit
8585
tempDir = Utils.createTempDir()
8686
logConfDir = new File(tempDir, "log4j")
8787
logConfDir.mkdir()
88+
System.setProperty("SPARK_YARN_MODE", "true")
8889

8990
val logConfFile = new File(logConfDir, "log4j.properties")
9091
Files.write(LOG4J_CONF, logConfFile, UTF_8)
@@ -124,6 +125,7 @@ class YarnClusterSuite extends FunSuite with BeforeAndAfterAll with Matchers wit
124125

125126
override def afterAll() {
126127
yarnCluster.stop()
128+
System.clearProperty("SPARK_YARN_MODE")
127129
super.afterAll()
128130
}
129131

0 commit comments

Comments
 (0)