Skip to content
Closed
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 @@ -49,6 +49,8 @@ private[spark] abstract class KubernetesConf(val sparkConf: SparkConf) {

def appName: String = get("spark.app.name", "spark")

def sparkVersion: String = SPARK_VERSION

def namespace: String = get(KUBERNETES_NAMESPACE)

def imagePullPolicy: String = get(CONTAINER_IMAGE_PULL_POLICY)
Expand Down Expand Up @@ -122,7 +124,7 @@ class KubernetesDriverConf(

override def labels: Map[String, String] = {
val presetLabels = Map(
SPARK_VERSION_LABEL -> SPARK_VERSION,
SPARK_VERSION_LABEL -> sparkVersion,
SPARK_APP_ID_LABEL -> appId,
SPARK_APP_NAME_LABEL -> KubernetesConf.getAppNameLabel(appName),
SPARK_ROLE_LABEL -> SPARK_POD_DRIVER_ROLE)
Expand Down Expand Up @@ -199,7 +201,7 @@ private[spark] class KubernetesExecutorConf(

override def labels: Map[String, String] = {
val presetLabels = Map(
SPARK_VERSION_LABEL -> SPARK_VERSION,
SPARK_VERSION_LABEL -> sparkVersion,
SPARK_EXECUTOR_ID_LABEL -> executorId,
SPARK_APP_ID_LABEL -> appId,
SPARK_APP_NAME_LABEL -> KubernetesConf.getAppNameLabel(appName),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,31 @@ class KubernetesConfSuite extends SparkFunSuite {
}
}

test("SPARK-56736: sparkVersion returns the runtime Spark version for driver and executor") {
val sparkConf = new SparkConf(false)
val driverConf = KubernetesTestConf.createDriverConf(sparkConf)
val execConf = KubernetesTestConf.createExecutorConf(sparkConf)
assert(driverConf.sparkVersion === SPARK_VERSION)
assert(execConf.sparkVersion === SPARK_VERSION)
assert(driverConf.labels(SPARK_VERSION_LABEL) === SPARK_VERSION)
assert(execConf.labels(SPARK_VERSION_LABEL) === SPARK_VERSION)
}

test("SPARK-56736: KubernetesDriverConf subclass can override sparkVersion") {
val customVersion = "9.9.9-custom"
val customConf = new KubernetesDriverConf(
new SparkConf(false),
KubernetesTestConf.APP_ID,
JavaMainAppResource(None),
KubernetesTestConf.MAIN_CLASS,
APP_ARGS,
None) {
override def sparkVersion: String = customVersion
}
assert(customConf.sparkVersion === customVersion)
assert(customConf.labels(SPARK_VERSION_LABEL) === customVersion)
}

test("SPARK-52902: K8s image configs support {{SPARK_VERSION}} placeholder") {
val sparkConf = new SparkConf(false)
sparkConf.set(CONTAINER_IMAGE, "apache/spark:{{SPARK_VERSION}}")
Expand Down