Skip to content

Conversation

@dongjoon-hyun
Copy link
Member

@dongjoon-hyun dongjoon-hyun commented Nov 22, 2024

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

case HELP =>
printUsageAndExit(0)

Spark Master

case ("--help") :: tail =>
printUsageAndExit(0)

Spark Worker

case ("--help") :: tail =>
printUsageAndExit(0)

Spark History Server

case ("--help" | "-h") :: tail =>
printUsageAndExit(0)

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.


"${SPARK_HOME}"/bin/spark-class $CLASS --help 2>&1 | grep -v "$pattern" 1>&2
exit 1
[[ $# -lt 1 ]] && exit 1 || exit 0
Copy link
Member Author

Choose a reason for hiding this comment

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

Note that,

  • sbin/start-worker.sh with no argument exits with 1 in the same way.
  • sbin/start-worker.sh --help exists with 0 after this PR.

@MaxGekk
Copy link
Member

MaxGekk commented Nov 23, 2024

+1, LGTM. Merging to master.
Thank you, @dongjoon-hyun.

@MaxGekk MaxGekk closed this in 5bdaa72 Nov 23, 2024
@dongjoon-hyun
Copy link
Member Author

Thank you, @MaxGekk .

@dongjoon-hyun dongjoon-hyun deleted the SPARK-50398 branch November 16, 2025 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants