-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-22646] [Submission] Spark on Kubernetes - basic submission client #19717
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
dcaac45
27c67ff
6d597d0
5b9fa39
5ccadb5
12f2797
c35fe48
faa2849
347ed69
0e8ca01
3a0b8e3
83d0b9c
44c40b1
67bc847
7d2b303
caf2206
2e7810b
cbcd30e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,6 +33,13 @@ import org.apache.spark.deploy.k8s.submit.steps.DriverConfigurationStep | |
| import org.apache.spark.internal.Logging | ||
| import org.apache.spark.util.Utils | ||
|
|
||
| /** | ||
| * Encapsulates arguments to the submission client. | ||
| * | ||
| * @param mainAppResource the main application resource | ||
| * @param mainClass the main class of the application to run | ||
| * @param driverArgs arguments to the driver | ||
| */ | ||
| private[spark] case class ClientArguments( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: add comments to describe the usage of this class, and the meaning of each params.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
| mainAppResource: MainAppResource, | ||
| mainClass: String, | ||
|
|
@@ -58,7 +65,7 @@ private[spark] object ClientArguments { | |
| } | ||
|
|
||
| require(mainAppResource.isDefined, | ||
| "Main app resource must be defined by either --primary-py-file or --primary-java-resource.") | ||
| "Main app resource must be defined by --primary-java-resource.") | ||
| require(mainClass.isDefined, "Main class must be specified via --main-class") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. mainAppResource need not be valid here
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wondering why?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For case of spark examples, spark thrift server, etc - there is no main app resource - the bits are bundled as part of spark itself.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Got it, removed the check. |
||
|
|
||
| ClientArguments( | ||
|
|
@@ -68,6 +75,19 @@ private[spark] object ClientArguments { | |
| } | ||
| } | ||
|
|
||
| /** | ||
| * Submits a Spark application to run on Kubernetes by creating the driver pod and starting a | ||
| * watcher that monitors and logs the application status. Waits for the application to terminate if | ||
| * spark.kubernetes.submission.waitAppCompletion is true. | ||
| * | ||
| * @param submissionSteps steps that collectively configure the driver | ||
| * @param submissionSparkConf the submission client Spark configuration | ||
| * @param kubernetesClient the client to talk to the Kubernetes API server | ||
| * @param waitForAppCompletion a flag indicating whether the client should wait for the application | ||
| * to complete | ||
| * @param appName the application name | ||
| * @param loggingPodStatusWatcher a watcher that monitors and logs the application status | ||
| */ | ||
| private[spark] class Client( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: add comments to describe the usage of this class, and the meaning of each params.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
| submissionSteps: Seq[DriverConfigurationStep], | ||
| submissionSparkConf: SparkConf, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,8 +51,12 @@ private[spark] class DriverConfigurationStepsOrchestrator( | |
| submissionSparkConf, | ||
| KUBERNETES_DRIVER_LABEL_PREFIX) | ||
| require(!driverCustomLabels.contains(SPARK_APP_ID_LABEL), "Label with key " + | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit:
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, done. |
||
| s" $SPARK_APP_ID_LABEL is not allowed as it is reserved for Spark bookkeeping" + | ||
| " operations.") | ||
| s"$SPARK_APP_ID_LABEL is not allowed as it is reserved for Spark bookkeeping " + | ||
| "operations.") | ||
| require(!driverCustomLabels.contains(SPARK_ROLE_LABEL), "Label with key " + | ||
| s"$SPARK_ROLE_LABEL is not allowed as it is reserved for Spark bookkeeping " + | ||
| "operations.") | ||
|
|
||
| val allDriverLabels = driverCustomLabels ++ Map( | ||
| SPARK_APP_ID_LABEL -> kubernetesAppId, | ||
| SPARK_ROLE_LABEL -> SPARK_POD_DRIVER_ROLE) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,8 +41,9 @@ private[k8s] trait LoggingPodStatusWatcher extends Watcher[Pod] { | |
| * number. | ||
| */ | ||
| private[k8s] class LoggingPodStatusWatcherImpl( | ||
| appId: String, maybeLoggingInterval: Option[Long]) | ||
| extends LoggingPodStatusWatcher with Logging { | ||
| appId: String, | ||
| maybeLoggingInterval: Option[Long]) | ||
| extends LoggingPodStatusWatcher with Logging { | ||
|
|
||
| private val podCompletedFuture = new CountDownLatch(1) | ||
| // start timer for periodic logging | ||
|
|
@@ -66,10 +67,7 @@ private[k8s] class LoggingPodStatusWatcherImpl( | |
| override def eventReceived(action: Action, pod: Pod): Unit = { | ||
| this.pod = Option(pod) | ||
| action match { | ||
| case Action.DELETED => | ||
| closeWatch() | ||
|
|
||
| case Action.ERROR => | ||
| case Action.DELETED | Action.ERROR => | ||
| closeWatch() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need for
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is checked only for case of
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's because in both |
||
|
|
||
| case _ => | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -83,10 +83,11 @@ private[spark] class BaseDriverConfigurationStep( | |
| " Spark bookkeeping operations.") | ||
|
|
||
| val driverCustomEnvs = submissionSparkConf.getAllWithPrefix(KUBERNETES_DRIVER_ENV_KEY).toSeq | ||
| .map(env => new EnvVarBuilder() | ||
| .withName(env._1) | ||
| .withValue(env._2) | ||
| .build()) | ||
| .map(env => | ||
|
||
| new EnvVarBuilder() | ||
| .withName(env._1) | ||
| .withValue(env._2) | ||
| .build()) | ||
|
|
||
| val allDriverAnnotations = driverCustomAnnotations ++ Map(SPARK_APP_NAME_ANNOTATION -> appName) | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
rawMasterString.substring("k8s://".length)?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.