Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -386,14 +386,14 @@ object KubernetesUtils extends Logging {
* This function builds the EnvVar objects for each key-value env.
*/
@Since("3.4.0")
def buildEnvVars(env: Map[String, String]): Seq[EnvVar] = {
env.filter(env => env._2 != null)
.map { env =>
def buildEnvVars(env: Seq[(String, String)]): Seq[EnvVar] = {
env.filterNot(_._2 == null)
.map { case (k, v) =>
new EnvVarBuilder()
.withName(env._1)
.withValue(env._2)
.withName(k)
.withValue(v)
.build()
}.toSeq
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ private[spark] class BasicDriverFeatureStep(conf: KubernetesDriverConf)

override def configurePod(pod: SparkPod): SparkPod = {
val driverCustomEnvs = KubernetesUtils.buildEnvVars(
Map(ENV_APPLICATION_ID -> conf.appId) ++ conf.environment)
Seq(ENV_APPLICATION_ID -> conf.appId) ++ conf.environment)
val driverCpuQuantity = new Quantity(driverCoresRequest)
val driverMemoryQuantity = new Quantity(s"${driverMemoryWithOverheadMiB}Mi")
val maybeCpuLimitQuantity = driverLimitCores.map { limitCores =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ private[spark] class BasicExecutorFeatureStep(
(s"$ENV_JAVA_OPT_PREFIX$index", opt)
}.toMap
KubernetesUtils.buildEnvVars(
Map(
Seq(
ENV_DRIVER_URL -> driverUrl,
ENV_EXECUTOR_CORES -> execResources.cores.get.toString,
ENV_EXECUTOR_MEMORY -> executorMemoryString,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ private[spark] class DriverCommandFeatureStep(conf: KubernetesDriverConf)

val pythonEnvs = {
KubernetesUtils.buildEnvVars(
Map(
Seq(
ENV_PYSPARK_PYTHON -> conf.get(PYSPARK_PYTHON)
.orElse(environmentVariables.get(ENV_PYSPARK_PYTHON))
.orNull,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class KubernetesUtilsSuite extends SparkFunSuite with PrivateMethodTester {
.withValue(v).build()
}
val outputEnvVars =
KubernetesUtils.buildEnvVars(input.toMap + ("testKeyForNull" -> null))
KubernetesUtils.buildEnvVars(input :+ ("testKeyForNull" -> null))
assert(outputEnvVars.toSet == expectedEnvVars.toSet)
}

Expand Down