Skip to content

Commit 6dd5943

Browse files
author
Marcelo Vanzin
committed
Fix propagation of config options to driver / executor.
ClientBase disagreed with itself about how to propagate config options. Some places used the SparkConf object, others relied on system properties. This lead to certain properties not being propagated, mainly in cluster mode. So standardize on using SparkConf for that. To maintain compatibility with SPARK_JAVA_OPTS, remove the hack in ClientBase and just call SparkConf.validateSettings(), which does the right thing and correctly warns the user to stop using the env variable in the future.
1 parent b2e377f commit 6dd5943

File tree

3 files changed

+5
-8
lines changed

3 files changed

+5
-8
lines changed

yarn/alpha/src/main/scala/org/apache/spark/deploy/yarn/Client.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ object Client {
178178
System.setProperty("SPARK_YARN_MODE", "true")
179179

180180
val sparkConf = new SparkConf
181+
sparkConf.validateSettings()
181182

182183
try {
183184
val args = new ClientArguments(argStrings, sparkConf)

yarn/common/src/main/scala/org/apache/spark/deploy/yarn/ClientBase.scala

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -351,21 +351,16 @@ trait ClientBase extends Logging {
351351
javaOpts += "-XX:CMSIncrementalDutyCycle=10"
352352
}
353353

354-
// SPARK_JAVA_OPTS is deprecated, but for backwards compatibility:
355-
sys.env.get("SPARK_JAVA_OPTS").foreach { opts =>
356-
sparkConf.set("spark.executor.extraJavaOptions", opts)
357-
sparkConf.set("spark.driver.extraJavaOptions", opts)
358-
}
359-
360354
// Forward the Spark configuration to the application master / executors.
361355
// TODO: it might be nicer to pass these as an internal environment variable rather than
362356
// as Java options, due to complications with string parsing of nested quotes.
363357
for ((k, v) <- sparkConf.getAll) {
364358
javaOpts += "-D" + k + "=" + "\\\"" + v + "\\\""
365359
}
366360
if (args.amClass == classOf[ApplicationMaster].getName) {
367-
sys.props.get("spark.driver.extraJavaOptions").foreach(opts => javaOpts += opts)
368-
sys.props.get("spark.driver.libraryPath").foreach(p => javaOpts += s"-Djava.library.path=$p")
361+
sparkConf.getOption("spark.driver.extraJavaOptions").foreach(opts => javaOpts += opts)
362+
sparkConf.getOption("spark.driver.libraryPath")
363+
.foreach(p => javaOpts += s"-Djava.library.path=$p")
369364
}
370365

371366
// Command for the ApplicationMaster

yarn/stable/src/main/scala/org/apache/spark/deploy/yarn/Client.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ object Client {
185185
// see Client#setupLaunchEnv().
186186
System.setProperty("SPARK_YARN_MODE", "true")
187187
val sparkConf = new SparkConf()
188+
sparkConf.validateSettings()
188189

189190
try {
190191
val args = new ClientArguments(argStrings, sparkConf)

0 commit comments

Comments
 (0)