Skip to content

Commit

Permalink
[SPARK-49845][CORE] Make appArgs and environmentVariables optiona…
Browse files Browse the repository at this point in the history
…l in REST API

### What changes were proposed in this pull request?

This PR aims to make `appArgs` and `environmentVariables` fields optional in REST API.

### Why are the changes needed?

`appArgs` and `environmentVariables` became mandatory due to the Apache Mesos limitation at Spark 2.2.2. Technically, this is a revert of SPARK-22574.
- apache#19966

Since Apache Spark 4.0 removed Mesos support, we don't need these requirements.
- apache#43135

### Does this PR introduce _any_ user-facing change?

No because this is a relaxation of enforcement.

### How was this patch tested?

Pass the CIs with the revised test case.

### Was this patch authored or co-authored using generative AI tooling?

No.

Closes apache#48316 from dongjoon-hyun/SPARK-49845.

Authored-by: Dongjoon Hyun <dongjoon@apache.org>
Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
  • Loading branch information
dongjoon-hyun committed Oct 2, 2024
1 parent 3093ad6 commit 3551a9e
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,12 @@ private[rest] class StandaloneSubmitRequestServlet(
val (_, masterPort) = Utils.extractHostPortFromSparkUrl(masterUrl)
val updatedMasters = masters.map(
_.replace(s":$masterRestPort", s":$masterPort")).getOrElse(masterUrl)
val appArgs = request.appArgs
val appArgs = Option(request.appArgs).getOrElse(Array[String]())
// Filter SPARK_LOCAL_(IP|HOSTNAME) environment variables from being set on the remote system.
// In addition, the placeholders are replaced into the values of environment variables.
val environmentVariables =
request.environmentVariables.filterNot(x => x._1.matches("SPARK_LOCAL_(IP|HOSTNAME)"))
Option(request.environmentVariables).getOrElse(Map.empty[String, String])
.filterNot(x => x._1.matches("SPARK_LOCAL_(IP|HOSTNAME)"))
.map(x => (x._1, replacePlaceHolder(x._2)))

// Construct driver description
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ private[rest] class CreateSubmissionRequest extends SubmitRestProtocolRequest {
super.doValidate()
assert(sparkProperties != null, "No Spark properties set!")
assertFieldIsSet(appResource, "appResource")
assertFieldIsSet(appArgs, "appArgs")
assertFieldIsSet(environmentVariables, "environmentVariables")
assertPropertyIsSet("spark.app.name")
assertPropertyIsBoolean(config.DRIVER_SUPERVISE.key)
assertPropertyIsNumeric(config.DRIVER_CORES.key)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ class SubmitRestProtocolSuite extends SparkFunSuite {
message.clientSparkVersion = "1.2.3"
message.appResource = "honey-walnut-cherry.jar"
message.mainClass = "org.apache.spark.examples.SparkPie"
message.appArgs = Array("two slices")
message.environmentVariables = Map("PATH" -> "/dev/null")
val conf = new SparkConf(false)
conf.set("spark.app.name", "SparkPie")
message.sparkProperties = conf.getAll.toMap
Expand Down

0 comments on commit 3551a9e

Please sign in to comment.