Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
[SPARK-21728][core] Follow up: fix user config, auth in SparkSubmit l…
…ogging.

- 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.
  • Loading branch information
Marcelo Vanzin committed Aug 30, 2017
commit 4b6284319c0c5616c997176747d644ca9ff14fae
3 changes: 3 additions & 0 deletions core/src/main/scala/org/apache/spark/deploy/SparkSubmit.scala
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,9 @@ object SparkSubmit extends CommandLineUtils with Logging {
var localJars: String = null
var localPyFiles: String = null
if (deployMode == CLIENT) {
// This security manager will not need an auth secret, but set a dummy value in case
// spark.authenticate is enabled, otherwise an exception is thrown.
sparkConf.set(SecurityManager.SPARK_AUTH_SECRET_CONF, "unused")
val secMgr = new SecurityManager(sparkConf)
localPrimaryResource = Option(args.primaryResource).map {
downloadFile(_, targetDir, sparkConf, hadoopConf, secMgr)
Expand Down
5 changes: 4 additions & 1 deletion core/src/main/scala/org/apache/spark/internal/Logging.scala
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ trait Logging {
val log4j12Initialized = LogManager.getRootLogger.getAllAppenders.hasMoreElements
// scalastyle:off println
if (!log4j12Initialized) {
Logging.defaultSparkLog4jConfig = true
val defaultLogProps = "org/apache/spark/log4j-defaults.properties"
Option(Utils.getSparkClassLoader.getResource(defaultLogProps)) match {
case Some(url) =>
Expand Down Expand Up @@ -164,6 +165,7 @@ trait Logging {
private[spark] object Logging {
@volatile private var initialized = false
@volatile private var defaultRootLevel: Level = null
@volatile private var defaultSparkLog4jConfig = false

val initLock = new Object()
try {
Expand All @@ -185,7 +187,8 @@ private[spark] object Logging {
* initialization again.
*/
def uninitialize(): Unit = initLock.synchronized {
if (isLog4j12()) {
if (isLog4j12() && defaultSparkLog4jConfig) {
defaultSparkLog4jConfig = false
LogManager.resetConfiguration()
}
this.initialized = false
Expand Down