-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-27900][K8s] Add jvm oom flag #25229
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -60,14 +60,44 @@ if ! [ -z ${HADOOP_CONF_DIR+x} ]; then | |
| SPARK_CLASSPATH="$HADOOP_CONF_DIR:$SPARK_CLASSPATH"; | ||
| fi | ||
|
|
||
| IGNORE_DEFAULT_DRIVER_JVM_OPTIONS=${IGNORE_DEFAULT_DRIVER_JVM_OPTIONS:-false} | ||
| DRIVER_VERBOSE=${DRIVER_VERBOSE:-false} | ||
|
|
||
| function get_verbose_flag() | ||
| { | ||
| if [[ $DRIVER_VERBOSE == "true" ]]; then | ||
| echo "--verbose" | ||
| else | ||
| echo "" | ||
| fi | ||
| } | ||
|
|
||
| function get_args_with_defaults() | ||
| { | ||
| if [[ $IGNORE_DEFAULT_DRIVER_JVM_OPTIONS == "true" ]]; then | ||
| echo "$@" | ||
| else | ||
| if grep -q "spark.driver.extraJavaOptions" "/opt/spark/conf/spark.properties"; then | ||
| sed 's/spark.driver.extraJavaOptions=/&-XX:OnOutOfMemoryError="kill -9 %p" /g' /opt/spark/conf/spark.properties > /tmp/spark.properties | ||
|
Contributor
Author
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.
|
||
| else | ||
| cp /opt/spark/conf/spark.properties /tmp/spark.properties | ||
| echo 'spark.driver.extraJavaOptions=-XX:OnOutOfMemoryError="kill -9 %p"' >> /tmp/spark.properties | ||
| fi | ||
| echo "$@" | sed 's|/opt/spark/conf/spark.properties |/tmp/spark.properties |g' | ||
|
Contributor
Author
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. We cannot avoid sed if we want to make sure the default is always added. Otherwise if we just add
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. If you follow https://github.com/apache/spark/pull/25229/files#r310866032, the suggested behavior is the following. So, it seems that we don't need this complexity.
Contributor
Author
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. ok so we say that |
||
| fi | ||
| } | ||
|
|
||
| case "$1" in | ||
| driver) | ||
| shift 1 | ||
| DRIVER_ARGS=$(get_args_with_defaults "$@") | ||
| VERBOSE_FLAG=$(get_verbose_flag) | ||
|
Contributor
Author
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. We use this flag so in the tests we can detect what properties we get. Also it it useful in general users want to debug Spark. |
||
| CMD=( | ||
| "$SPARK_HOME/bin/spark-submit" | ||
| $VERBOSE_FLAG | ||
| --conf "spark.driver.bindAddress=$SPARK_DRIVER_BIND_ADDRESS" | ||
| --deploy-mode client | ||
| "$@" | ||
| $DRIVER_ARGS | ||
| ) | ||
| ;; | ||
| executor) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -98,6 +98,28 @@ private[spark] trait BasicTestsSuite { k8sSuite: KubernetesSuite => | |
| expectedJVMValue = Seq("(spark.test.foo,spark.test.bar)")) | ||
| } | ||
|
|
||
| test("Run SparkPi without the default exit on OOM error flag", k8sTestTag) { | ||
| sparkAppConf | ||
| .set("spark.driver.extraJavaOptions", "-Dspark.test.foo=spark.test.bar") | ||
| .set("spark.kubernetes.driverEnv.DRIVER_VERBOSE", "true") | ||
| .set("spark.kubernetes.driverEnv.IGNORE_DEFAULT_DRIVER_JVM_OPTIONS", "true") | ||
|
|
||
| val output = Seq("Pi is roughly 3", | ||
| "(spark.driver.extraJavaOptions,-Dspark.test.foo=spark.test.bar)") | ||
|
|
||
| runSparkPiAndVerifyCompletion(expectedLogOnCompletion = output) | ||
| } | ||
|
|
||
| test("Run SparkPi with the default exit on OOM error flag set", k8sTestTag) { | ||
| sparkAppConf | ||
| .set("spark.driver.extraJavaOptions", "-Dspark.test.foo=spark.test.bar") | ||
| .set("spark.kubernetes.driverEnv.DRIVER_VERBOSE", "true") | ||
| val output = Seq("Pi is roughly 3", | ||
| "(spark.driver.extraJavaOptions,-XX:OnOutOfMemoryError=\"kill -9 %p\" " + | ||
| "-Dspark.test.foo=spark.test.bar)") | ||
| runSparkPiAndVerifyCompletion(expectedLogOnCompletion = output) | ||
| } | ||
|
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. Thank you for adding these test cases. |
||
|
|
||
| test("Run SparkRemoteFileTest using a remote data file", k8sTestTag) { | ||
| sparkAppConf | ||
| .set("spark.files", REMOTE_PAGE_RANK_DATA_FILE) | ||
|
|
||
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 we have
DEFAULT_DRIVER_JVM_OPTIONSinstead of this flag?DEFAULT_DRIVER_JVM_OPTIONS=-XX:OnOutOfMemoryError="kill -9 %p"and it will be appended beforespark.driver.extraJavaOptions.DEFAULT_DRIVER_JVM_OPTIONS, then onlyspark.driver.extraJavaOptionsworks.At (1), if
spark.driver.extraJavaOptionshas-XX:OnOutOfMemoryError=, it will supersedeDEFAULT_DRIVER_JVM_OPTIONSbecause the last one is used.Uh oh!
There was an error while loading. Please reload this page.
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.
@dongjoon-hyun How can they unset
DEFAULT_DRIVER_JVM_OPTIONSat runtime? Probably missing something here. Do you mean by setting the container env var eg. spark.kubernetes.driverEnv.DEFAULT_DRIVER_JVM_OPTIONS=""?Uh oh!
There was an error while loading. Please reload this page.
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.
@dongjoon-hyun the only option I see is setting
DEFAULT_DRIVER_JVM_OPTIONSto empty string to signal the script to use the default, which is similar to setting that flag to true. I will the rename the flag but not sure if we are aligned.How should the user do that? Could you elaborate a bit more?
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.
@dongjoon-hyun gentle ping :)
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. Sorry for being late, @skonto . I'll take a look this PR tomorrow again~
Uh oh!
There was an error while loading. Please reload this page.
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.
Initially, what I thought was something like the following
And users do
export DEFAULT_DRIVER_JVM_OPTIONS=' 'for unset. Ya. My comment was unclear at that time.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.
@skonto . What do you think about the above? For me, the above looks more direct.
Uh oh!
There was an error while loading. Please reload this page.
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.
@dongjoon-hyun Ok so that is what I also concluded :) I can do that, it looks fine to me, the only issue is that this way we open the door to adding arbitrary options there. Initially that was what I didnt want to support, thus I used that the flag to make defaults unchangeable (defaults usually have fixed values).
But we could be flexible here for simplicity reasons, so I will change to what you suggest.