This is an automated email from the ASF dual-hosted git repository.

maxgekk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/master by this push:
     new 5bdaa72801d6 [SPARK-50398][CORE] Use ExitCode `0` for `--help` usage 
in Spark scripts
5bdaa72801d6 is described below

commit 5bdaa72801d6ab35cbb975516324b536f5278f13
Author: Dongjoon Hyun <[email protected]>
AuthorDate: Sat Nov 23 11:15:48 2024 +0100

    [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]>
---
 sbin/start-connect-server.sh | 2 +-
 sbin/start-history-server.sh | 2 +-
 sbin/start-master.sh         | 2 +-
 sbin/start-thriftserver.sh   | 2 +-
 sbin/start-worker.sh         | 2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/sbin/start-connect-server.sh b/sbin/start-connect-server.sh
index 668423bad1cb..7f0c430a468a 100755
--- a/sbin/start-connect-server.sh
+++ b/sbin/start-connect-server.sh
@@ -33,7 +33,7 @@ if [[ "$@" = *--help ]] || [[ "$@" = *-h ]]; then
   echo "Usage: ./sbin/start-connect-server.sh [--wait] [options]"
 
   "${SPARK_HOME}"/bin/spark-submit --help 2>&1 | grep -v Usage 1>&2
-  exit 1
+  exit 0
 fi
 
 . "${SPARK_HOME}/bin/load-spark-env.sh"
diff --git a/sbin/start-history-server.sh b/sbin/start-history-server.sh
index 71dace47767c..a99c8e557885 100755
--- a/sbin/start-history-server.sh
+++ b/sbin/start-history-server.sh
@@ -40,7 +40,7 @@ if [[ "$@" = *--help ]] || [[ "$@" = *-h ]]; then
   pattern+="\|Registered signal handler for"
 
   "${SPARK_HOME}"/bin/spark-class $CLASS --help 2>&1 | grep -v "$pattern" 1>&2
-  exit 1
+  exit 0
 fi
 
 . "${SPARK_HOME}/sbin/spark-config.sh"
diff --git a/sbin/start-master.sh b/sbin/start-master.sh
index 36fe4b4abeb9..25e739132f0d 100755
--- a/sbin/start-master.sh
+++ b/sbin/start-master.sh
@@ -35,7 +35,7 @@ if [[ "$@" = *--help ]] || [[ "$@" = *-h ]]; then
   pattern+="\|Registered signal handler for"
 
   "${SPARK_HOME}"/bin/spark-class $CLASS --help 2>&1 | grep -v "$pattern" 1>&2
-  exit 1
+  exit 0
 fi
 
 ORIGINAL_ARGS="$@"
diff --git a/sbin/start-thriftserver.sh b/sbin/start-thriftserver.sh
index b1d38713218b..a45752697934 100755
--- a/sbin/start-thriftserver.sh
+++ b/sbin/start-thriftserver.sh
@@ -52,7 +52,7 @@ function usage {
 
 if [[ "$@" = *--help ]] || [[ "$@" = *-h ]]; then
   usage
-  exit 1
+  exit 0
 fi
 
 export SUBMIT_USAGE_FUNCTION=usage
diff --git a/sbin/start-worker.sh b/sbin/start-worker.sh
index fd58f01bac2e..c0147a51b3f2 100755
--- a/sbin/start-worker.sh
+++ b/sbin/start-worker.sh
@@ -47,7 +47,7 @@ if [[ $# -lt 1 ]] || [[ "$@" = *--help ]] || [[ "$@" = *-h 
]]; then
   pattern+="\|Registered signal handler for"
 
   "${SPARK_HOME}"/bin/spark-class $CLASS --help 2>&1 | grep -v "$pattern" 1>&2
-  exit 1
+  [[ $# -lt 1 ]] && exit 1 || exit 0
 fi
 
 . "${SPARK_HOME}/sbin/spark-config.sh"


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to