Skip to content

Commit 77bdcbd

Browse files
committed
Fix argument validation error
1 parent 8a53de1 commit 77bdcbd

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

yarn/src/main/scala/org/apache/spark/deploy/yarn/ClientArguments.scala

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,14 @@ private[spark] class ClientArguments(args: Array[String], sparkConf: SparkConf)
103103
* This is intended to be called only after the provided arguments have been parsed.
104104
*/
105105
private def validateArgs(): Unit = {
106-
if (numExecutors <= 0) {
106+
if (numExecutors < 0 || (!isDynamicAllocationEnabled && numExecutors == 0)) {
107107
throw new IllegalArgumentException(
108-
"You must specify at least 1 executor!\n" + getUsageMessage())
108+
s"""
109+
|Number of executors $numExecutors is not legal.
110+
|If dynamic allocation is enable, number of executors should at least be 0.
111+
|If dynamic allocation is not enabled, number of executors should at least be 1.
112+
|${getUsageMessage()}
113+
""".stripMargin)
109114
}
110115
if (executorCores < sparkConf.getInt("spark.task.cpus", 1)) {
111116
throw new SparkException("Executor cores must not be less than " +

0 commit comments

Comments
 (0)