File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed
core/src/main/scala/org/apache/spark/util Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -464,14 +464,16 @@ private[spark] object Utils extends Logging {
464464 getOrCreateLocalRootDirs(conf)(0 )
465465 }
466466
467+ private [spark] def isRunningInYarnContainer (conf : SparkConf ): Boolean = {
468+ conf.getenv(" NM_HOST" ) != null || conf.getenv(" CONTAINER_ID" ) != null
469+ }
470+
467471 /**
468472 * Gets or creates the directories listed in spark.local.dir or SPARK_LOCAL_DIRS,
469473 * and returns only the directories that exist / could be created.
470474 */
471475 private [spark] def getOrCreateLocalRootDirs (conf : SparkConf ): Array [String ] = {
472- val isYarn = java.lang.Boolean .valueOf(
473- System .getProperty(" SPARK_YARN_MODE" , conf.getenv(" SPARK_YARN_MODE" )))
474- val confValue = if (isYarn) {
476+ val confValue = if (isRunningInYarnContainer(conf)) {
475477 // If we are in yarn mode, systems can have different disk layouts so we must set it
476478 // to what Yarn on this system said was available.
477479 getYarnLocalDirs(conf)
You can’t perform that action at this time.
0 commit comments