-
Notifications
You must be signed in to change notification settings - Fork 28.8k
[SPARK-53176][DEPLOY] Spark launcher should respect --load-spark-defaults
#51905
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 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
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
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
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 |
---|---|---|
|
@@ -56,16 +56,18 @@ public static void cleanUp() throws Exception { | |
|
||
@Test | ||
public void testDriverCmdBuilder() throws Exception { | ||
testCmdBuilder(true, null); | ||
testCmdBuilder(true, dummyPropsFile); | ||
testCmdBuilder(true, connectPropsFile); | ||
testCmdBuilder(true, null, false); | ||
testCmdBuilder(true, dummyPropsFile, false); | ||
testCmdBuilder(true, dummyPropsFile, true); | ||
testCmdBuilder(true, connectPropsFile, false); | ||
} | ||
|
||
@Test | ||
public void testClusterCmdBuilder() throws Exception { | ||
testCmdBuilder(false, null); | ||
testCmdBuilder(false, dummyPropsFile); | ||
testCmdBuilder(false, connectPropsFile); | ||
testCmdBuilder(true, null, false); | ||
testCmdBuilder(true, dummyPropsFile, false); | ||
testCmdBuilder(true, dummyPropsFile, true); | ||
testCmdBuilder(true, connectPropsFile, false); | ||
} | ||
|
||
@Test | ||
|
@@ -317,13 +319,15 @@ public void testIsClientMode() { | |
assertTrue(builder.isClientMode(userProps)); | ||
} | ||
|
||
private void testCmdBuilder(boolean isDriver, File propertiesFile) throws Exception { | ||
private void testCmdBuilder( | ||
boolean isDriver, File propertiesFile, boolean loadSparkDefaults) throws Exception { | ||
final String DRIVER_DEFAULT_PARAM = "-Ddriver-default"; | ||
final String DRIVER_EXTRA_PARAM = "-Ddriver-extra"; | ||
String deployMode = isDriver ? "client" : "cluster"; | ||
|
||
SparkSubmitCommandBuilder launcher = | ||
newCommandBuilder(Collections.emptyList()); | ||
launcher.loadSparkDefaults = loadSparkDefaults; | ||
launcher.childEnv.put(CommandBuilderUtils.ENV_SPARK_HOME, | ||
System.getProperty("spark.test.home")); | ||
launcher.master = "yarn"; | ||
|
@@ -334,11 +338,10 @@ private void testCmdBuilder(boolean isDriver, File propertiesFile) throws Except | |
launcher.appArgs.add("foo"); | ||
launcher.appArgs.add("bar"); | ||
launcher.conf.put("spark.foo", "foo"); | ||
// either set the property through "--conf" or through default property file | ||
if (propertiesFile == null) { | ||
launcher.childEnv.put("SPARK_CONF_DIR", System.getProperty("spark.test.home") | ||
+ "/launcher/src/test/resources"); | ||
} else { | ||
launcher.childEnv.put("SPARK_CONF_DIR", System.getProperty("spark.test.home") | ||
+ "/launcher/src/test/resources"); | ||
// either set the property through "--conf" or through properties file(s) | ||
if (propertiesFile != null) { | ||
launcher.setPropertiesFile(propertiesFile.getAbsolutePath()); | ||
launcher.conf.put(SparkLauncher.DRIVER_MEMORY, "1g"); | ||
launcher.conf.put(SparkLauncher.DRIVER_EXTRA_CLASSPATH, "/driver"); | ||
|
@@ -369,8 +372,13 @@ private void testCmdBuilder(boolean isDriver, File propertiesFile) throws Except | |
String[] cp = findArgValue(cmd, "-cp").split(Pattern.quote(File.pathSeparator)); | ||
if (isDriver) { | ||
assertTrue(contains("/driver", cp), "Driver classpath should contain provided entry."); | ||
if (propertiesFile == null || loadSparkDefaults) { | ||
assertTrue(contains("/driver-default", cp), | ||
"Driver classpath should contain provided entry."); | ||
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. this assertion fails without this patch. |
||
} | ||
} else { | ||
assertFalse(contains("/driver", cp), "Driver classpath should not be in command."); | ||
assertFalse(contains("/driver-default", cp), "Driver classpath should not be in command."); | ||
} | ||
|
||
String libPath = env.get(CommandBuilderUtils.getLibPathEnvName()); | ||
|
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
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.
Hmm? I think the logic should be that if user specified prop file contains any default entries, they must be overwritten. But here it looks like if the user specified entries are not in default prop file, they will be present? So it is a merger instead of overwritting? Is it correct?
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.
Oops, you are right, will fix soon.
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.
@viirya I fixed the behavior, also refactored UT to verify the priority of the configs:
--conf
spark-defaults.conf
if it exists