Skip to content

Commit 926bd96

Browse files
committed
Moved check to SparkContext.
1 parent 7c89b6e commit 926bd96

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

core/src/main/scala/org/apache/spark/SparkConf.scala

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -449,14 +449,6 @@ class SparkConf(loadDefaults: Boolean) extends Cloneable with Logging {
449449
}
450450
}
451451

452-
// System property spark.yarn.app.id must be set if user code ran by AM on a YARN cluster
453-
// yarn-standalone is deprecated, but still supported
454-
if ((get("spark.master") == "yarn-cluster" || get("spark.master") == "yarn-standalone") &&
455-
get("spark.yarn.app.id", null) == null) {
456-
throw new SparkException("Detected yarn-cluster mode, but isn't running on a cluster. " +
457-
"Deployment to YARN is not supported directly by SparkContext. Please use spark-submit.")
458-
}
459-
460452
}
461453

462454
/**

core/src/main/scala/org/apache/spark/SparkContext.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,14 @@ class SparkContext(config: SparkConf) extends Logging with ExecutorAllocationCli
371371
throw new SparkException("An application name must be set in your configuration")
372372
}
373373

374+
// System property spark.yarn.app.id must be set if user code ran by AM on a YARN cluster
375+
// yarn-standalone is deprecated, but still supported
376+
if ((master == "yarn-cluster" || master == "yarn-standalone") &&
377+
!_conf.contains("spark.yarn.app.id")) {
378+
throw new SparkException("Detected yarn-cluster mode, but isn't running on a cluster. " +
379+
"Deployment to YARN is not supported directly by SparkContext. Please use spark-submit.")
380+
}
381+
374382
if (_conf.getBoolean("spark.logConf", false)) {
375383
logInfo("Spark configuration:\n" + _conf.toDebugString)
376384
}

0 commit comments

Comments
 (0)