-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-18099][YARN] Fail if same files added to distributed cache for --files and --archives #15627
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2c55fc2
Dist cache yarn during submit should throw error for adding same file…
kishorvpatil a1dc858
Convert required to IllegalArgumentException
kishorvpatil 33f95ab
Reword exception message
kishorvpatil f797481
Adding comment and unit tests
kishorvpatil 51eefa5
Updating unit test cover all three scenarios.
kishorvpatil File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -598,8 +598,16 @@ private[spark] class Client( | |
| ).foreach { case (flist, resType, addToClasspath) => | ||
| flist.foreach { file => | ||
| val (_, localizedPath) = distribute(file, resType = resType) | ||
| if (addToClasspath && localizedPath != null) { | ||
| cachedSecondaryJarLinks += localizedPath | ||
| // If addToClassPath, we ignore adding jar multiple times to distitrbuted cache. | ||
| if (addToClasspath) { | ||
| if (localizedPath != null) { | ||
| cachedSecondaryJarLinks += localizedPath | ||
| } | ||
| } else { | ||
| if (localizedPath != null) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess here is |
||
| throw new IllegalArgumentException(s"Attempt to add ($file) multiple times" + | ||
| " to the distributed cache.") | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -282,6 +282,48 @@ class ClientSuite extends SparkFunSuite with Matchers with BeforeAndAfterAll | |
| } | ||
| } | ||
|
|
||
| test("distribute archive multiple times") { | ||
| val libs = Utils.createTempDir() | ||
| // Create jars dir and RELEASE file to avoid IllegalStateException. | ||
| val jarsDir = new File(libs, "jars") | ||
| assert(jarsDir.mkdir()) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see jarsDir being used anywhere either |
||
| new FileOutputStream(new File(libs, "RELEASE")).close() | ||
|
|
||
| val userLib1 = Utils.createTempDir() | ||
| val testJar = TestUtils.createJarWithFiles(Map(), userLib1) | ||
|
|
||
| // Case 1: FILES_TO_DISTRIBUTE and ARCHIVES_TO_DISTRIBUTE can't have duplicate files | ||
| val sparkConf = new SparkConfWithEnv(Map("SPARK_HOME" -> libs.getAbsolutePath)) | ||
| .set(FILES_TO_DISTRIBUTE, Seq(testJar.getPath)) | ||
| .set(ARCHIVES_TO_DISTRIBUTE, Seq(testJar.getPath)) | ||
|
|
||
| val client = createClient(sparkConf) | ||
| val tempDir = Utils.createTempDir() | ||
| intercept[IllegalArgumentException] { | ||
| client.prepareLocalResources(new Path(tempDir.getAbsolutePath()), Nil) | ||
| } | ||
|
|
||
| // Case 2: FILES_TO_DISTRIBUTE can't have duplicate files. | ||
| val sparkConfFiles = new SparkConfWithEnv(Map("SPARK_HOME" -> libs.getAbsolutePath)) | ||
| .set(FILES_TO_DISTRIBUTE, Seq(testJar.getPath, testJar.getPath)) | ||
|
|
||
| val clientFiles = createClient(sparkConfFiles) | ||
| val tempDirForFiles = Utils.createTempDir() | ||
| intercept[IllegalArgumentException] { | ||
| clientFiles.prepareLocalResources(new Path(tempDirForFiles.getAbsolutePath()), Nil) | ||
| } | ||
|
|
||
| // Case 3: ARCHIVES_TO_DISTRIBUTE can't have duplicate files. | ||
| val sparkConfArchives = new SparkConfWithEnv(Map("SPARK_HOME" -> libs.getAbsolutePath)) | ||
| .set(ARCHIVES_TO_DISTRIBUTE, Seq(testJar.getPath, testJar.getPath)) | ||
|
|
||
| val clientArchives = createClient(sparkConfArchives) | ||
| val tempDirForArchives = Utils.createTempDir() | ||
| intercept[IllegalArgumentException] { | ||
| clientArchives.prepareLocalResources(new Path(tempDirForArchives.getAbsolutePath()), Nil) | ||
| } | ||
| } | ||
|
|
||
| test("distribute local spark jars") { | ||
| val temp = Utils.createTempDir() | ||
| val jarsDir = new File(temp, "jars") | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add a comment here explaining what exactly thi sis doing to help explain and keep from breaking in future.
Also can you add another unit test to cover this case.