Skip to content

Commit dc0b466

Browse files
committed
Sanitize jars and files
1 parent 3328a78 commit dc0b466

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

resource-managers/kubernetes/core/src/main/scala/org/apache/spark/deploy/k8s/KubernetesConf.scala

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import org.apache.spark.deploy.k8s.Config._
2323
import org.apache.spark.deploy.k8s.Constants._
2424
import org.apache.spark.deploy.k8s.submit.{JavaMainAppResource, MainAppResource}
2525
import org.apache.spark.internal.config.ConfigEntry
26+
import org.apache.spark.launcher.SparkLauncher
2627

2728
private[spark] sealed trait KubernetesRoleSpecificConf
2829

@@ -105,7 +106,7 @@ private[spark] object KubernetesConf {
105106
appArgs: Array[String]): KubernetesConf[KubernetesDriverSpecificConf] = {
106107
val sparkConfWithMainAppJar = sparkConf.clone()
107108
mainAppResource.foreach {
108-
case JavaMainAppResource(res) =>
109+
case JavaMainAppResource(res) if res != SparkLauncher.NO_RESOURCE =>
109110
val previousJars = sparkConf
110111
.getOption("spark.jars")
111112
.map(_.split(","))
@@ -115,6 +116,21 @@ private[spark] object KubernetesConf {
115116
}
116117
}
117118

119+
sparkConfWithMainAppJar.setJars(
120+
sparkConfWithMainAppJar.getOption("spark.jars")
121+
.map(_.split(","))
122+
.getOrElse(Array.empty)
123+
.map(_.trim)
124+
.filterNot(_.isEmpty))
125+
126+
sparkConfWithMainAppJar.set("spark.files",
127+
sparkConfWithMainAppJar.getOption("spark.files")
128+
.map(_.split(","))
129+
.getOrElse(Array.empty)
130+
.map(_.trim)
131+
.filterNot(_.isEmpty)
132+
.mkString(","))
133+
118134
val driverCustomLabels = KubernetesUtils.parsePrefixedKeyValuePairs(
119135
sparkConf, KUBERNETES_DRIVER_LABEL_PREFIX)
120136
require(!driverCustomLabels.contains(SPARK_APP_ID_LABEL), "Label with key " +

0 commit comments

Comments
 (0)