HeartSaVioR commented on a change in pull request #23599: [SPARK-24793][K8s]
Enhance spark-submit for app management
URL: https://github.com/apache/spark/pull/23599#discussion_r249299907
##########
File path: core/src/main/scala/org/apache/spark/deploy/SparkSubmit.scala
##########
@@ -95,20 +95,66 @@ private[spark] class SparkSubmit extends Logging {
}
/**
- * Kill an existing submission using the REST protocol. Standalone and Mesos
cluster mode only.
+ * Kill an existing submission.
+ * Standalone, Kubernetes and Mesos cluster mode only.
*/
private def kill(args: SparkSubmitArguments): Unit = {
- new RestSubmissionClient(args.master)
- .killSubmission(args.submissionToKill)
+ if (args.master.startsWith("k8s://")) {
+ try {
+ val ops =
Utils.classForName("org.apache.spark.deploy.k8s.submit.K8sSubmitOps$")
+ val killC =
Utils.classForName("org.apache.spark.deploy.k8s.submit.KillApplication")
+ val sparkConf = new SparkConf()
+ args.sparkProperties.foreach { case (k, v) => sparkConf.set(k, v) }
+ sparkConf.set("spark.master", args.master)
+ val f = ops.getDeclaredField("MODULE$")
+ val value = f.get(new Object())
+ value.getClass
+ .getDeclaredMethods
+ .filter(_.getName() == "execute")
+ .head
+ .invoke(value, args.submissionToKill, sparkConf,
+ killC.getConstructor().newInstance().asInstanceOf[Object])
+ } catch {
+ case e: Exception =>
+ throw new SparkException(s"Failed to kill application with
submission " +
+ s" id: ${args.submissionToKill}", e)
+ }
+ } else {
+ // Use the REST protocol (Standalone, Mesos).
+ new RestSubmissionClient(args.master)
+ .killSubmission(args.submissionToKill)
+ }
}
/**
* Request the status of an existing submission using the REST protocol.
* Standalone and Mesos cluster mode only.
*/
private def requestStatus(args: SparkSubmitArguments): Unit = {
- new RestSubmissionClient(args.master)
- .requestSubmissionStatus(args.submissionToRequestStatusFor)
+ if (args.master.startsWith("k8s://")) {
+ try {
+ val ops =
Utils.classForName("org.apache.spark.deploy.k8s.submit.K8sSubmitOps$")
Review comment:
Same here.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]