Skip to content

Commit bf696ff

Browse files
author
Andrew Or
committed
Add checks for enabling REST when using kill/status
1 parent 7ee6737 commit bf696ff

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

core/src/main/scala/org/apache/spark/deploy/SparkSubmitArguments.scala

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ private[spark] class SparkSubmitArguments(args: Seq[String], env: Map[String, St
6060
var driverToKill: String = null
6161
var driverToRequestStatusFor: String = null
6262

63+
private val restEnabledKey = "spark.submit.rest.enabled"
64+
6365
def action: SparkSubmitAction = {
6466
(driverToKill, driverToRequestStatusFor) match {
6567
case (null, null) => SparkSubmitAction.SUBMIT
@@ -237,6 +239,10 @@ private[spark] class SparkSubmitArguments(args: Seq[String], env: Map[String, St
237239
if (!isStandaloneCluster) {
238240
SparkSubmit.printErrorAndExit("Killing drivers is only supported in standalone cluster mode")
239241
}
242+
if (!isRestEnabled) {
243+
SparkSubmit.printErrorAndExit("Killing drivers is currently only supported " +
244+
s"through the REST interface. Please set $restEnabledKey to true.")
245+
}
240246
if (driverToKill == null) {
241247
SparkSubmit.printErrorAndExit("Please specify a driver to kill")
242248
}
@@ -247,6 +253,10 @@ private[spark] class SparkSubmitArguments(args: Seq[String], env: Map[String, St
247253
SparkSubmit.printErrorAndExit(
248254
"Requesting driver statuses is only supported in standalone cluster mode")
249255
}
256+
if (!isRestEnabled) {
257+
SparkSubmit.printErrorAndExit("Requesting driver statuses is currently only " +
258+
s"supported through the REST interface. Please set $restEnabledKey to true.")
259+
}
250260
if (driverToRequestStatusFor == null) {
251261
SparkSubmit.printErrorAndExit("Please specify a driver to request status for")
252262
}
@@ -258,7 +268,7 @@ private[spark] class SparkSubmitArguments(args: Seq[String], env: Map[String, St
258268

259269
/** Return whether the REST application submission protocol is enabled. */
260270
def isRestEnabled: Boolean = {
261-
sparkProperties.get("spark.submit.rest.enabled").getOrElse("false").toBoolean
271+
sparkProperties.get(restEnabledKey).getOrElse("false").toBoolean
262272
}
263273

264274
override def toString = {

0 commit comments

Comments
 (0)