Skip to content

Commit

Permalink
[SPARK-24683][K8S] Fix k8s no resource on palantir/master (apache#387)
Browse files Browse the repository at this point in the history
* [SPARK-24683][K8S] Add main class if no resource is provided for k8s.

* Add integration test.
  • Loading branch information
mccheah authored Jun 28, 2018
1 parent 771a5c7 commit eddf77b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 2 additions & 0 deletions core/src/main/scala/org/apache/spark/deploy/SparkSubmit.scala
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,8 @@ private[spark] class SparkSubmit extends Logging {
childArgs ++= Array("--primary-java-resource", args.primaryResource)
childArgs ++= Array("--main-class", args.mainClass)
}
} else {
childArgs ++= Array("--main-class", args.mainClass)
}
if (args.childArgs != null) {
args.childArgs.foreach { arg =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ private[spark] class KubernetesDriverBuilder(
case JavaMainAppResource(_) =>
provideJavaStep(kubernetesConf)
case PythonMainAppResource(_) =>
providePythonStep(kubernetesConf)}.getOrElse(provideJavaStep(kubernetesConf))
providePythonStep(kubernetesConf)}
.getOrElse(provideJavaStep(kubernetesConf))

val localFiles = KubernetesUtils.submitterLocalFiles(kubernetesConf.sparkFiles)
.map(new File(_))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ import java.nio.file.{Path, Paths}
import java.util.UUID
import java.util.regex.Pattern

import scala.collection.JavaConverters._

import com.google.common.io.PatternFilenameFilter
import io.fabric8.kubernetes.api.model.{Container, Pod}
import org.scalatest.{BeforeAndAfter, BeforeAndAfterAll}
import org.scalatest.concurrent.{Eventually, PatienceConfiguration}
import org.scalatest.time.{Minutes, Seconds, Span}
import scala.collection.JavaConverters._

import org.apache.spark.SparkFunSuite
import org.apache.spark.deploy.k8s.integrationtest.backend.{IntegrationTestBackend, IntegrationTestBackendFactory}
import org.apache.spark.deploy.k8s.integrationtest.config._
import org.apache.spark.launcher.SparkLauncher

private[spark] class KubernetesSuite extends SparkFunSuite
with BeforeAndAfterAll with BeforeAndAfter {
Expand Down Expand Up @@ -109,6 +109,12 @@ private[spark] class KubernetesSuite extends SparkFunSuite
runSparkPiAndVerifyCompletion()
}

test("Use SparkLauncher.NO_RESOURCE") {
sparkAppConf.setJars(Seq(containerLocalSparkDistroExamplesJar))
runSparkPiAndVerifyCompletion(
appResource = SparkLauncher.NO_RESOURCE)
}

test("Run SparkPi with a master URL without a scheme.") {
val url = kubernetesTestComponents.kubernetesClient.getMasterUrl
val k8sMasterUrl = if (url.getPort < 0) {
Expand Down

0 comments on commit eddf77b

Please sign in to comment.