You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2022/07/15 11:24:01 UTC

[GitHub] [spark] pralabhkumar opened a new pull request, #37203: [SPARK-39755][CORE] Randomization in Spark local directory for other resource managers

pralabhkumar opened a new pull request, #37203:
URL: https://github.com/apache/spark/pull/37203

   
   ### What changes were proposed in this pull request?
   Added randomization in spark local directories 
   
   
   ### Why are the changes needed?
   Currently randomization is only applied when Spark run on Yarn. This brings the similar (https://issues.apache.org/jira/browse/SPARK-24992) issue if Spark run on K8s. 
   
   ### Does this PR introduce _any_ user-facing change?
   No
   
   
   ### How was this patch tested?
   Added unit test cases 
   


-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [spark] pralabhkumar commented on pull request #37203: [SPARK-39755][CORE] Randomization in Spark local directory for K8 resource managers

Posted by GitBox <gi...@apache.org>.
pralabhkumar commented on PR #37203:
URL: https://github.com/apache/spark/pull/37203#issuecomment-1194234764

   > To @pralabhkumar . The following two comments seems to be not applied properly at the final commit. Is it applied and reverted?
   > 
   > * [[SPARK-39755][CORE] Randomization in Spark local directory for K8 resource managers #37203 (review)](https://github.com/apache/spark/pull/37203#pullrequestreview-1045944162) (mine)
   > * [[SPARK-39755][CORE] Randomization in Spark local directory for K8 resource managers #37203 (comment)](https://github.com/apache/spark/pull/37203#discussion_r927667939) (@tgravescs 's)
   
   @dongjoon-hyun 
   Yes the first comment was applied , however @HyukjinKwon suggested to do the changes only w.r.t to K8s , therefore I had reverted it , because of which I didn't apply the second one . 


-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [spark] dongjoon-hyun commented on a diff in pull request #37203: [SPARK-39755][K8S] Randomization in Spark local directory for K8 resource managers

Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on code in PR #37203:
URL: https://github.com/apache/spark/pull/37203#discussion_r950519087


##########
resource-managers/kubernetes/core/src/main/scala/org/apache/spark/deploy/k8s/features/LocalDirsFeatureStep.scala:
##########
@@ -24,6 +24,7 @@ import io.fabric8.kubernetes.api.model._
 
 import org.apache.spark.deploy.k8s.{KubernetesConf, SparkPod}
 import org.apache.spark.deploy.k8s.Config._
+import org.apache.spark.util.Utils._

Review Comment:
   Please update like the following.
   ```scala
   - import org.apache.spark.util.Utils._
   + import org.apache.spark.util.Utils.randomizeInPlace
   ```



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [spark] pralabhkumar commented on a diff in pull request #37203: [SPARK-39755][CORE] Randomization in Spark local directory for K8 resource managers

Posted by GitBox <gi...@apache.org>.
pralabhkumar commented on code in PR #37203:
URL: https://github.com/apache/spark/pull/37203#discussion_r928888865


##########
core/src/main/scala/org/apache/spark/util/Utils.scala:
##########
@@ -919,8 +925,13 @@ private[spark] object Utils extends Logging {
       // created the directories already, and that they are secured so that only the
       // user has access to them.
       randomizeInPlace(getYarnLocalDirs(conf).split(","))
-    } else if (conf.getenv("SPARK_EXECUTOR_DIRS") != null) {
-      conf.getenv("SPARK_EXECUTOR_DIRS").split(File.pathSeparator)
+    } else if (isRunningInK8sContainer(conf)) {
+      // Randomizing the shuffle location in case of K8s so that all disk get fair changes to
+      // get selected.
+      randomizeInPlace(conf.getenv("SPARK_LOCAL_DIRS").split(","))

Review Comment:
   Hi @HyukjinKwon  Thx for the comment.  
   
   Comment : I am still not sure if this really safe to return the randomized directory whenever this method is invoked
   
   Response : I think this is already been happening  in case case of Yarn 
   
   - Logic for yarn is also similar . getConfiguredLocalDirs would return randomized location in case of yarn also in each call . However it is randomizing  LOCAL_DIRS .But it is also randomizing based on environment variables.
   
   https://github.com/apache/spark/blob/ae1f6a26ed39b297ace8d6c9420b72a3c01a3291/core/src/main/scala/org/apache/spark/util/Utils.scala#L921
   
   - Similar logic is being used in  shuffle.py https://github.com/apache/spark/blob/ae1f6a26ed39b297ace8d6c9420b72a3c01a3291/python/pyspark/shuffle.py#L82
   
   . Also have tested this in K8s cluster .  
   
   Since randomization is  already there on Yarn side, IMHO it should follow similar pattern on K8s .
   
   Please let me know if u want me to test for any specific scenario
    
   
   
   
   
   



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [spark] pralabhkumar commented on pull request #37203: [SPARK-39755][CORE] Randomization in Spark local directory for other resource managers

Posted by GitBox <gi...@apache.org>.
pralabhkumar commented on PR #37203:
URL: https://github.com/apache/spark/pull/37203#issuecomment-1192184850

   @dongjoon-hyun 
   Thx for reviewing PR.  
   > Just a question. Why not applying for `SPARK_EXECUTOR_DIRS` code path together, @pralabhkumar ?
   >  Applied 
   > https://github.com/apache/spark/blob/66b1f79b72855af35351ff995492f2c13872dac5/core/src/main/scala/org/apache/spark/util/Utils.scala#L922-L923
   > 
   > And, could you elaborate your issue in the PR description more, please?
   
   Added more description
   


-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [spark] tgravescs commented on a diff in pull request #37203: [SPARK-39755][CORE] Randomization in Spark local directory for other resource managers

Posted by GitBox <gi...@apache.org>.
tgravescs commented on code in PR #37203:
URL: https://github.com/apache/spark/pull/37203#discussion_r927667939


##########
core/src/main/scala/org/apache/spark/util/Utils.scala:
##########
@@ -937,7 +937,7 @@ private[spark] object Utils extends Logging {
       // In non-Yarn mode (or for the driver in yarn-client mode), we cannot trust the user
       // configuration to point to a secure directory. So create a subdirectory with restricted
       // permissions under each listed directory.
-      conf.get("spark.local.dir", System.getProperty("java.io.tmpdir")).split(",")
+      randomizeInPlace(conf.get("spark.local.dir", System.getProperty("java.io.tmpdir")).split(","))

Review Comment:
   if we are calling it in all cases then we should just get the dirs and then call it at the end.
   
   if val dirs = if (isRunningInYarnContainer(conf) {....}
   // return:
   randomizeInPlace(dirs)
   
   
   



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [spark] dongjoon-hyun commented on a diff in pull request #37203: [SPARK-39755][K8S] Randomization in Spark local directory for K8 resource managers

Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on code in PR #37203:
URL: https://github.com/apache/spark/pull/37203#discussion_r950733857


##########
resource-managers/kubernetes/core/src/test/scala/org/apache/spark/deploy/k8s/features/LocalDirsFeatureStepSuite.scala:
##########
@@ -52,41 +52,58 @@ class LocalDirsFeatureStepSuite extends SparkFunSuite {
   }
 
   test("Use configured local dirs split on comma if provided.") {

Review Comment:
   When I checked your PR 14 hours ago, it didn't fail. I'm not sure the current one because it's force-pushed again. In your case, simply loose the index condition to check `.get(0)` and `get(1)` instead of refactoring like this.



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [spark] dongjoon-hyun commented on a diff in pull request #37203: [SPARK-39755][K8S] Randomization in Spark local directory for K8 resource managers

Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on code in PR #37203:
URL: https://github.com/apache/spark/pull/37203#discussion_r950519708


##########
resource-managers/kubernetes/core/src/main/scala/org/apache/spark/deploy/k8s/features/LocalDirsFeatureStep.scala:
##########
@@ -35,9 +36,10 @@ private[spark] class LocalDirsFeatureStep(
   override def configurePod(pod: SparkPod): SparkPod = {
     var localDirs = pod.container.getVolumeMounts.asScala
       .filter(_.getName.startsWith("spark-local-dir-"))
-      .map(_.getMountPath)
+      .map(_.getMountPath).toArray

Review Comment:
   BTW, `Utils` has the following too.
   
   ```
   /**
      * Shuffle the elements of a collection into a random order, returning the
      * result in a new collection. Unlike scala.util.Random.shuffle, this method
      * uses a local random number generator, avoiding inter-thread contention.
      */
     def randomize[T: ClassTag](seq: TraversableOnce[T]): Seq[T] = {
       randomizeInPlace(seq.toArray)
     }
   ```



##########
resource-managers/kubernetes/core/src/main/scala/org/apache/spark/deploy/k8s/features/LocalDirsFeatureStep.scala:
##########
@@ -35,9 +36,10 @@ private[spark] class LocalDirsFeatureStep(
   override def configurePod(pod: SparkPod): SparkPod = {
     var localDirs = pod.container.getVolumeMounts.asScala
       .filter(_.getName.startsWith("spark-local-dir-"))
-      .map(_.getMountPath)
+      .map(_.getMountPath).toArray

Review Comment:
   BTW, `Utils` has the following too.
   
   ```scala
     def randomize[T: ClassTag](seq: TraversableOnce[T]): Seq[T] = {
       randomizeInPlace(seq.toArray)
     }
   ```



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [spark] dongjoon-hyun commented on pull request #37203: [SPARK-39755][K8S] Randomization in Spark local directory for K8 resource managers

Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on PR #37203:
URL: https://github.com/apache/spark/pull/37203#issuecomment-1221589990

   Sure, I'll recisit this Today.


-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [spark] dongjoon-hyun commented on a diff in pull request #37203: [SPARK-39755][CORE] Randomization in Spark local directory for K8 resource managers

Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on code in PR #37203:
URL: https://github.com/apache/spark/pull/37203#discussion_r929007005


##########
core/src/main/scala/org/apache/spark/util/Utils.scala:
##########
@@ -919,8 +925,13 @@ private[spark] object Utils extends Logging {
       // created the directories already, and that they are secured so that only the
       // user has access to them.
       randomizeInPlace(getYarnLocalDirs(conf).split(","))
-    } else if (conf.getenv("SPARK_EXECUTOR_DIRS") != null) {
-      conf.getenv("SPARK_EXECUTOR_DIRS").split(File.pathSeparator)
+    } else if (isRunningInK8sContainer(conf) && conf.getenv("SPARK_LOCAL_DIRS") != null) {
+      // Randomizing the shuffle location in case of K8s so that all disk get fair changes to
+      // get selected.
+      randomizeInPlace(conf.getenv("SPARK_LOCAL_DIRS").split(","))
+    }
+    else if (conf.getenv("SPARK_EXECUTOR_DIRS") != null) {
+     conf.getenv("SPARK_EXECUTOR_DIRS").split(File.pathSeparator)

Review Comment:
   Please recover indentation change here.



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [spark] dongjoon-hyun commented on a diff in pull request #37203: [SPARK-39755][K8S] Randomization in Spark local directory for K8 resource managers

Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on code in PR #37203:
URL: https://github.com/apache/spark/pull/37203#discussion_r950653293


##########
resource-managers/kubernetes/core/src/main/scala/org/apache/spark/deploy/k8s/features/LocalDirsFeatureStep.scala:
##########
@@ -33,12 +34,11 @@ private[spark] class LocalDirsFeatureStep(
   private val useLocalDirTmpFs = conf.get(KUBERNETES_LOCAL_DIRS_TMPFS)
 
   override def configurePod(pod: SparkPod): SparkPod = {
-    var localDirs = pod.container.getVolumeMounts.asScala
+    var localDirs = randomize(pod.container.getVolumeMounts.asScala
       .filter(_.getName.startsWith("spark-local-dir-"))
-      .map(_.getMountPath)
-    var localDirVolumes : Seq[Volume] = Seq()
-    var localDirVolumeMounts : Seq[VolumeMount] = Seq()
-

Review Comment:
   Please revert this removal.



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [spark] dongjoon-hyun commented on a diff in pull request #37203: [SPARK-39755][K8S] Randomization in Spark local directory for K8 resource managers

Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on code in PR #37203:
URL: https://github.com/apache/spark/pull/37203#discussion_r950653274


##########
core/src/test/scala/org/apache/spark/storage/LocalDirsSuite.scala:
##########
@@ -85,4 +85,5 @@ class LocalDirsSuite extends SparkFunSuite with LocalRootDirsTest {
     assert(!f1.exists())
     assert(!f2.exists())
   }
+

Review Comment:
   Please revert this, @pralabhkumar .



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [spark] pralabhkumar commented on pull request #37203: [SPARK-39755][CORE] Randomization in Spark local directory for K8 resource managers

Posted by GitBox <gi...@apache.org>.
pralabhkumar commented on PR #37203:
URL: https://github.com/apache/spark/pull/37203#issuecomment-1208165783

   @HyukjinKwon @dongjoon-hyun Ping to please review the PR and take it forward


-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [spark] pralabhkumar commented on pull request #37203: [SPARK-39755][CORE] Randomization in Spark local directory for other resource managers

Posted by GitBox <gi...@apache.org>.
pralabhkumar commented on PR #37203:
URL: https://github.com/apache/spark/pull/37203#issuecomment-1189298711

   > > IMHO , this should be randomized , so that all the directories have equal changes of pushing the data as was done on yarn side
   > 
   > Was there an actual problem that occurred because these were not random?
   
   @tgravescs 
   Yes we are seeing same problem(https://issues.apache.org/jira/browse/SPARK-24992) in our K8s cluster, where most of the time one disk get filled. 
   
   > 
   > how was this tested?
   
   
   I had tested this via unit test cases . Also ran internally  on K8s cluster and seen executor logs . There have seen the disk get randomized on different executors. 
   
   


-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [spark] tgravescs commented on pull request #37203: [SPARK-39755][CORE] Randomization in Spark local directory for other resource managers

Posted by GitBox <gi...@apache.org>.
tgravescs commented on PR #37203:
URL: https://github.com/apache/spark/pull/37203#issuecomment-1192593051

   ok to test


-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [spark] dongjoon-hyun commented on a diff in pull request #37203: [SPARK-39755][K8S] Randomization in Spark local directory for K8 resource managers

Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on code in PR #37203:
URL: https://github.com/apache/spark/pull/37203#discussion_r950733857


##########
resource-managers/kubernetes/core/src/test/scala/org/apache/spark/deploy/k8s/features/LocalDirsFeatureStepSuite.scala:
##########
@@ -52,41 +52,58 @@ class LocalDirsFeatureStepSuite extends SparkFunSuite {
   }
 
   test("Use configured local dirs split on comma if provided.") {

Review Comment:
   In that case, simply loose the index condition to check `.get(0)` and `get(1)` instead of refactoring like this.



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [spark] pralabhkumar commented on a diff in pull request #37203: [SPARK-39755][K8S] Randomization in Spark local directory for K8 resource managers

Posted by GitBox <gi...@apache.org>.
pralabhkumar commented on code in PR #37203:
URL: https://github.com/apache/spark/pull/37203#discussion_r950664130


##########
resource-managers/kubernetes/core/src/test/scala/org/apache/spark/deploy/k8s/features/LocalDirsFeatureStepSuite.scala:
##########
@@ -52,41 +52,58 @@ class LocalDirsFeatureStepSuite extends SparkFunSuite {
   }
 
   test("Use configured local dirs split on comma if provided.") {

Review Comment:
   @dongjoon-hyun  After randomization , this test case will fail , since this test case is always expecting 
   ```
   assert(configuredPod.container.getVolumeMounts.get(0) ===
         new VolumeMountBuilder()
           .withName(s"spark-local-dir-1")
           .withMountPath("/var/data/my-local-dir-1")
           .build())
   ```
   
   which is not true always since , locations are randomized.  Also  test case is expecting env variable as always 
   /var/data/my-local-dir-1,/var/data/my-local-dir-2 which is not true after randomization. 
   
   ```
   assert(configuredPod.container.getEnv.get(0) ===
         new EnvVarBuilder()
           .withName("SPARK_LOCAL_DIRS")
           .withValue("/var/data/my-local-dir-1,/var/data/my-local-dir-2")
           .build())
   ```
   
   Therefore have changed the test case to take care of randomization. 
   
   



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [spark] pralabhkumar commented on a diff in pull request #37203: [SPARK-39755][CORE] Randomization in Spark local directory for K8 resource managers

Posted by GitBox <gi...@apache.org>.
pralabhkumar commented on code in PR #37203:
URL: https://github.com/apache/spark/pull/37203#discussion_r928888865


##########
core/src/main/scala/org/apache/spark/util/Utils.scala:
##########
@@ -919,8 +925,13 @@ private[spark] object Utils extends Logging {
       // created the directories already, and that they are secured so that only the
       // user has access to them.
       randomizeInPlace(getYarnLocalDirs(conf).split(","))
-    } else if (conf.getenv("SPARK_EXECUTOR_DIRS") != null) {
-      conf.getenv("SPARK_EXECUTOR_DIRS").split(File.pathSeparator)
+    } else if (isRunningInK8sContainer(conf)) {
+      // Randomizing the shuffle location in case of K8s so that all disk get fair changes to
+      // get selected.
+      randomizeInPlace(conf.getenv("SPARK_LOCAL_DIRS").split(","))

Review Comment:
   Hi @HyukjinKwon  Thx for the comment.  
   
   - Logic for yarn is also similar . getConfiguredLocalDirs would return randomized location in case of yarn also in each call . However it is randomizing  LOCAL_DIRS .But it is also randomizing based on environment variables.
   
   https://github.com/apache/spark/blob/ae1f6a26ed39b297ace8d6c9420b72a3c01a3291/core/src/main/scala/org/apache/spark/util/Utils.scala#L921
   
   - Similar logic is being used in  shuffle.py https://github.com/apache/spark/blob/ae1f6a26ed39b297ace8d6c9420b72a3c01a3291/python/pyspark/shuffle.py#L82
   
   . Also have tested this in K8s cluster .  
   
   Since randomization is  already there on Yarn side, IMHO it should follow similar pattern on K8s .
   
   Please let me know if u want me to test for any specific scenario
    
   
   
   
   
   



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [spark] dongjoon-hyun commented on a diff in pull request #37203: [SPARK-39755][CORE] Randomization in Spark local directory for K8 resource managers

Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on code in PR #37203:
URL: https://github.com/apache/spark/pull/37203#discussion_r929007805


##########
core/src/test/scala/org/apache/spark/storage/LocalDirsSuite.scala:
##########
@@ -85,4 +85,24 @@ class LocalDirsSuite extends SparkFunSuite with LocalRootDirsTest {
     assert(!f1.exists())
     assert(!f2.exists())
   }
+
+  test("SPARK-39755: Test randomness in SPARK_LOCAL_DIRS for K8s master") {
+    val path1 = "PATH_ONE"
+    val path2 = "PATH_TWO"
+    val conf = new SparkConfWithEnv(Map("SPARK_LOCAL_DIRS" -> "PATH_ONE,PATH_TWO"))
+    conf.set("spark.master", "k8s://test")
+    val index_of_path1 = Array(false, false)
+    for (index <- 0 to 10) {
+      val data = Utils.getConfiguredLocalDirs(conf)
+      if (data(0).equals("PATH_ONE")) {
+        index_of_path1(0) = true
+      }
+      if (data(1).equals("PATH_ONE")) {
+        index_of_path1(1) = true
+      }
+    }
+    assert(index_of_path1(0))
+    assert(index_of_path1(1))
+  }
+

Review Comment:
   nit. redundant empty line.



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [spark] dongjoon-hyun commented on a diff in pull request #37203: [SPARK-39755][CORE] Randomization in Spark local directory for K8 resource managers

Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on code in PR #37203:
URL: https://github.com/apache/spark/pull/37203#discussion_r929009563


##########
core/src/main/scala/org/apache/spark/util/Utils.scala:
##########
@@ -937,7 +937,7 @@ private[spark] object Utils extends Logging {
       // In non-Yarn mode (or for the driver in yarn-client mode), we cannot trust the user
       // configuration to point to a secure directory. So create a subdirectory with restricted
       // permissions under each listed directory.
-      conf.get("spark.local.dir", System.getProperty("java.io.tmpdir")).split(",")
+      randomizeInPlace(conf.get("spark.local.dir", System.getProperty("java.io.tmpdir")).split(","))

Review Comment:
   +1



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [spark] mridulm commented on a diff in pull request #37203: [SPARK-39755][CORE] Randomization in Spark local directory for K8 resource managers

Posted by GitBox <gi...@apache.org>.
mridulm commented on code in PR #37203:
URL: https://github.com/apache/spark/pull/37203#discussion_r929414978


##########
core/src/main/scala/org/apache/spark/util/Utils.scala:
##########
@@ -880,6 +880,12 @@ private[spark] object Utils extends Logging {
     conf.getenv("CONTAINER_ID") != null
   }
 
+  private[spark] def isRunningInK8sContainer(conf: SparkConf): Boolean = {
+    // Master must start with K8s in case of kubernetes
+    conf.contains("spark.master") && conf.get("spark.master") != null &&
+      conf.get("spark.master").startsWith("k8s://")

Review Comment:
   nit: `conf.getOption("spark.master").exists(_.startsWith("k8s://"))` ?



##########
core/src/main/scala/org/apache/spark/util/Utils.scala:
##########
@@ -919,8 +925,13 @@ private[spark] object Utils extends Logging {
       // created the directories already, and that they are secured so that only the
       // user has access to them.
       randomizeInPlace(getYarnLocalDirs(conf).split(","))
-    } else if (conf.getenv("SPARK_EXECUTOR_DIRS") != null) {
-      conf.getenv("SPARK_EXECUTOR_DIRS").split(File.pathSeparator)
+    } else if (isRunningInK8sContainer(conf)) {
+      // Randomizing the shuffle location in case of K8s so that all disk get fair changes to
+      // get selected.
+      randomizeInPlace(conf.getenv("SPARK_LOCAL_DIRS").split(","))

Review Comment:
   QQ: I see both `SPARK_LOCAL_DIRS` and `SPARK_EXECUTOR_DIRS` in use within k8s resource manager - do we not want to do this for `SPARK_EXECUTOR_DIRS` @dongjoon-hyun ?



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [spark] dongjoon-hyun closed pull request #37203: [SPARK-39755][K8S] Improve `LocalDirsFeatureStep` to randomize local directories

Posted by GitBox <gi...@apache.org>.
dongjoon-hyun closed pull request #37203: [SPARK-39755][K8S] Improve `LocalDirsFeatureStep` to randomize local directories
URL: https://github.com/apache/spark/pull/37203


-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [spark] AmplabJenkins commented on pull request #37203: [SPARK-39755][CORE] Randomization in Spark local directory for other resource managers

Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on PR #37203:
URL: https://github.com/apache/spark/pull/37203#issuecomment-1186115503

   Can one of the admins verify this patch?


-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [spark] HyukjinKwon commented on a diff in pull request #37203: [SPARK-39755][CORE] Randomization in Spark local directory for other resource managers

Posted by GitBox <gi...@apache.org>.
HyukjinKwon commented on code in PR #37203:
URL: https://github.com/apache/spark/pull/37203#discussion_r928860500


##########
core/src/main/scala/org/apache/spark/util/Utils.scala:
##########
@@ -919,8 +925,13 @@ private[spark] object Utils extends Logging {
       // created the directories already, and that they are secured so that only the
       // user has access to them.
       randomizeInPlace(getYarnLocalDirs(conf).split(","))
-    } else if (conf.getenv("SPARK_EXECUTOR_DIRS") != null) {
-      conf.getenv("SPARK_EXECUTOR_DIRS").split(File.pathSeparator)
+    } else if (isRunningInK8sContainer(conf)) {
+      // Randomizing the shuffle location in case of K8s so that all disk get fair changes to
+      // get selected.
+      randomizeInPlace(conf.getenv("SPARK_LOCAL_DIRS").split(","))

Review Comment:
   I am still not sure if this really safe to return the randomized directory whenever this method is invoked. This configuration (spark.local.dir) and environment variables are meant to be immutable but this is changing it here for every call during runtime.
   
   Since this relates to the code path in which we should be relatively more strict, I would suggest to thoroughly investigate all the related paths TBH since we're breaking the assumption.



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [spark] pralabhkumar commented on a diff in pull request #37203: [SPARK-39755][CORE] Randomization in Spark local directory for K8 resource managers

Posted by GitBox <gi...@apache.org>.
pralabhkumar commented on code in PR #37203:
URL: https://github.com/apache/spark/pull/37203#discussion_r928888865


##########
core/src/main/scala/org/apache/spark/util/Utils.scala:
##########
@@ -919,8 +925,13 @@ private[spark] object Utils extends Logging {
       // created the directories already, and that they are secured so that only the
       // user has access to them.
       randomizeInPlace(getYarnLocalDirs(conf).split(","))
-    } else if (conf.getenv("SPARK_EXECUTOR_DIRS") != null) {
-      conf.getenv("SPARK_EXECUTOR_DIRS").split(File.pathSeparator)
+    } else if (isRunningInK8sContainer(conf)) {
+      // Randomizing the shuffle location in case of K8s so that all disk get fair changes to
+      // get selected.
+      randomizeInPlace(conf.getenv("SPARK_LOCAL_DIRS").split(","))

Review Comment:
   Hi @HyukjinKwon  Thx for the comment.  
   
   I am still not sure if this really safe to return the randomized directory whenever this method is invoked
   
   Response : I think this is already been done  in case case of Yarn 
   
   - Logic for yarn is also similar . getConfiguredLocalDirs would return randomized location in case of yarn also in each call . However it is randomizing  LOCAL_DIRS .But it is also randomizing based on environment variables.
   
   https://github.com/apache/spark/blob/ae1f6a26ed39b297ace8d6c9420b72a3c01a3291/core/src/main/scala/org/apache/spark/util/Utils.scala#L921
   
   - Similar logic is being used in  shuffle.py https://github.com/apache/spark/blob/ae1f6a26ed39b297ace8d6c9420b72a3c01a3291/python/pyspark/shuffle.py#L82
   
   . Also have tested this in K8s cluster .  
   
   Since randomization is  already there on Yarn side, IMHO it should follow similar pattern on K8s .
   
   Please let me know if u want me to test for any specific scenario
    
   
   
   
   
   



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [spark] dongjoon-hyun commented on pull request #37203: [SPARK-39755][K8S] Improve `LocalDirsFeatureStep` to randomize local directories

Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on PR #37203:
URL: https://github.com/apache/spark/pull/37203#issuecomment-1222440852

   Thank you, @tgravescs , @mridulm , @cloud-fan , @HyukjinKwon , too.
   This is a pure K8s module PR now and landed to Apache Spark 3.4.0.


-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [spark] pralabhkumar commented on pull request #37203: [SPARK-39755][K8S] Improve `LocalDirsFeatureStep` to randomize local directories

Posted by GitBox <gi...@apache.org>.
pralabhkumar commented on PR #37203:
URL: https://github.com/apache/spark/pull/37203#issuecomment-1222462077

   Thx for all the help provided during review @dongjoon-hyun


-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [spark] pralabhkumar commented on pull request #37203: [SPARK-39755][CORE] Randomization in Spark local directory for other resource managers

Posted by GitBox <gi...@apache.org>.
pralabhkumar commented on PR #37203:
URL: https://github.com/apache/spark/pull/37203#issuecomment-1189287282

   Please review the PR . 
   


-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [spark] pralabhkumar commented on pull request #37203: [SPARK-39755][CORE] Randomization in Spark local directory for other resource managers

Posted by GitBox <gi...@apache.org>.
pralabhkumar commented on PR #37203:
URL: https://github.com/apache/spark/pull/37203#issuecomment-1192701195

   I think build is failing because of unrelated changes (since test cases are passing in local) . Please let me know if I am missing something


-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [spark] pralabhkumar commented on pull request #37203: [SPARK-39755][CORE] Randomization in Spark local directory for K8 resource managers

Posted by GitBox <gi...@apache.org>.
pralabhkumar commented on PR #37203:
URL: https://github.com/apache/spark/pull/37203#issuecomment-1201957796

   @HyukjinKwon @cloud-fan @dongjoon-hyun Please find some time to review the PR . 


-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [spark] pralabhkumar commented on pull request #37203: [SPARK-39755][CORE] Randomization in Spark local directory for K8 resource managers

Posted by GitBox <gi...@apache.org>.
pralabhkumar commented on PR #37203:
URL: https://github.com/apache/spark/pull/37203#issuecomment-1196241951

   @mridulm @cloud-fan @tgravescs @HyukjinKwon @dongjoon-hyun 
   
   Have addressed all the review comments. Please guide me to take this further . 


-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [spark] pralabhkumar commented on pull request #37203: [SPARK-39755][CORE] Randomization in Spark local directory for K8 resource managers

Posted by GitBox <gi...@apache.org>.
pralabhkumar commented on PR #37203:
URL: https://github.com/apache/spark/pull/37203#issuecomment-1200636478

   Gentle ping to review the PR 


-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [spark] dongjoon-hyun commented on a diff in pull request #37203: [SPARK-39755][K8S] Randomization in Spark local directory for K8 resource managers

Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on code in PR #37203:
URL: https://github.com/apache/spark/pull/37203#discussion_r950654693


##########
resource-managers/kubernetes/core/src/test/scala/org/apache/spark/deploy/k8s/features/LocalDirsFeatureStepSuite.scala:
##########
@@ -52,41 +52,58 @@ class LocalDirsFeatureStepSuite extends SparkFunSuite {
   }
 
   test("Use configured local dirs split on comma if provided.") {

Review Comment:
   Please avoid changing the existing test coverage. Instead, we recommend to add a new test coverage as a new test case with test name prefix, `SPARK-39755: `. Technically, this test case doesn't fail with your PR, does it?



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [spark] tgravescs commented on pull request #37203: [SPARK-39755][CORE] Randomization in Spark local directory for other resource managers

Posted by GitBox <gi...@apache.org>.
tgravescs commented on PR #37203:
URL: https://github.com/apache/spark/pull/37203#issuecomment-1189147237

   > IMHO , this should be randomized , so that all the directories have equal changes of pushing the data as was done on yarn side
   
   Was there an actual problem that occurred because these were not random?  
   
   how was this tested?


-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [spark] cloud-fan commented on a diff in pull request #37203: [SPARK-39755][CORE] Randomization in Spark local directory for other resource managers

Posted by GitBox <gi...@apache.org>.
cloud-fan commented on code in PR #37203:
URL: https://github.com/apache/spark/pull/37203#discussion_r928590099


##########
core/src/test/scala/org/apache/spark/storage/LocalDirsSuite.scala:
##########
@@ -79,10 +79,33 @@ class LocalDirsSuite extends SparkFunSuite with LocalRootDirsTest {
     }.getMessage
     // If any temporary directory could not be retrieved under the given paths above, it should
     // throw an exception with the message that includes the paths.
-    assert(message.contains(s"$path1,$path2"))
+    assert(message.contains(s"$path1,$path2") || message.contains(s"$path2,$path1"))
 
     // These directories should not be created.
     assert(!f1.exists())
     assert(!f2.exists())
   }
+
+  test("SPARK-39755 : Test randomness in SPARK_LOCAL_DIRS, SPARK_EXECUTOR_DIRS") {

Review Comment:
   ```suggestion
     test("SPARK-39755: Test randomness in SPARK_LOCAL_DIRS, SPARK_EXECUTOR_DIRS") {
   ```



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [spark] pralabhkumar commented on a diff in pull request #37203: [SPARK-39755][CORE] Randomization in Spark local directory for K8 resource managers

Posted by GitBox <gi...@apache.org>.
pralabhkumar commented on code in PR #37203:
URL: https://github.com/apache/spark/pull/37203#discussion_r929033412


##########
core/src/main/scala/org/apache/spark/util/Utils.scala:
##########
@@ -919,8 +925,13 @@ private[spark] object Utils extends Logging {
       // created the directories already, and that they are secured so that only the
       // user has access to them.
       randomizeInPlace(getYarnLocalDirs(conf).split(","))
-    } else if (conf.getenv("SPARK_EXECUTOR_DIRS") != null) {
-      conf.getenv("SPARK_EXECUTOR_DIRS").split(File.pathSeparator)
+    } else if (isRunningInK8sContainer(conf) && conf.getenv("SPARK_LOCAL_DIRS") != null) {
+      // Randomizing the shuffle location in case of K8s so that all disk get fair changes to
+      // get selected.
+      randomizeInPlace(conf.getenv("SPARK_LOCAL_DIRS").split(","))
+    }
+    else if (conf.getenv("SPARK_EXECUTOR_DIRS") != null) {
+     conf.getenv("SPARK_EXECUTOR_DIRS").split(File.pathSeparator)

Review Comment:
   will do 



##########
core/src/test/scala/org/apache/spark/storage/LocalDirsSuite.scala:
##########
@@ -85,4 +85,24 @@ class LocalDirsSuite extends SparkFunSuite with LocalRootDirsTest {
     assert(!f1.exists())
     assert(!f2.exists())
   }
+
+  test("SPARK-39755: Test randomness in SPARK_LOCAL_DIRS for K8s master") {
+    val path1 = "PATH_ONE"
+    val path2 = "PATH_TWO"
+    val conf = new SparkConfWithEnv(Map("SPARK_LOCAL_DIRS" -> "PATH_ONE,PATH_TWO"))
+    conf.set("spark.master", "k8s://test")
+    val index_of_path1 = Array(false, false)
+    for (index <- 0 to 10) {
+      val data = Utils.getConfiguredLocalDirs(conf)
+      if (data(0).equals("PATH_ONE")) {
+        index_of_path1(0) = true
+      }
+      if (data(1).equals("PATH_ONE")) {
+        index_of_path1(1) = true
+      }
+    }
+    assert(index_of_path1(0))
+    assert(index_of_path1(1))
+  }
+

Review Comment:
   will do 



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [spark] pralabhkumar commented on pull request #37203: [SPARK-39755][CORE] Randomization in Spark local directory for K8 resource managers

Posted by GitBox <gi...@apache.org>.
pralabhkumar commented on PR #37203:
URL: https://github.com/apache/spark/pull/37203#issuecomment-1197662779

   @dongjoon-hyun can u please review. 


-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [spark] dongjoon-hyun commented on a diff in pull request #37203: [SPARK-39755][CORE] Randomization in Spark local directory for K8 resource managers

Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on code in PR #37203:
URL: https://github.com/apache/spark/pull/37203#discussion_r943873697


##########
core/src/main/scala/org/apache/spark/util/Utils.scala:
##########
@@ -919,8 +925,13 @@ private[spark] object Utils extends Logging {
       // created the directories already, and that they are secured so that only the
       // user has access to them.
       randomizeInPlace(getYarnLocalDirs(conf).split(","))
-    } else if (conf.getenv("SPARK_EXECUTOR_DIRS") != null) {
-      conf.getenv("SPARK_EXECUTOR_DIRS").split(File.pathSeparator)
+    } else if (isRunningInK8sContainer(conf)) {
+      // Randomizing the shuffle location in case of K8s so that all disk get fair changes to
+      // get selected.
+      randomizeInPlace(conf.getenv("SPARK_LOCAL_DIRS").split(","))

Review Comment:
   > QQ: I see both `SPARK_LOCAL_DIRS` and `SPARK_EXECUTOR_DIRS` in use within k8s resource manager - do we not want to do this for `SPARK_EXECUTOR_DIRS` @dongjoon-hyun ?
   
   We want it, @mridulm . That was my first comment here.
   - https://github.com/apache/spark/pull/37203#pullrequestreview-1045944162



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [spark] dongjoon-hyun commented on a diff in pull request #37203: [SPARK-39755][K8S] Randomization in Spark local directory for K8 resource managers

Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on code in PR #37203:
URL: https://github.com/apache/spark/pull/37203#discussion_r950734114


##########
resource-managers/kubernetes/core/src/main/scala/org/apache/spark/deploy/k8s/features/LocalDirsFeatureStep.scala:
##########
@@ -33,12 +34,11 @@ private[spark] class LocalDirsFeatureStep(
   private val useLocalDirTmpFs = conf.get(KUBERNETES_LOCAL_DIRS_TMPFS)
 
   override def configurePod(pod: SparkPod): SparkPod = {
-    var localDirs = pod.container.getVolumeMounts.asScala
+    var localDirs = randomize(pod.container.getVolumeMounts.asScala
       .filter(_.getName.startsWith("spark-local-dir-"))
-      .map(_.getMountPath)
-    var localDirVolumes : Seq[Volume] = Seq()
-    var localDirVolumeMounts : Seq[VolumeMount] = Seq()
-

Review Comment:
   What I pointed was the removal of that empty line after `var localDirVolumeMounts`.
   
   <img width="1202" alt="Screen Shot 2022-08-20 at 12 45 14 PM" 
   src="https://user-images.githubusercontent.com/9700541/185763765-0be7e2df-b13d-4ecf-83b2-f4af6079e408.png">
   



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [spark] pralabhkumar commented on a diff in pull request #37203: [SPARK-39755][K8S] Randomization in Spark local directory for K8 resource managers

Posted by GitBox <gi...@apache.org>.
pralabhkumar commented on code in PR #37203:
URL: https://github.com/apache/spark/pull/37203#discussion_r950664881


##########
resource-managers/kubernetes/core/src/main/scala/org/apache/spark/deploy/k8s/features/LocalDirsFeatureStep.scala:
##########
@@ -68,9 +69,8 @@ private[spark] class LocalDirsFeatureStep(
             .withName(localDirVolume.getName)
             .withMountPath(localDirPath)
             .build()
-          }
+        }
     }
-

Review Comment:
   done



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [spark] pralabhkumar commented on pull request #37203: [SPARK-39755][K8S] Improve `LocalDirsFeatureStep` to randomize local directories

Posted by GitBox <gi...@apache.org>.
pralabhkumar commented on PR #37203:
URL: https://github.com/apache/spark/pull/37203#issuecomment-1222429187

   @dongjoon-hyun . Thx for reviewing. 
   1. Yes we tested in our cluster . It helps to randomly pic shuffle locations , which helps in equal  data distribution for disks .
   2. I'll create a seperate Jira for the SPARK_EXECUTOR_DIRS . 
   
   
   


-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [spark] pralabhkumar commented on pull request #37203: [SPARK-39755][CORE] Randomization in Spark local directory for K8 resource managers

Posted by GitBox <gi...@apache.org>.
pralabhkumar commented on PR #37203:
URL: https://github.com/apache/spark/pull/37203#issuecomment-1217454964

   @dongjoon-hyun . Thx for reviewing it .  Let me rework on the PR as suggested. 


-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [spark] cloud-fan commented on a diff in pull request #37203: [SPARK-39755][CORE] Randomization in Spark local directory for other resource managers

Posted by GitBox <gi...@apache.org>.
cloud-fan commented on code in PR #37203:
URL: https://github.com/apache/spark/pull/37203#discussion_r928589465


##########
core/src/main/scala/org/apache/spark/util/Utils.scala:
##########
@@ -937,7 +937,7 @@ private[spark] object Utils extends Logging {
       // In non-Yarn mode (or for the driver in yarn-client mode), we cannot trust the user
       // configuration to point to a secure directory. So create a subdirectory with restricted
       // permissions under each listed directory.
-      conf.get("spark.local.dir", System.getProperty("java.io.tmpdir")).split(",")
+      randomizeInPlace(conf.get("spark.local.dir", System.getProperty("java.io.tmpdir")).split(","))

Review Comment:
   +1



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [spark] HyukjinKwon commented on a diff in pull request #37203: [SPARK-39755][CORE] Randomization in Spark local directory for other resource managers

Posted by GitBox <gi...@apache.org>.
HyukjinKwon commented on code in PR #37203:
URL: https://github.com/apache/spark/pull/37203#discussion_r928860500


##########
core/src/main/scala/org/apache/spark/util/Utils.scala:
##########
@@ -919,8 +925,13 @@ private[spark] object Utils extends Logging {
       // created the directories already, and that they are secured so that only the
       // user has access to them.
       randomizeInPlace(getYarnLocalDirs(conf).split(","))
-    } else if (conf.getenv("SPARK_EXECUTOR_DIRS") != null) {
-      conf.getenv("SPARK_EXECUTOR_DIRS").split(File.pathSeparator)
+    } else if (isRunningInK8sContainer(conf)) {
+      // Randomizing the shuffle location in case of K8s so that all disk get fair changes to
+      // get selected.
+      randomizeInPlace(conf.getenv("SPARK_LOCAL_DIRS").split(","))

Review Comment:
   I am still not sure if this really safe to return the randomized directory whenever this method is invoked. This configuration (spark.local.dir) and environment variables are meant to be immutable but this is changing it here for every call during runtime.
   
   Since this relates to the core path in which we should be relatively more strict, I would suggest to thoroughly investigate all the related paths TBH since we're breaking the assumption.



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [spark] pralabhkumar commented on a diff in pull request #37203: [SPARK-39755][CORE] Randomization in Spark local directory for K8 resource managers

Posted by GitBox <gi...@apache.org>.
pralabhkumar commented on code in PR #37203:
URL: https://github.com/apache/spark/pull/37203#discussion_r928888865


##########
core/src/main/scala/org/apache/spark/util/Utils.scala:
##########
@@ -919,8 +925,13 @@ private[spark] object Utils extends Logging {
       // created the directories already, and that they are secured so that only the
       // user has access to them.
       randomizeInPlace(getYarnLocalDirs(conf).split(","))
-    } else if (conf.getenv("SPARK_EXECUTOR_DIRS") != null) {
-      conf.getenv("SPARK_EXECUTOR_DIRS").split(File.pathSeparator)
+    } else if (isRunningInK8sContainer(conf)) {
+      // Randomizing the shuffle location in case of K8s so that all disk get fair changes to
+      // get selected.
+      randomizeInPlace(conf.getenv("SPARK_LOCAL_DIRS").split(","))

Review Comment:
   Hi @HyukjinKwon  Thx for the comment.  
   
   Comment : I am still not sure if this really safe to return the randomized directory whenever this method is invoked
   
   Response : I think this is already been done  in case case of Yarn 
   
   - Logic for yarn is also similar . getConfiguredLocalDirs would return randomized location in case of yarn also in each call . However it is randomizing  LOCAL_DIRS .But it is also randomizing based on environment variables.
   
   https://github.com/apache/spark/blob/ae1f6a26ed39b297ace8d6c9420b72a3c01a3291/core/src/main/scala/org/apache/spark/util/Utils.scala#L921
   
   - Similar logic is being used in  shuffle.py https://github.com/apache/spark/blob/ae1f6a26ed39b297ace8d6c9420b72a3c01a3291/python/pyspark/shuffle.py#L82
   
   . Also have tested this in K8s cluster .  
   
   Since randomization is  already there on Yarn side, IMHO it should follow similar pattern on K8s .
   
   Please let me know if u want me to test for any specific scenario
    
   
   
   
   
   



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [spark] tgravescs commented on pull request #37203: [SPARK-39755][CORE] Randomization in Spark local directory for other resource managers

Posted by GitBox <gi...@apache.org>.
tgravescs commented on PR #37203:
URL: https://github.com/apache/spark/pull/37203#issuecomment-1192592856

   It would be nice to get feedback from folks running standalone.  @cloud-fan @HyukjinKwon 


-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [spark] pralabhkumar commented on pull request #37203: [SPARK-39755][CORE] Randomization in Spark local directory for other resource managers

Posted by GitBox <gi...@apache.org>.
pralabhkumar commented on PR #37203:
URL: https://github.com/apache/spark/pull/37203#issuecomment-1193098967

   @dongjoon-hyun  I rebase and pushed the changes . However, I think  build is failing because of unrelated changes . 
   Please help 


-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [spark] HyukjinKwon commented on a diff in pull request #37203: [SPARK-39755][CORE] Randomization in Spark local directory for other resource managers

Posted by GitBox <gi...@apache.org>.
HyukjinKwon commented on code in PR #37203:
URL: https://github.com/apache/spark/pull/37203#discussion_r928339985


##########
core/src/main/scala/org/apache/spark/util/Utils.scala:
##########
@@ -920,9 +920,9 @@ private[spark] object Utils extends Logging {
       // user has access to them.
       randomizeInPlace(getYarnLocalDirs(conf).split(","))
     } else if (conf.getenv("SPARK_EXECUTOR_DIRS") != null) {
-      conf.getenv("SPARK_EXECUTOR_DIRS").split(File.pathSeparator)
+      randomizeInPlace(conf.getenv("SPARK_EXECUTOR_DIRS").split(File.pathSeparator))

Review Comment:
   Hm, quick question though. `getConfiguredLocalDirs` gets invoked multiple times, and won't it return a different directory every time when it's called?
   
   This `spark.local.dir` can be used to pass `spark.files` around, e.g., `SparkFiles.get`. Wonder if that would be affected.
   
   If this is a K8S specific issue, I think it's best to localize the fix into K8S.



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [spark] HyukjinKwon commented on pull request #37203: [SPARK-39755][CORE] Randomization in Spark local directory for other resource managers

Posted by GitBox <gi...@apache.org>.
HyukjinKwon commented on PR #37203:
URL: https://github.com/apache/spark/pull/37203#issuecomment-1193438451

   Yeah, doesn't seem related. You can retrigger the failed tests for doubly sure rough


-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [spark] dongjoon-hyun commented on pull request #37203: [SPARK-39755][CORE] Randomization in Spark local directory for K8 resource managers

Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on PR #37203:
URL: https://github.com/apache/spark/pull/37203#issuecomment-1194194452

   To @pralabhkumar . The following two comments seems to be not applied properly at the final commit. Is it applied and reverted?
   - https://github.com/apache/spark/pull/37203#pullrequestreview-1045944162 (mine)
   - https://github.com/apache/spark/pull/37203#discussion_r927667939 (@tgravescs 's)


-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [spark] dongjoon-hyun commented on a diff in pull request #37203: [SPARK-39755][K8S] Randomization in Spark local directory for K8 resource managers

Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on code in PR #37203:
URL: https://github.com/apache/spark/pull/37203#discussion_r950521862


##########
resource-managers/kubernetes/core/src/main/scala/org/apache/spark/deploy/k8s/features/LocalDirsFeatureStep.scala:
##########
@@ -35,9 +36,10 @@ private[spark] class LocalDirsFeatureStep(
   override def configurePod(pod: SparkPod): SparkPod = {
     var localDirs = pod.container.getVolumeMounts.asScala
       .filter(_.getName.startsWith("spark-local-dir-"))
-      .map(_.getMountPath)
+      .map(_.getMountPath).toArray
     var localDirVolumes : Seq[Volume] = Seq()
     var localDirVolumeMounts : Seq[VolumeMount] = Seq()
+    var isShuffleLocationRandomized : Boolean = false

Review Comment:
   Why do we have this? You can randomize `localDirs` at line 37.



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [spark] pralabhkumar commented on pull request #37203: [SPARK-39755][K8S] Randomization in Spark local directory for K8 resource managers

Posted by GitBox <gi...@apache.org>.
pralabhkumar commented on PR #37203:
URL: https://github.com/apache/spark/pull/37203#issuecomment-1221580952

   @dongjoon-hyun  fixed all comments and build is also passing . please review


-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [spark] dongjoon-hyun commented on a diff in pull request #37203: [SPARK-39755][K8S] Randomization in Spark local directory for K8 resource managers

Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on code in PR #37203:
URL: https://github.com/apache/spark/pull/37203#discussion_r950653318


##########
resource-managers/kubernetes/core/src/main/scala/org/apache/spark/deploy/k8s/features/LocalDirsFeatureStep.scala:
##########
@@ -68,9 +69,8 @@ private[spark] class LocalDirsFeatureStep(
             .withName(localDirVolume.getName)
             .withMountPath(localDirPath)
             .build()
-          }
+        }
     }
-

Review Comment:
   Please revert this removal.



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [spark] pralabhkumar commented on a diff in pull request #37203: [SPARK-39755][K8S] Randomization in Spark local directory for K8 resource managers

Posted by GitBox <gi...@apache.org>.
pralabhkumar commented on code in PR #37203:
URL: https://github.com/apache/spark/pull/37203#discussion_r950664130


##########
resource-managers/kubernetes/core/src/test/scala/org/apache/spark/deploy/k8s/features/LocalDirsFeatureStepSuite.scala:
##########
@@ -52,41 +52,58 @@ class LocalDirsFeatureStepSuite extends SparkFunSuite {
   }
 
   test("Use configured local dirs split on comma if provided.") {

Review Comment:
   @dongjoon-hyun  After randomization , this test case will fail , since this test case is always expecting 
   ```
   assert(configuredPod.container.getVolumeMounts.get(0) ===
         new VolumeMountBuilder()
           .withName(s"spark-local-dir-1")
           .withMountPath("/var/data/my-local-dir-1")
           .build())
   ```
   
   which is not true always since , locations are randomized (spark-local-dir-1 can mount to /var/data/my-local-dir-2) .   Also  test case is expecting env variable as always 
   /var/data/my-local-dir-1,/var/data/my-local-dir-2 which is also not true after randomization it can be both 
   (/var/data/my-local-dir-1,/var/data/my-local-dir-2 , /var/data/my-local-dir-2,/var/data/my-local-dir-1)
   
   ```
   assert(configuredPod.container.getEnv.get(0) ===
         new EnvVarBuilder()
           .withName("SPARK_LOCAL_DIRS")
           .withValue("/var/data/my-local-dir-1,/var/data/my-local-dir-2")
           .build())
   ```
   
   Therefore have changed the test case to take care of randomization. 
   
   Please suggest



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [spark] pralabhkumar commented on a diff in pull request #37203: [SPARK-39755][K8S] Randomization in Spark local directory for K8 resource managers

Posted by GitBox <gi...@apache.org>.
pralabhkumar commented on code in PR #37203:
URL: https://github.com/apache/spark/pull/37203#discussion_r950664546


##########
resource-managers/kubernetes/core/src/main/scala/org/apache/spark/deploy/k8s/features/LocalDirsFeatureStep.scala:
##########
@@ -33,12 +34,11 @@ private[spark] class LocalDirsFeatureStep(
   private val useLocalDirTmpFs = conf.get(KUBERNETES_LOCAL_DIRS_TMPFS)
 
   override def configurePod(pod: SparkPod): SparkPod = {
-    var localDirs = pod.container.getVolumeMounts.asScala
+    var localDirs = randomize(pod.container.getVolumeMounts.asScala
       .filter(_.getName.startsWith("spark-local-dir-"))
-      .map(_.getMountPath)
-    var localDirVolumes : Seq[Volume] = Seq()
-    var localDirVolumeMounts : Seq[VolumeMount] = Seq()
-

Review Comment:
   These line are not removed its there on line 40 and 41 . 



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [spark] pralabhkumar commented on pull request #37203: [SPARK-39755][CORE] Randomization in Spark local directory for other resource managers

Posted by GitBox <gi...@apache.org>.
pralabhkumar commented on PR #37203:
URL: https://github.com/apache/spark/pull/37203#issuecomment-1186905623

   @HyukjinKwon  Please review the PR . Thx 


-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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