You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by do...@apache.org on 2026/05/06 05:44:01 UTC
(spark) branch branch-4.2 updated: [SPARK-56736][K8S] Add `sparkVersion` method to `KubernetesConf` abstract class
This is an automated email from the ASF dual-hosted git repository.
dongjoon-hyun pushed a commit to branch branch-4.2
in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/branch-4.2 by this push:
new 322a6871b435 [SPARK-56736][K8S] Add `sparkVersion` method to `KubernetesConf` abstract class
322a6871b435 is described below
commit 322a6871b435ce6faafaacbe8498ae3fabe0a66b
Author: Dongjoon Hyun <do...@apache.org>
AuthorDate: Tue May 5 22:43:35 2026 -0700
[SPARK-56736][K8S] Add `sparkVersion` method to `KubernetesConf` abstract class
### What changes were proposed in this pull request?
This PR adds a `sparkVersion: String` method on `KubernetesConf` and uses it in `KubernetesDriverConf.labels` and `KubernetesExecutorConf.labels` instead of referencing the `SPARK_VERSION` constant directly.
### Why are the changes needed?
Exposing the version through an overridable method gives subclasses (e.g., the Spark K8s operator) a single extension point to customize the `SPARK_VERSION_LABEL` value.
### Does this PR introduce _any_ user-facing change?
No.
### How was this patch tested?
Pass the CIs with the newly added test cases.
### Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Opus 4.7)
Closes #55697 from dongjoon-hyun/SPARK-56736.
Authored-by: Dongjoon Hyun <do...@apache.org>
Signed-off-by: Dongjoon Hyun <do...@apache.org>
(cherry picked from commit 2e59054d53d87d879e36055e12844811383d00f4)
Signed-off-by: Dongjoon Hyun <do...@apache.org>
---
.../apache/spark/deploy/k8s/KubernetesConf.scala | 6 ++++--
.../spark/deploy/k8s/KubernetesConfSuite.scala | 25 ++++++++++++++++++++++
2 files changed, 29 insertions(+), 2 deletions(-)
diff --git a/resource-managers/kubernetes/core/src/main/scala/org/apache/spark/deploy/k8s/KubernetesConf.scala b/resource-managers/kubernetes/core/src/main/scala/org/apache/spark/deploy/k8s/KubernetesConf.scala
index 22a21c2ed4aa..9070d6ce35ff 100644
--- a/resource-managers/kubernetes/core/src/main/scala/org/apache/spark/deploy/k8s/KubernetesConf.scala
+++ b/resource-managers/kubernetes/core/src/main/scala/org/apache/spark/deploy/k8s/KubernetesConf.scala
@@ -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)
@@ -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)
@@ -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),
diff --git a/resource-managers/kubernetes/core/src/test/scala/org/apache/spark/deploy/k8s/KubernetesConfSuite.scala b/resource-managers/kubernetes/core/src/test/scala/org/apache/spark/deploy/k8s/KubernetesConfSuite.scala
index 37778ff1bf8f..c1b3e8d6b252 100644
--- a/resource-managers/kubernetes/core/src/test/scala/org/apache/spark/deploy/k8s/KubernetesConfSuite.scala
+++ b/resource-managers/kubernetes/core/src/test/scala/org/apache/spark/deploy/k8s/KubernetesConfSuite.scala
@@ -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}}")
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org