Skip to content

Commit efad8c6

Browse files
committed
Address review comments:
- check for different env. vars. - fix logging message
1 parent 1dec709 commit efad8c6

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

core/src/main/scala/org/apache/spark/util/Utils.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,10 @@ private[spark] object Utils extends Logging {
465465
}
466466

467467
private[spark] def isRunningInYarnContainer(conf: SparkConf): Boolean = {
468-
conf.getenv("NM_HOST") != null || conf.getenv("CONTAINER_ID") != null
468+
// These environment variables are set by YARN.
469+
// For Hadoop 0.23.X, we check for YARN_LOCAL_DIRS (we use this below in getYarnLocalDirs())
470+
// For Hadoop 2.X, we check for CONTAINER_ID.
471+
conf.getenv("CONTAINER_ID") != null || conf.getenv("YARN_LOCAL_DIRS") != null
469472
}
470473

471474
/**
@@ -484,7 +487,7 @@ private[spark] object Utils extends Logging {
484487
conf.get("spark.local.dir", System.getProperty("java.io.tmpdir")))
485488
}
486489
val rootDirs = confValue.split(',')
487-
logDebug(s"Getting/creating local root dirs at '$rootDirs'")
490+
logDebug(s"Getting/creating local root dirs at '$confValue'")
488491

489492
rootDirs.flatMap { rootDir =>
490493
val localDir: File = new File(rootDir)

0 commit comments

Comments
 (0)