Skip to content

Commit 4b62843

Browse files
author
Marcelo Vanzin
committed
[SPARK-21728][core] Follow up: fix user config, auth in SparkSubmit logging.
- SecurityManager complains when auth is enabled but no secret is defined; SparkSubmit doesn't use the auth functionality of the SecurityManager, so use a dummy secret to work around the exception. - Only reset the log4j configuration when Spark was the one initializing it, otherwise user-defined log configuration may be lost.
1 parent 235d283 commit 4b62843

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

core/src/main/scala/org/apache/spark/deploy/SparkSubmit.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,9 @@ object SparkSubmit extends CommandLineUtils with Logging {
352352
var localJars: String = null
353353
var localPyFiles: String = null
354354
if (deployMode == CLIENT) {
355+
// This security manager will not need an auth secret, but set a dummy value in case
356+
// spark.authenticate is enabled, otherwise an exception is thrown.
357+
sparkConf.set(SecurityManager.SPARK_AUTH_SECRET_CONF, "unused")
355358
val secMgr = new SecurityManager(sparkConf)
356359
localPrimaryResource = Option(args.primaryResource).map {
357360
downloadFile(_, targetDir, sparkConf, hadoopConf, secMgr)

core/src/main/scala/org/apache/spark/internal/Logging.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ trait Logging {
120120
val log4j12Initialized = LogManager.getRootLogger.getAllAppenders.hasMoreElements
121121
// scalastyle:off println
122122
if (!log4j12Initialized) {
123+
Logging.defaultSparkLog4jConfig = true
123124
val defaultLogProps = "org/apache/spark/log4j-defaults.properties"
124125
Option(Utils.getSparkClassLoader.getResource(defaultLogProps)) match {
125126
case Some(url) =>
@@ -164,6 +165,7 @@ trait Logging {
164165
private[spark] object Logging {
165166
@volatile private var initialized = false
166167
@volatile private var defaultRootLevel: Level = null
168+
@volatile private var defaultSparkLog4jConfig = false
167169

168170
val initLock = new Object()
169171
try {
@@ -185,7 +187,8 @@ private[spark] object Logging {
185187
* initialization again.
186188
*/
187189
def uninitialize(): Unit = initLock.synchronized {
188-
if (isLog4j12()) {
190+
if (isLog4j12() && defaultSparkLog4jConfig) {
191+
defaultSparkLog4jConfig = false
189192
LogManager.resetConfiguration()
190193
}
191194
this.initialized = false

0 commit comments

Comments
 (0)