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 005a6beff54f5..9e735edf2df17 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 c98654d6c02aa..5e1aba066d80a 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)))