Skip to content

Commit eddf77b

Browse files
authored
[SPARK-24683][K8S] Fix k8s no resource on palantir/master (apache#387)
* [SPARK-24683][K8S] Add main class if no resource is provided for k8s. * Add integration test.
1 parent 771a5c7 commit eddf77b

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,8 @@ private[spark] class SparkSubmit extends Logging {
702702
childArgs ++= Array("--primary-java-resource", args.primaryResource)
703703
childArgs ++= Array("--main-class", args.mainClass)
704704
}
705+
} else {
706+
childArgs ++= Array("--main-class", args.mainClass)
705707
}
706708
if (args.childArgs != null) {
707709
args.childArgs.foreach { arg =>

resource-managers/kubernetes/core/src/main/scala/org/apache/spark/deploy/k8s/submit/KubernetesDriverBuilder.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ private[spark] class KubernetesDriverBuilder(
6868
case JavaMainAppResource(_) =>
6969
provideJavaStep(kubernetesConf)
7070
case PythonMainAppResource(_) =>
71-
providePythonStep(kubernetesConf)}.getOrElse(provideJavaStep(kubernetesConf))
71+
providePythonStep(kubernetesConf)}
72+
.getOrElse(provideJavaStep(kubernetesConf))
7273

7374
val localFiles = KubernetesUtils.submitterLocalFiles(kubernetesConf.sparkFiles)
7475
.map(new File(_))

resource-managers/kubernetes/integration-tests/src/test/scala/org/apache/spark/deploy/k8s/integrationtest/KubernetesSuite.scala

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@ import java.nio.file.{Path, Paths}
2121
import java.util.UUID
2222
import java.util.regex.Pattern
2323

24-
import scala.collection.JavaConverters._
25-
2624
import com.google.common.io.PatternFilenameFilter
2725
import io.fabric8.kubernetes.api.model.{Container, Pod}
2826
import org.scalatest.{BeforeAndAfter, BeforeAndAfterAll}
2927
import org.scalatest.concurrent.{Eventually, PatienceConfiguration}
3028
import org.scalatest.time.{Minutes, Seconds, Span}
29+
import scala.collection.JavaConverters._
3130

3231
import org.apache.spark.SparkFunSuite
3332
import org.apache.spark.deploy.k8s.integrationtest.backend.{IntegrationTestBackend, IntegrationTestBackendFactory}
3433
import org.apache.spark.deploy.k8s.integrationtest.config._
34+
import org.apache.spark.launcher.SparkLauncher
3535

3636
private[spark] class KubernetesSuite extends SparkFunSuite
3737
with BeforeAndAfterAll with BeforeAndAfter {
@@ -109,6 +109,12 @@ private[spark] class KubernetesSuite extends SparkFunSuite
109109
runSparkPiAndVerifyCompletion()
110110
}
111111

112+
test("Use SparkLauncher.NO_RESOURCE") {
113+
sparkAppConf.setJars(Seq(containerLocalSparkDistroExamplesJar))
114+
runSparkPiAndVerifyCompletion(
115+
appResource = SparkLauncher.NO_RESOURCE)
116+
}
117+
112118
test("Run SparkPi with a master URL without a scheme.") {
113119
val url = kubernetesTestComponents.kubernetesClient.getMasterUrl
114120
val k8sMasterUrl = if (url.getPort < 0) {

0 commit comments

Comments
 (0)