Skip to content

Commit 5bdaa72

Browse files
dongjoon-hyunMaxGekk
authored andcommitted
[SPARK-50398][CORE] Use ExitCode 0 for --help usage in Spark scripts
### What changes were proposed in this pull request? This PR aims to use `0` as the exit code for `--help` usage in Spark scripts consistently to provide better and consistent UX from Apache Spark 4.0.0. ### Why are the changes needed? Initially, Apache Spark was designed to exit with `0` when `--help` is given because `--help` argument is not a error case. **SparkSubmit** https://github.com/apache/spark/blob/d5da49d56d7dec5f8a96c5252384d865f7efd4d9/core/src/main/scala/org/apache/spark/deploy/SparkSubmitArguments.scala#L458-L459 **Spark Master** https://github.com/apache/spark/blob/d5da49d56d7dec5f8a96c5252384d865f7efd4d9/core/src/main/scala/org/apache/spark/deploy/master/MasterArguments.scala#L88-L89 **Spark Worker** https://github.com/apache/spark/blob/d5da49d56d7dec5f8a96c5252384d865f7efd4d9/core/src/main/scala/org/apache/spark/deploy/worker/WorkerArguments.scala#L107-L108 **Spark History Server** https://github.com/apache/spark/blob/d5da49d56d7dec5f8a96c5252384d865f7efd4d9/core/src/main/scala/org/apache/spark/deploy/history/HistoryServerArguments.scala#L39-L40 In addition, all scripts under `bin/*` return `0` consistently like the following. This PR changes `sbin/*` scripts additionally for consistency. | Command | Before | After | | ---------- | ------- | ------- | | bin/spark-class --help | 0 | 0 | | bin/spark-shell --help | 0 | 0 | | bin/pyspark --help | 0 | 0 | | bin/spark-sql --help | 0 | 0 | | bin/beeline --help | 0 | 0 | | bin/sparkR --help | 0 | 0 | | bin/docker-image-tool.sh --help | 0 | 0 | | sbin/start-master.sh --help | 1 | 0 | | sbin/start-worker.sh --help | 1 | 0 | | sbin/start-history-server.sh --help | 1 | 0 | | sbin/start-thriftserver.sh --help | 1 | 0 | | sbin/start-connect-server.sh --help | 1 | 0 | ### Does this PR introduce _any_ user-facing change? Yes, but this is a exit status code for `--help` or `-h`. ### How was this patch tested? Manual review. ### Was this patch authored or co-authored using generative AI tooling? No. Closes #48939 from dongjoon-hyun/SPARK-50398. Authored-by: Dongjoon Hyun <[email protected]> Signed-off-by: Max Gekk <[email protected]>
1 parent d5da49d commit 5bdaa72

File tree

5 files changed

+5
-5
lines changed

5 files changed

+5
-5
lines changed

sbin/start-connect-server.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ if [[ "$@" = *--help ]] || [[ "$@" = *-h ]]; then
3333
echo "Usage: ./sbin/start-connect-server.sh [--wait] [options]"
3434

3535
"${SPARK_HOME}"/bin/spark-submit --help 2>&1 | grep -v Usage 1>&2
36-
exit 1
36+
exit 0
3737
fi
3838

3939
. "${SPARK_HOME}/bin/load-spark-env.sh"

sbin/start-history-server.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ if [[ "$@" = *--help ]] || [[ "$@" = *-h ]]; then
4040
pattern+="\|Registered signal handler for"
4141

4242
"${SPARK_HOME}"/bin/spark-class $CLASS --help 2>&1 | grep -v "$pattern" 1>&2
43-
exit 1
43+
exit 0
4444
fi
4545

4646
. "${SPARK_HOME}/sbin/spark-config.sh"

sbin/start-master.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ if [[ "$@" = *--help ]] || [[ "$@" = *-h ]]; then
3535
pattern+="\|Registered signal handler for"
3636

3737
"${SPARK_HOME}"/bin/spark-class $CLASS --help 2>&1 | grep -v "$pattern" 1>&2
38-
exit 1
38+
exit 0
3939
fi
4040

4141
ORIGINAL_ARGS="$@"

sbin/start-thriftserver.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function usage {
5252

5353
if [[ "$@" = *--help ]] || [[ "$@" = *-h ]]; then
5454
usage
55-
exit 1
55+
exit 0
5656
fi
5757

5858
export SUBMIT_USAGE_FUNCTION=usage

sbin/start-worker.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ if [[ $# -lt 1 ]] || [[ "$@" = *--help ]] || [[ "$@" = *-h ]]; then
4747
pattern+="\|Registered signal handler for"
4848

4949
"${SPARK_HOME}"/bin/spark-class $CLASS --help 2>&1 | grep -v "$pattern" 1>&2
50-
exit 1
50+
[[ $# -lt 1 ]] && exit 1 || exit 0
5151
fi
5252

5353
. "${SPARK_HOME}/sbin/spark-config.sh"

0 commit comments

Comments
 (0)