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/09/22 00:31:48 UTC

(spark) branch branch-4.x updated: [SPARK-59702][4.X][K8S] Use `KeyToPathBuilder` instead of `KeyToPath` constructor

This is an automated email from the ASF dual-hosted git repository.

dongjoon-hyun pushed a commit to branch branch-4.x
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/branch-4.x by this push:
     new d9c20f6b6983 [SPARK-59702][4.X][K8S] Use `KeyToPathBuilder` instead of `KeyToPath` constructor
d9c20f6b6983 is described below

commit d9c20f6b698332bd1b6b669606ed47e20f14f944
Author: Dongjoon Hyun <do...@apache.org>
AuthorDate: Mon Sep 21 17:31:37 2026 -0700

    [SPARK-59702][4.X][K8S] Use `KeyToPathBuilder` instead of `KeyToPath` constructor
    
    ### What changes were proposed in this pull request?
    
    This PR aims to use the fluent `KeyToPathBuilder` instead of the positional `KeyToPath` constructor in `KubernetesClientUtils` and `ClientSuite`.
    
    ### Why are the changes needed?
    
    `KeyToPath` gains new fields as new Kubernetes versions are supported, and each addition changes the canonical constructor signature and breaks compilation. The builder names every field it sets and is already the prevailing style in this module (e.g. `HadoopConfDriverFeatureStep`, `KerberosConfDriverFeatureStep`).
    
    ### Does this PR introduce _any_ user-facing change?
    
    No. The builder produces the same `KeyToPath` objects as before.
    
    ### How was this patch tested?
    
    Pass the CIs.
    
    ### Was this patch authored or co-authored using generative AI tooling?
    
    Generated-by: Claude Opus 5
    
    Closes #58954 from dongjoon-hyun/SPARK-59702.
    
    Authored-by: Dongjoon Hyun <do...@apache.org>
    Signed-off-by: Dongjoon Hyun <do...@apache.org>
---
 .../apache/spark/deploy/k8s/submit/KubernetesClientUtils.scala    | 8 ++++++--
 .../scala/org/apache/spark/deploy/k8s/submit/ClientSuite.scala    | 8 +++++---
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/resource-managers/kubernetes/core/src/main/scala/org/apache/spark/deploy/k8s/submit/KubernetesClientUtils.scala b/resource-managers/kubernetes/core/src/main/scala/org/apache/spark/deploy/k8s/submit/KubernetesClientUtils.scala
index 005a6beff54f..9e735edf2df1 100644
--- a/resource-managers/kubernetes/core/src/main/scala/org/apache/spark/deploy/k8s/submit/KubernetesClientUtils.scala
+++ b/resource-managers/kubernetes/core/src/main/scala/org/apache/spark/deploy/k8s/submit/KubernetesClientUtils.scala
@@ -26,7 +26,7 @@ import scala.collection.mutable
 import scala.io.{Codec, Source}
 import scala.jdk.CollectionConverters._
 
-import io.fabric8.kubernetes.api.model.{ConfigMap, ConfigMapBuilder, KeyToPath}
+import io.fabric8.kubernetes.api.model.{ConfigMap, ConfigMapBuilder, KeyToPath, KeyToPathBuilder}
 
 import org.apache.spark.SparkConf
 import org.apache.spark.annotation.{DeveloperApi, Since, Stable}
@@ -113,7 +113,11 @@ object KubernetesClientUtils extends Logging {
     confFilesMap.map {
       case (fileName: String, _: String) =>
         val filePermissionMode = 420  // 420 is decimal for octal literal 0644.
-        new KeyToPath(fileName, filePermissionMode, fileName)
+        new KeyToPathBuilder()
+          .withKey(fileName)
+          .withMode(filePermissionMode)
+          .withPath(fileName)
+          .build()
     }.toList.sortBy(x => x.getKey) // List is sorted to make mocking based tests work
   }
 
diff --git a/resource-managers/kubernetes/core/src/test/scala/org/apache/spark/deploy/k8s/submit/ClientSuite.scala b/resource-managers/kubernetes/core/src/test/scala/org/apache/spark/deploy/k8s/submit/ClientSuite.scala
index c98654d6c02a..5e1aba066d80 100644
--- a/resource-managers/kubernetes/core/src/test/scala/org/apache/spark/deploy/k8s/submit/ClientSuite.scala
+++ b/resource-managers/kubernetes/core/src/test/scala/org/apache/spark/deploy/k8s/submit/ClientSuite.scala
@@ -90,8 +90,10 @@ class ClientSuite extends SparkFunSuite with BeforeAndAfter {
       .endVolumeMount()
     .build()
 
-  private val KEY_TO_PATH =
-    new KeyToPath(SPARK_CONF_FILE_NAME, 420, SPARK_CONF_FILE_NAME)
+  private def keyToPath(key: String): KeyToPath =
+    new KeyToPathBuilder().withKey(key).withMode(420).withPath(key).build()
+
+  private val KEY_TO_PATH = keyToPath(SPARK_CONF_FILE_NAME)
 
   private def fullExpectedPod(keyToPaths: List[KeyToPath] = List(KEY_TO_PATH)) =
     new PodBuilder(BUILT_DRIVER_POD)
@@ -306,7 +308,7 @@ class ClientSuite extends SparkFunSuite with BeforeAndAfter {
 
     val (sparkConf: SparkConf, expectedConfFiles: Seq[String]) = testSetup
 
-    val expectedKeyToPaths = (expectedConfFiles.map(x => new KeyToPath(x, 420, x)).toList ++
+    val expectedKeyToPaths = (expectedConfFiles.map(keyToPath).toList ++
       List(KEY_TO_PATH)).sortBy(x => x.getKey)
 
     when(podsWithNamespace.resource(fullExpectedPod(expectedKeyToPaths)))


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org