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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to