shardulm94 commented on a change in pull request #31591:
URL: https://github.com/apache/spark/pull/31591#discussion_r595557365



##########
File path: 
resource-managers/yarn/src/test/scala/org/apache/spark/deploy/yarn/YarnClusterSuite.scala
##########
@@ -583,6 +597,44 @@ private object YarnClasspathTest extends Logging {
 
 }
 
+private object YarnAddJarTest extends Logging {
+  def main(args: Array[String]): Unit = {
+    if (args.length != 1) {
+      // scalastyle:off println
+      System.err.println(
+        s"""
+           |Invalid command line: ${args.mkString(" ")}
+           |
+           |Usage: YarnAddJarTest [result file]
+        """.stripMargin)
+      // scalastyle:on println
+      System.exit(1)
+    }
+
+    val resultPath = args(0)
+    val sc = new SparkContext(new SparkConf())
+
+    var result = "failure"
+    try {
+      val settingsFile = sc.getConf.get("spark.jars.ivySettings")
+      // Make sure that ivySettings conf was set to the localized file
+      assert(settingsFile.startsWith(Client.LOCALIZED_CONF_DIR))
+
+      val caught = intercept[RuntimeException] {
+        sc.addJar("ivy://org.fake-project.test:test:1.0.0")
+      }
+      if (caught.getMessage.contains("unresolved dependency: 
org.fake-project.test#test")) {
+        // "unresolved dependency" is expected as the dependency does not exist
+        // but exception like "Ivy settings file <file> does not exist should 
result in failure"

Review comment:
       Fixed

##########
File path: 
resource-managers/yarn/src/test/scala/org/apache/spark/deploy/yarn/YarnClusterSuite.scala
##########
@@ -368,6 +369,19 @@ class YarnClusterSuite extends BaseYarnClusterSuite {
     )
     checkResult(finalState, result, "true")
   }
+
+  test("SPARK-34472: ivySettings file should be localized on driver in cluster 
mode") {
+
+    val emptyIvySettings = File.createTempFile("ivy", ".xml")
+    FileUtils.write(emptyIvySettings, "<ivysettings />", 
StandardCharsets.UTF_8)
+

Review comment:
       I changed this to use Guava's Files which is used in many places within 
this file. Can I create a followup PR to replace these with NIO?

##########
File path: 
resource-managers/yarn/src/main/scala/org/apache/spark/deploy/yarn/Client.scala
##########
@@ -793,6 +793,25 @@ private[spark] class Client(
       // distributed file.
       amKeytabFileName.foreach { kt => props.setProperty(KEYTAB.key, kt) }
 
+      // Upload user provided ivysettings.xml file to the distributed cache
+      val ivySettings = sparkConf.getOption("spark.jars.ivySettings")
+      if (isClusterMode && ivySettings.isDefined) {
+        val ivySettingsFile = new File(ivySettings.get)
+        require(ivySettingsFile.exists(), s"Ivy settings file $ivySettingsFile 
not found")

Review comment:
       Done

##########
File path: 
resource-managers/yarn/src/main/scala/org/apache/spark/deploy/yarn/Client.scala
##########
@@ -793,6 +793,25 @@ private[spark] class Client(
       // distributed file.
       amKeytabFileName.foreach { kt => props.setProperty(KEYTAB.key, kt) }
 
+      // Upload user provided ivysettings.xml file to the distributed cache
+      val ivySettings = sparkConf.getOption("spark.jars.ivySettings")
+      if (isClusterMode && ivySettings.isDefined) {
+        val ivySettingsFile = new File(ivySettings.get)
+        require(ivySettingsFile.exists(), s"Ivy settings file $ivySettingsFile 
not found")
+        require(ivySettingsFile.isFile(),
+          s"Ivy settings file $ivySettingsFile is not a normal file")
+        // Generate a file name that can be used for the ivySettings file, 
that does not conflict
+        // with any other conf file.
+        val amIvySettingsFileName = ivySettingsFile.getName() + "-" + 
UUID.randomUUID().toString
+        confStream.putNextEntry(new ZipEntry(amIvySettingsFileName))
+        Files.copy(ivySettingsFile, confStream)

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.

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