Skip to content
This repository has been archived by the owner on Jan 9, 2020. It is now read-only.

Use a list of environment variables for JVM options. #444

Merged
merged 3 commits into from
Aug 22, 2017

Conversation

mccheah
Copy link

@mccheah mccheah commented Aug 18, 2017

Closes #440.

As opposed to using a single environment variables string, which does not delimit in the shell properly. Requires upgrading the Docker image to match the submission client.

@@ -39,10 +39,10 @@ ENV PYSPARK_DRIVER_PYTHON python
ENV PYTHONPATH ${SPARK_HOME}/python/:${SPARK_HOME}/python/lib/py4j-0.10.4-src.zip:${PYTHONPATH}

CMD SPARK_CLASSPATH="${SPARK_HOME}/jars/*" && \
env | grep SPARK_JAVA_OPT_ | sed 's/[^=]*=\(.*\)/\1/g' > /tmp/java_opts.txt && \
Copy link
Author

@mccheah mccheah Aug 19, 2017

Choose a reason for hiding this comment

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

This is pretty strange and is fairly dependent on the shell being Bash instead of sh. It would be good to make this compatible with /bin/sh but I couldn't think of a great way to handle this sanely without using arrays.

Separately, the usage of a temporary file is also sub-par. I found that when piping the result of env... sed into the readarray command via the <<< operator, readarray treated the entire input string as a single element of the array, making it such that the resulting array only had one large JVM option. I also tried piping the results of the sed command into readarray but that also isn't working for me in my testing.

I would appreciate any feedback or suggestions from those who are experienced at shell scripting.

Copy link

Choose a reason for hiding this comment

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

I'd also appreciate thoughts on how to avoid bouncing this off a temp file. What's there now is ugly but works, so if someone knows how to do this where it's pretty and works, that'd be even better

Copy link

Choose a reason for hiding this comment

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

cc @ifilonenko @erikerlandson @foxish for shell scripting suggestions

Copy link
Member

Choose a reason for hiding this comment

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

readarray can be at the end of the pipe, which avoids the temp file. That's at least slightly cleaner.

Copy link
Author

Choose a reason for hiding this comment

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

Piping to readarray didn't work for me; I believe the result was an empty array in the environment variable. But perhaps I was writing it incorrectly? I had this:

env | grep SPARK_JAVA_OPT_ | sed 's/[^=]*=\(.*\)/\1/g' | readarray -t SPARK_DRIVER_JAVA_OPTS

Copy link
Member

Choose a reason for hiding this comment

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

Weird, I'd expect that to be equivalent to the code using the temp file.

Copy link

@ash211 ash211 left a comment

Choose a reason for hiding this comment

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

Probably worth calling out in the PR message that this is a bugfix where previously space-separated values of spark.{driver,executor}.extraJavaOptions were ignored.

This change looks good to me -- I'd like to merge by EOD Monday since this is an important bugfix that we found in testing.

@@ -135,7 +135,7 @@ class ClientSuite extends SparkFunSuite with BeforeAndAfter {
.set("spark.logConf", "true")
.set(
org.apache.spark.internal.config.DRIVER_JAVA_OPTIONS,
"-XX:+|-HeapDumpOnOutOfMemoryError")
Copy link

Choose a reason for hiding this comment

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

what was this +|- for before? afaik that's not valid syntax

Copy link
Author

Choose a reason for hiding this comment

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

Not sure - probably just a badly written unit test.

@@ -226,6 +226,26 @@ private[spark] class KubernetesSuite extends SparkFunSuite with BeforeAndAfter {
Seq.empty[String])
}

test("Setting JVM options on the driver and executors with spaces.") {
Copy link

Choose a reason for hiding this comment

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

right now this PR only tests drivers -- the executors is coming in the followup PR

Copy link
Author

Choose a reason for hiding this comment

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

I'm ok with keeping the name as-is for now though given that the next PR is imminent.

@@ -39,10 +39,10 @@ ENV PYSPARK_DRIVER_PYTHON python
ENV PYTHONPATH ${SPARK_HOME}/python/:${SPARK_HOME}/python/lib/py4j-0.10.4-src.zip:${PYTHONPATH}

CMD SPARK_CLASSPATH="${SPARK_HOME}/jars/*" && \
env | grep SPARK_JAVA_OPT_ | sed 's/[^=]*=\(.*\)/\1/g' > /tmp/java_opts.txt && \
Copy link

Choose a reason for hiding this comment

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

I'd also appreciate thoughts on how to avoid bouncing this off a temp file. What's there now is ugly but works, so if someone knows how to do this where it's pretty and works, that'd be even better

Copy link

@ash211 ash211 left a comment

Choose a reason for hiding this comment

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

Ready to merge

@ash211 ash211 merged commit f7b5820 into branch-2.2-kubernetes Aug 22, 2017
@foxish foxish deleted the support-java-options-with-spaces branch November 29, 2017 16:10
puneetloya pushed a commit to puneetloya/spark that referenced this pull request Mar 11, 2019
…-k8s#444)

* Use a list of environment variables for JVM options.

* Fix merge conflicts.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants