Skip to content

Commit ae91720

Browse files
wangyumMarcelo Vanzin
authored andcommitted
[SPARK-23640][CORE] Fix hadoop config may override spark config
## What changes were proposed in this pull request? It may be get `spark.shuffle.service.port` from https://github.com/apache/spark/blob/9745ec3a61c99be59ef6a9d5eebd445e8af65b7a/core/src/main/scala/org/apache/spark/deploy/SparkHadoopUtil.scala#L459 Therefore, the client configuration `spark.shuffle.service.port` does not working unless the configuration is `spark.hadoop.spark.shuffle.service.port`. - This configuration is not working: ``` bin/spark-sql --master yarn --conf spark.shuffle.service.port=7338 ``` - This configuration works: ``` bin/spark-sql --master yarn --conf spark.hadoop.spark.shuffle.service.port=7338 ``` This PR fix this issue. ## How was this patch tested? It's difficult to carry out unit testing. But I've tested it manually. Author: Yuming Wang <[email protected]> Closes apache#20785 from wangyum/SPARK-23640.
1 parent bc8d093 commit ae91720

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

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

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2302,16 +2302,20 @@ private[spark] object Utils extends Logging {
23022302
}
23032303

23042304
/**
2305-
* Return the value of a config either through the SparkConf or the Hadoop configuration
2306-
* if this is Yarn mode. In the latter case, this defaults to the value set through SparkConf
2307-
* if the key is not set in the Hadoop configuration.
2305+
* Return the value of a config either through the SparkConf or the Hadoop configuration.
2306+
* We Check whether the key is set in the SparkConf before look at any Hadoop configuration.
2307+
* If the key is set in SparkConf, no matter whether it is running on YARN or not,
2308+
* gets the value from SparkConf.
2309+
* Only when the key is not set in SparkConf and running on YARN,
2310+
* gets the value from Hadoop configuration.
23082311
*/
23092312
def getSparkOrYarnConfig(conf: SparkConf, key: String, default: String): String = {
2310-
val sparkValue = conf.get(key, default)
2311-
if (conf.get(SparkLauncher.SPARK_MASTER, null) == "yarn") {
2312-
new YarnConfiguration(SparkHadoopUtil.get.newConfiguration(conf)).get(key, sparkValue)
2313+
if (conf.contains(key)) {
2314+
conf.get(key, default)
2315+
} else if (conf.get(SparkLauncher.SPARK_MASTER, null) == "yarn") {
2316+
new YarnConfiguration(SparkHadoopUtil.get.newConfiguration(conf)).get(key, default)
23132317
} else {
2314-
sparkValue
2318+
default
23152319
}
23162320
}
23172321

0 commit comments

Comments
 (0)