Pass Spark job server JVM args#39242
Conversation
149a3c2 to
38a618d
Compare
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces the ability to pass custom JVM arguments to the Spark job server. This change is primarily aimed at resolving compatibility issues with Java 17 and newer, where specific module access flags are required. The implementation includes logic to automatically detect the Java version and apply the necessary 'add-opens' flags, while also updating the supporting shell scripts to handle these arguments during the job server lifecycle. Highlights
New Features🧠 You can now enable Memory (public preview) to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
|
Assigning reviewers: R: @jrmccluskey for label python. Note: If you would like to opt out of this review, comment Available commands:
The PR bot will only process comments in the main thread (not review comments). |
There was a problem hiding this comment.
Code Review
This pull request adds support for passing JVM arguments (such as --add-opens flags for Java 17+) to the Spark Job Server. It updates the Gradle setup task to dynamically determine the Java version and pass these arguments, and modifies run_job_server.sh to accept and apply them. The review feedback highlights potential issues with unquoted $JVM_ARGS in the shell script leading to word-splitting or unbound variable errors, and a potential NumberFormatException in the Gradle build file when parsing the testJavaVersion property.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
|
||
| echo "Launching job server @ $JOB_PORT ..." | ||
| "$JAVA_CMD" -jar $JOB_SERVER_JAR --job-port=$JOB_PORT --artifact-port=$ARTIFACT_PORT --expansion-port=0 $ADDITIONAL_ARGS >$TEMP_DIR/$FILE_BASE.log 2>&1 </dev/null & | ||
| "$JAVA_CMD" $JVM_ARGS -jar $JOB_SERVER_JAR --job-port=$JOB_PORT --artifact-port=$ARTIFACT_PORT --expansion-port=0 $ADDITIONAL_ARGS >$TEMP_DIR/$FILE_BASE.log 2>&1 </dev/null & |
There was a problem hiding this comment.
When $JVM_ARGS is unquoted, it undergoes word splitting, which is necessary here to pass multiple JVM arguments (like --add-opens) as separate parameters to the java command. However, if $JVM_ARGS is empty or unset, this can sometimes lead to unexpected behavior depending on shell settings, or if any of the arguments contain spaces.
To ensure robustness and avoid issues with empty values, it is safer to use an array for arguments in bash, or explicitly handle the expansion. Since this script is executed via sh (which might be dash or bash depending on the system), we should be careful. If we are sure it's run with bash (the shebang of run_job_server.sh is likely #!/bin/bash), using a bash array is the most robust way to handle list of arguments with potential spaces. If it must remain a string, we should ensure JVM_ARGS is initialized to an empty string at the top of the script to prevent unbound variable errors if set -u is used.
| def artifactPort = BeamModulePlugin.getRandomPort() | ||
|
|
||
| def sparkJobServerJvmArgs() { | ||
| def testJavaVer = project.findProperty('testJavaVersion') ? (project.property('testJavaVersion') as int) : JavaVersion.current().majorVersion.toInteger() |
There was a problem hiding this comment.
In Groovy/Gradle, using as int on a property that might be a String can throw a NumberFormatException if the property is not a valid integer. Additionally, JavaVersion.current().majorVersion is already a String, so calling .toInteger() on it is safe, but we should make sure testJavaVersion is safely parsed.
Consider using Integer.parseInt() or a safe cast with a fallback to avoid potential build failures if testJavaVersion is configured incorrectly.
def testJavaVer = project.findProperty('testJavaVersion') ? (project.property('testJavaVersion').toString().toInteger()) : JavaVersion.current().majorVersion.toInteger()
Fixes: #30602
Successful run: https://github.com/apache/beam/actions/runs/28941534332
Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
addresses #123), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, commentfixes #<ISSUE NUMBER>instead.CHANGES.mdwith noteworthy changes.See the Contributor Guide for more tips on how to make review process smoother.
To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md
GitHub Actions Tests Status (on master branch)
See CI.md for more information about GitHub Actions CI or the workflows README to see a list of phrases to trigger workflows.