Skip to content
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

[SPARK-24446][yarn] Properly quote library path for YARN. #21476

Closed
wants to merge 2 commits into from

Conversation

vanzin
Copy link
Contributor

@vanzin vanzin commented May 31, 2018

Because the way YARN executes commands via bash -c, everything needs
to be quoted so that the whole command is fully contained inside a
bash string and is interpreted correctly when the string is read by
bash. This is a bit different than the quoting done when executing
things as if typing in a bash shell.

Tweaked unit tests to exercise the bad behavior, which would cause
existing tests to time out without the fix. Also tested on a real
cluster, verifying the shell script created by YARN to run the
container.

Because the way YARN executes commands via bash -c, everything needs
to be quoted so that the whole command is fully contained inside a
bash string and is interpreted correctly when the string is read by
bash. This is a bit different than the quoting done when executing
things as if typing in a bash shell.

Tweaked unit tests to exercise the bad behavior, which would cause
existing tests to time out without the fix. Also tested on a real
cluster, verifying the shell script created by YARN to run the
container.
@SparkQA
Copy link

SparkQA commented May 31, 2018

Test build #91370 has finished for PR 21476 at commit 0a3b71f.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

* Create a properly quoted library path string to be added as a prefix to the command executed by
* YARN. This is different from plain quoting due to YARN executing the command through "bash -c".
*/
def createLibraryPathPrefix(libpath: String, conf: SparkConf): String = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe pull this into a util class and have unit tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is so specific to the way YARN runs things that I don't think it would be useful anywhere else. If at some point it becomes useful, the code can be moved.

I think the tests I added are better than just unit testing this function, since that way the code is actually being run through YARN and bash.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

k

val envName = Utils.libraryPathEnvName
// For quotes, escape both the quote and the escape character when encoding in the command
// string.
val quoted = libpath.replace("\"", "\\\\\\\"")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dumb question i think escaping """ => "\"". Not sure why we have so many escapes otherwise. Trying to understand, else PR looks good

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be double escaped because it goes through two rounds of bash interpreting the value.

@SparkQA
Copy link

SparkQA commented Jun 4, 2018

Test build #91454 has finished for PR 21476 at commit 87e207c.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@vanzin
Copy link
Contributor Author

vanzin commented Jun 22, 2018

If there are no more comments I plan to push this next week.

@vanzin
Copy link
Contributor Author

vanzin commented Jun 27, 2018

retest this please

@SparkQA
Copy link

SparkQA commented Jun 27, 2018

Test build #92388 has finished for PR 21476 at commit 87e207c.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@vanzin
Copy link
Contributor Author

vanzin commented Jun 27, 2018

Merging to master.

@asfgit asfgit closed this in 78ecb6d Jun 27, 2018
@vanzin vanzin deleted the SPARK-24446 branch August 24, 2018 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants