chenjunjiedada commented on a change in pull request #24879: [SPARK-28042][K8S] 
Support using hostpath volume mount as local storage
URL: https://github.com/apache/spark/pull/24879#discussion_r294064371
 
 

 ##########
 File path: 
resource-managers/kubernetes/core/src/main/scala/org/apache/spark/deploy/k8s/features/LocalDirsFeatureStep.scala
 ##########
 @@ -43,20 +44,34 @@ private[spark] class LocalDirsFeatureStep(
     val localDirVolumes = resolvedLocalDirs
       .zipWithIndex
       .map { case (localDir, index) =>
-        new VolumeBuilder()
-          .withName(s"spark-local-dir-${index + 1}")
-          .withNewEmptyDir()
-            .withMedium(if (useLocalDirTmpFs) "Memory" else null)
-          .endEmptyDir()
-          .build()
+        val name = s"spark-local-dir-${index + 1}"
+        hasVolume(pod, name) match {
+          case true =>
+            pod.pod.getSpec.getVolumes().asScala.find(v => 
v.getName.equals(name)).get
+          case false =>
+            new VolumeBuilder()
+              .withName(s"spark-local-dir-${index + 1}")
+              .withNewEmptyDir()
+              .withMedium(if (useLocalDirTmpFs) "Memory" else null)
+              .endEmptyDir()
+              .build()
+        }
       }
     val localDirVolumeMounts = localDirVolumes
       .zip(resolvedLocalDirs)
       .map { case (localDirVolume, localDirPath) =>
-        new VolumeMountBuilder()
-          .withName(localDirVolume.getName)
-          .withMountPath(localDirPath)
-          .build()
+        hasVolumeMount(pod, localDirVolume.getName, localDirPath) match {
+          case true =>
+            pod.container.getVolumeMounts().asScala
+            .find(m => m.getName.equals(localDirVolume.getName)
 
 Review comment:
   ok, will check and run scalafmt.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to