dongjoon-hyun commented on a change in pull request #30472:
URL: https://github.com/apache/spark/pull/30472#discussion_r550364684



##########
File path: 
resource-managers/kubernetes/core/src/main/scala/org/apache/spark/deploy/k8s/submit/KubernetesClientUtils.scala
##########
@@ -90,29 +92,67 @@ private[spark] object KubernetesClientUtils extends Logging 
{
       .build()
   }
 
-  private def loadSparkConfDirFiles(conf: SparkConf): Map[String, String] = {
+  private def orderFilesBySize(confFiles: Seq[File]): Seq[File] = {
+    val fileToFileSizePairs = confFiles.map(f => (f, f.getName.length + 
f.length()))
+    // sort first by name and then by length, so that during tests we have 
consistent results.
+    fileToFileSizePairs.sortBy(f => f._1).sortBy(f => f._2).map(_._1)

Review comment:
       This has a bug because we will consider file name later by 
`truncatedMapSize = truncatedMapSize + (fileName.length + fileContent.length)`. 
Please see [this 
comment](https://github.com/apache/spark/pull/30472#discussion_r550364758).
   ```scala
   scala> Seq("b" -> 1, "abcdef" -> 1).sortBy(f => f._1).sortBy(f => f._2)
   res14: Seq[(String, Int)] = List((abcdef,1), (b,1))
   
   scala> Seq("b" -> 1, "abcdef" -> 1).sortBy(f => f._1).sortBy(f => 
f._2).map(f => f._1.length + f._2)
   res15: Seq[Int] = List(7, 2)
   ```




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



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

Reply via email to