@@ -98,6 +98,7 @@ object SparkSubmit extends CommandLineUtils with Logging {
9898 " org.apache.spark.deploy.yarn.YarnClusterApplication"
9999 private [deploy] val REST_CLUSTER_SUBMIT_CLASS = classOf [RestSubmissionClientApp ].getName()
100100 private [deploy] val STANDALONE_CLUSTER_SUBMIT_CLASS = classOf [ClientApp ].getName()
101+ private [deploy] val KUBERNETES_CLUSTER_SUBMIT_CLASS = " org.apache.spark.deploy.k8s.submit.Client"
101102
102103 // scalastyle:off println
103104 private [spark] def printVersionAndExit (): Unit = {
@@ -298,6 +299,12 @@ object SparkSubmit extends CommandLineUtils with Logging {
298299
299300 if (clusterManager == KUBERNETES ) {
300301 args.master = Utils .checkAndGetK8sMasterUrl(args.master)
302+ // Make sure YARN is included in our build if we're trying to use it
303+ if (! Utils .classIsLoadable(KUBERNETES_CLUSTER_SUBMIT_CLASS ) && ! Utils .isTesting) {
304+ printErrorAndExit(
305+ " Could not load KUBERNETES classes. " +
306+ " This copy of Spark may not have been compiled with KUBERNETES support." )
307+ }
301308 }
302309
303310 // Fail fast, the following modes are not supported or applicable
@@ -721,7 +728,7 @@ object SparkSubmit extends CommandLineUtils with Logging {
721728 }
722729
723730 if (isKubernetesCluster) {
724- childMainClass = " org.apache.spark.deploy.k8s.submit.Client "
731+ childMainClass = KUBERNETES_CLUSTER_SUBMIT_CLASS
725732 if (args.primaryResource != SparkLauncher .NO_RESOURCE ) {
726733 childArgs ++= Array (" --primary-java-resource" , args.primaryResource)
727734 }
0 commit comments