Skip to content

Commit b167a8c

Browse files
JoshRosenandrewor14
authored andcommitted
[SPARK-3734] DriverRunner should not read SPARK_HOME from submitter's environment
When using spark-submit in `cluster` mode to submit a job to a Spark Standalone cluster, if the JAVA_HOME environment variable was set on the submitting machine then DriverRunner would attempt to use the submitter's JAVA_HOME to launch the driver process (instead of the worker's JAVA_HOME), causing the driver to fail unless the submitter and worker had the same Java location. This commit fixes this by reading JAVA_HOME from sys.env instead of command.environment. Author: Josh Rosen <[email protected]> Closes #2586 from JoshRosen/SPARK-3734 and squashes the following commits: e9513d9 [Josh Rosen] [SPARK-3734] DriverRunner should not read SPARK_HOME from submitter's environment.
1 parent de700d3 commit b167a8c

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

core/src/main/scala/org/apache/spark/deploy/worker/CommandUtils.scala

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,14 @@ import org.apache.spark.util.Utils
3030
private[spark]
3131
object CommandUtils extends Logging {
3232
def buildCommandSeq(command: Command, memory: Int, sparkHome: String): Seq[String] = {
33-
val runner = getEnv("JAVA_HOME", command).map(_ + "/bin/java").getOrElse("java")
33+
val runner = sys.env.get("JAVA_HOME").map(_ + "/bin/java").getOrElse("java")
3434

3535
// SPARK-698: do not call the run.cmd script, as process.destroy()
3636
// fails to kill a process tree on Windows
3737
Seq(runner) ++ buildJavaOpts(command, memory, sparkHome) ++ Seq(command.mainClass) ++
3838
command.arguments
3939
}
4040

41-
private def getEnv(key: String, command: Command): Option[String] =
42-
command.environment.get(key).orElse(Option(System.getenv(key)))
43-
4441
/**
4542
* Attention: this must always be aligned with the environment variables in the run scripts and
4643
* the way the JAVA_OPTS are assembled there.

0 commit comments

Comments
 (0)