Skip to content

Commit 3654b00

Browse files
brkyvzmtbrandy
authored andcommitted
[SPARK-8410] [SPARK-8475] remove previous ivy resolution when using spark-submit
This PR also includes re-ordering the order that repositories are used when resolving packages. User provided repositories will be prioritized. cc andrewor14 Author: Burak Yavuz <brkyvz@gmail.com> Closes apache#7089 from brkyvz/delete-prev-ivy-resolution and squashes the following commits: a21f95a [Burak Yavuz] remove previous ivy resolution when using spark-submit (cherry picked from commit d7f796d) Signed-off-by: Andrew Or <andrew@databricks.com>
1 parent e5e1a87 commit 3654b00

File tree

2 files changed

+26
-17
lines changed

2 files changed

+26
-17
lines changed

core/src/main/scala/org/apache/spark/deploy/SparkSubmit.scala

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -800,6 +800,20 @@ private[spark] object SparkSubmitUtils {
800800
val cr = new ChainResolver
801801
cr.setName("list")
802802

803+
val repositoryList = remoteRepos.getOrElse("")
804+
// add any other remote repositories other than maven central
805+
if (repositoryList.trim.nonEmpty) {
806+
repositoryList.split(",").zipWithIndex.foreach { case (repo, i) =>
807+
val brr: IBiblioResolver = new IBiblioResolver
808+
brr.setM2compatible(true)
809+
brr.setUsepoms(true)
810+
brr.setRoot(repo)
811+
brr.setName(s"repo-${i + 1}")
812+
cr.add(brr)
813+
printStream.println(s"$repo added as a remote repository with the name: ${brr.getName}")
814+
}
815+
}
816+
803817
val localM2 = new IBiblioResolver
804818
localM2.setM2compatible(true)
805819
localM2.setRoot(m2Path.toURI.toString)
@@ -830,20 +844,6 @@ private[spark] object SparkSubmitUtils {
830844
sp.setRoot("http://dl.bintray.com/spark-packages/maven")
831845
sp.setName("spark-packages")
832846
cr.add(sp)
833-
834-
val repositoryList = remoteRepos.getOrElse("")
835-
// add any other remote repositories other than maven central
836-
if (repositoryList.trim.nonEmpty) {
837-
repositoryList.split(",").zipWithIndex.foreach { case (repo, i) =>
838-
val brr: IBiblioResolver = new IBiblioResolver
839-
brr.setM2compatible(true)
840-
brr.setUsepoms(true)
841-
brr.setRoot(repo)
842-
brr.setName(s"repo-${i + 1}")
843-
cr.add(brr)
844-
printStream.println(s"$repo added as a remote repository with the name: ${brr.getName}")
845-
}
846-
}
847847
cr
848848
}
849849

@@ -973,6 +973,15 @@ private[spark] object SparkSubmitUtils {
973973

974974
// A Module descriptor must be specified. Entries are dummy strings
975975
val md = getModuleDescriptor
976+
// clear ivy resolution from previous launches. The resolution file is usually at
977+
// ~/.ivy2/org.apache.spark-spark-submit-parent-default.xml. In between runs, this file
978+
// leads to confusion with Ivy when the files can no longer be found at the repository
979+
// declared in that file/
980+
val mdId = md.getModuleRevisionId
981+
val previousResolution = new File(ivySettings.getDefaultCache,
982+
s"${mdId.getOrganisation}-${mdId.getName}-$ivyConfName.xml")
983+
if (previousResolution.exists) previousResolution.delete
984+
976985
md.setDefaultConf(ivyConfName)
977986

978987
// Add exclusion rules for Spark and Scala Library

core/src/test/scala/org/apache/spark/deploy/SparkSubmitUtilsSuite.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ class SparkSubmitUtilsSuite extends FunSuite with BeforeAndAfterAll {
7676
assert(resolver2.getResolvers.size() === 7)
7777
val expected = repos.split(",").map(r => s"$r/")
7878
resolver2.getResolvers.toArray.zipWithIndex.foreach { case (resolver: AbstractResolver, i) =>
79-
if (i > 3) {
80-
assert(resolver.getName === s"repo-${i - 3}")
81-
assert(resolver.asInstanceOf[IBiblioResolver].getRoot === expected(i - 4))
79+
if (i < 3) {
80+
assert(resolver.getName === s"repo-${i + 1}")
81+
assert(resolver.asInstanceOf[IBiblioResolver].getRoot === expected(i))
8282
}
8383
}
8484
}

0 commit comments

Comments
 (0)