Skip to content
This repository was archived by the owner on Jan 9, 2020. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
7570eab
[SPARK-22788][STREAMING] Use correct hadoop config for fs append supp…
Dec 20, 2017
7798c9e
[SPARK-22824] Restore old offset for binary compatibility
jose-torres Dec 20, 2017
d762d11
[SPARK-22832][ML] BisectingKMeans unpersist unused datasets
zhengruifeng Dec 20, 2017
c89b431
[SPARK-22849] ivy.retrieve pattern should also consider `classifier`
gatorsmile Dec 20, 2017
792915c
[SPARK-22830] Scala Coding style has been improved in Spark Examples
chetkhatri Dec 20, 2017
b176014
[SPARK-22847][CORE] Remove redundant code in AppStatusListener while …
Ngone51 Dec 20, 2017
0114c89
[SPARK-22845][SCHEDULER] Modify spark.kubernetes.allocation.batch.del…
foxish Dec 21, 2017
fb0562f
[SPARK-22810][ML][PYSPARK] Expose Python API for LinearRegression wit…
yanboliang Dec 21, 2017
9c289a5
[SPARK-22387][SQL] Propagate session configs to data source read/writ…
jiangxb1987 Dec 21, 2017
d3ae3e1
[SPARK-19634][SQL][ML][FOLLOW-UP] Improve interface of dataframe vect…
WeichenXu123 Dec 21, 2017
cb9fc8d
[SPARK-22848][SQL] Eliminate mutable state from Stack
kiszk Dec 21, 2017
59d5263
[SPARK-22324][SQL][PYTHON] Upgrade Arrow to 0.8.0
BryanCutler Dec 21, 2017
0abaf31
[SPARK-22852][BUILD] Exclude -Xlint:unchecked from sbt javadoc flags
easel Dec 21, 2017
4c2efde
[SPARK-22855][BUILD] Add -no-java-comments to sbt docs/scalacOptions
easel Dec 21, 2017
8a0ed5a
[SPARK-22668][SQL] Ensure no global variables in arguments of method …
cloud-fan Dec 21, 2017
d3a1d95
[SPARK-22786][SQL] only use AppStatusPlugin in history server
cloud-fan Dec 21, 2017
4e107fd
[SPARK-22822][TEST] Basic tests for WindowFrameCoercion and DecimalPr…
wangyum Dec 21, 2017
fe65361
[SPARK-22042][FOLLOW-UP][SQL] ReorderJoinPredicates can break when ch…
tejasapatil Dec 21, 2017
7beb375
[SPARK-22861][SQL] SQLAppStatusListener handles multi-job executions.
squito Dec 21, 2017
7ab165b
[SPARK-22648][K8S] Spark on Kubernetes - Documentation
foxish Dec 22, 2017
c0abb1d
[SPARK-22854][UI] Read Spark version from event logs.
Dec 22, 2017
c6f01ca
[SPARK-22750][SQL] Reuse mutable states when possible
mgaido91 Dec 22, 2017
a36b78b
[SPARK-22450][CORE][MLLIB][FOLLOWUP] safely register class for mllib …
zhengruifeng Dec 22, 2017
22e1849
[SPARK-22866][K8S] Fix path issue in Kubernetes dockerfile
foxish Dec 22, 2017
8df1da3
[SPARK-22862] Docs on lazy elimination of columns missing from an enc…
marmbrus Dec 22, 2017
13190a4
[SPARK-22874][PYSPARK][SQL] Modify checking pandas version to use Loo…
ueshin Dec 22, 2017
d23dc5b
[SPARK-22346][ML] VectorSizeHint Transformer for using VectorAssemble…
MrBago Dec 22, 2017
d3cbbdd
[SPARK-22757][Kubernetes] Enable use of remote dependencies in Kubern…
liyinan926 Dec 12, 2017
5d2cbc8
Addressed first round of comments
liyinan926 Dec 15, 2017
4ee76af
Addressed the second round of comments
liyinan926 Dec 16, 2017
9c8051a
Create one task per jar/file to download in the init-container
liyinan926 Dec 16, 2017
1f65417
More review comments
liyinan926 Dec 18, 2017
109ad80
Shorten variable names
liyinan926 Dec 19, 2017
c21fdcf
Removed traits that have only a single implementation
liyinan926 Dec 19, 2017
a3cd71d
Remove unused class arguments
liyinan926 Dec 19, 2017
23c5cd9
Improved documentation
liyinan926 Dec 19, 2017
2ec15c4
Addressed latest round of comments
liyinan926 Dec 20, 2017
5d1f889
Addressed more comments
liyinan926 Dec 21, 2017
9d9c841
Updated names of two configuration properties
liyinan926 Dec 22, 2017
c51bc56
Addressed more comments
liyinan926 Dec 25, 2017
28343fb
Addressed one more comment
liyinan926 Dec 26, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Addressed latest round of comments
  • Loading branch information
liyinan926 committed Dec 23, 2017
commit 2ec15c489a7a0429a0b3064ea50f61c75020685b
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,13 @@ private[spark] object Config extends Logging {
.timeConf(TimeUnit.MINUTES)
.createWithDefault(5)

val INIT_CONTAINER_MAX_THREAD_POOL_SIZE =
ConfigBuilder("spark.kubernetes.initContainer.maxThreadPoolSize")
.doc("Maximum size of the thread pool in the init-container for downloading remote " +
"dependencies.")
.intConf
.createWithDefault(5)

val INIT_CONTAINER_REMOTE_JARS =
ConfigBuilder("spark.kubernetes.initContainer.remoteJars")
.doc("Comma-separated list of jar URIs to download in the init-container. This is " +
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,12 @@ private[spark] class InitContainerBootstrap(
case SPARK_POD_EXECUTOR_ROLE => "spark.executorEnv."
case _ => throw new SparkException(s"$sparkRole is not a valid Spark pod role")
}
val customEnvVars = sparkConf.getAllWithPrefix(customEnvVarKeyPrefix).toSeq.map { env =>
new EnvVarBuilder()
.withName(env._1)
.withValue(env._2)
.build()
val customEnvVars = sparkConf.getAllWithPrefix(customEnvVarKeyPrefix).toSeq.map {
case (key, value) =>
new EnvVarBuilder()
.withName(key)
.withValue(value)
.build()
}

val initContainer = new ContainerBuilder(original.initContainer)
Expand Down Expand Up @@ -102,14 +103,13 @@ private[spark] class InitContainerBootstrap(
.endSpec()
.build()

val mainContainer = new ContainerBuilder(
original.mainContainer)
.addToVolumeMounts(sharedVolumeMounts: _*)
.addNewEnv()
.withName(ENV_MOUNTED_FILES_DIR)
.withValue(filesDownloadPath)
.endEnv()
.build()
val mainContainer = new ContainerBuilder(original.mainContainer)
.addToVolumeMounts(sharedVolumeMounts: _*)
.addNewEnv()
.withName(ENV_MOUNTED_FILES_DIR)
.withValue(filesDownloadPath)
.endEnv()
.build()

PodWithDetachedInitContainer(
podWithBasicVolumes,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,49 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.spark.deploy.k8s.submit
package org.apache.spark.deploy.k8s

import java.io.File

import io.fabric8.kubernetes.api.model.{Container, Pod, PodBuilder}

import org.apache.spark.SparkConf
import org.apache.spark.util.Utils

private[spark] object KubernetesFileUtils {
private[spark] object KubernetesUtils {

/**
* Extract and parse Spark configuration properties with a given name prefix and
* return the result as a Map. Keys must not have more than one value.
*
* @param sparkConf Spark configuration
* @param prefix the given property name prefix
* @return a Map storing the configuration property keys and values
*/
def parsePrefixedKeyValuePairs(
sparkConf: SparkConf,
prefix: String): Map[String, String] = {
sparkConf.getAllWithPrefix(prefix).toMap
}

def requireNandDefined(opt1: Option[_], opt2: Option[_], errMessage: String): Unit = {
opt1.foreach { _ => require(opt2.isEmpty, errMessage) }
}

/**
* Append the given init-container to a pod's list of init-containers..
*
* @param originalPodSpec original specification of the pod
* @param initContainer the init-container to add to the pod
* @return the pod with the init-container added to the list of InitContainers
*/
def appendInitContainer(originalPodSpec: Pod, initContainer: Container): Pod = {
new PodBuilder(originalPodSpec)
.editOrNewSpec()
.addToInitContainers(initContainer)
.endSpec()
.build()
}

/**
* For the given collection of file URIs, resolves them as follows:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,13 @@ private[spark] class MountSecretsBootstrap(secretNamesToMountPaths: Map[String,
}

var containerBuilder = new ContainerBuilder(container)
secretNamesToMountPaths.foreach { namePath =>
containerBuilder = containerBuilder
.addNewVolumeMount()
.withName(secretVolumeName(namePath._1))
.withMountPath(namePath._2)
.endVolumeMount()
secretNamesToMountPaths.foreach {
case (name, path) =>
containerBuilder = containerBuilder
.addNewVolumeMount()
.withName(secretVolumeName(name))
.withMountPath(path)
.endVolumeMount()
}

(podBuilder.build(), containerBuilder.build())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ private[spark] object SparkKubernetesClientFactory {
.map(new File(_))
.orElse(defaultServiceAccountToken)
val oauthTokenValue = sparkConf.getOption(oauthTokenConf)
ConfigurationUtils.requireNandDefined(
KubernetesUtils.requireNandDefined(
oauthTokenFile,
oauthTokenValue,
s"Cannot specify OAuth token through both a file $oauthTokenFileConf and a " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import java.util.UUID
import com.google.common.primitives.Longs

import org.apache.spark.SparkConf
import org.apache.spark.deploy.k8s.{ConfigurationUtils, MountSecretsBootstrap}
import org.apache.spark.deploy.k8s.{KubernetesUtils, MountSecretsBootstrap}
import org.apache.spark.deploy.k8s.Config._
import org.apache.spark.deploy.k8s.Constants._
import org.apache.spark.deploy.k8s.submit.steps._
Expand Down Expand Up @@ -61,7 +61,7 @@ private[spark] class DriverConfigOrchestrator(
private val filesDownloadPath = sparkConf.get(FILES_DOWNLOAD_LOCATION)

def getAllConfigurationSteps: Seq[DriverConfigurationStep] = {
val driverCustomLabels = ConfigurationUtils.parsePrefixedKeyValuePairs(
val driverCustomLabels = KubernetesUtils.parsePrefixedKeyValuePairs(
sparkConf,
KUBERNETES_DRIVER_LABEL_PREFIX)
require(!driverCustomLabels.contains(SPARK_APP_ID_LABEL), "Label with key " +
Expand All @@ -71,15 +71,15 @@ private[spark] class DriverConfigOrchestrator(
s"$SPARK_ROLE_LABEL is not allowed as it is reserved for Spark bookkeeping " +
"operations.")

val secretNamesToMountPaths = ConfigurationUtils.parsePrefixedKeyValuePairs(
val secretNamesToMountPaths = KubernetesUtils.parsePrefixedKeyValuePairs(
sparkConf,
KUBERNETES_DRIVER_SECRETS_PREFIX)

val allDriverLabels = driverCustomLabels ++ Map(
SPARK_APP_ID_LABEL -> kubernetesAppId,
SPARK_ROLE_LABEL -> SPARK_POD_DRIVER_ROLE)

val initialSubmissionStep = new BaseDriverConfigurationStep(
val initialSubmissionStep = new BasicDriverConfigurationStep(
kubernetesAppId,
kubernetesResourceNamePrefix,
allDriverLabels,
Expand Down Expand Up @@ -117,50 +117,49 @@ private[spark] class DriverConfigOrchestrator(
.map(_.split(","))
.getOrElse(Array.empty[String])

val maybeDependencyResolutionStep = if (sparkJars.nonEmpty || sparkFiles.nonEmpty) {
Some(new DependencyResolutionStep(
val dependencyResolutionStep = if (sparkJars.nonEmpty || sparkFiles.nonEmpty) {
Seq(new DependencyResolutionStep(
sparkJars,
sparkFiles,
jarsDownloadPath,
filesDownloadPath))
} else {
None
Nil
}

val mayBeInitContainerBootstrapStep =
if (areAnyFilesNonContainerLocal(sparkJars ++ sparkFiles)) {
val orchestrator = new InitContainerConfigOrchestrator(
sparkJars,
sparkFiles,
jarsDownloadPath,
filesDownloadPath,
imagePullPolicy,
initContainerConfigMapName,
INIT_CONTAINER_PROPERTIES_FILE_NAME,
sparkConf)
val bootstrapStep = new DriverInitContainerBootstrapStep(
orchestrator.getAllConfigurationSteps,
initContainerConfigMapName,
INIT_CONTAINER_PROPERTIES_FILE_NAME)

Some(bootstrapStep)
} else {
None
}
val initContainerBootstrapStep = if (areAnyFilesNonContainerLocal(sparkJars ++ sparkFiles)) {
val orchestrator = new InitContainerConfigOrchestrator(
sparkJars,
sparkFiles,
jarsDownloadPath,
filesDownloadPath,
imagePullPolicy,
initContainerConfigMapName,
INIT_CONTAINER_PROPERTIES_FILE_NAME,
sparkConf)
val bootstrapStep = new DriverInitContainerBootstrapStep(
orchestrator.getAllConfigurationSteps,
initContainerConfigMapName,
INIT_CONTAINER_PROPERTIES_FILE_NAME)

Seq(bootstrapStep)
} else {
Nil
}

val mayBeMountSecretsStep = if (secretNamesToMountPaths.nonEmpty) {
Some(new DriverMountSecretsStep(new MountSecretsBootstrap(secretNamesToMountPaths)))
val mountSecretsStep = if (secretNamesToMountPaths.nonEmpty) {
Seq(new DriverMountSecretsStep(new MountSecretsBootstrap(secretNamesToMountPaths)))
} else {
None
Nil
}

Seq(
initialSubmissionStep,
serviceBootstrapStep,
kubernetesCredentialsStep) ++
maybeDependencyResolutionStep.toSeq ++
mayBeInitContainerBootstrapStep.toSeq ++
mayBeMountSecretsStep.toSeq
dependencyResolutionStep ++
initContainerBootstrapStep ++
mountSecretsStep
}

private def areAnyFilesNonContainerLocal(files: Seq[String]): Boolean = {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ import io.fabric8.kubernetes.api.model.{ContainerBuilder, EnvVarBuilder, EnvVarS

import org.apache.spark.{SparkConf, SparkException}
import org.apache.spark.deploy.k8s.Config._
import org.apache.spark.deploy.k8s.ConfigurationUtils
import org.apache.spark.deploy.k8s.Constants._
import org.apache.spark.deploy.k8s.KubernetesUtils
import org.apache.spark.deploy.k8s.submit.KubernetesDriverSpec
import org.apache.spark.internal.config.{DRIVER_CLASS_PATH, DRIVER_MEMORY, DRIVER_MEMORY_OVERHEAD}

/**
* Performs basic configuration for the driver pod.
*/
private[spark] class BaseDriverConfigurationStep(
private[spark] class BasicDriverConfigurationStep(
kubernetesAppId: String,
resourceNamePrefix: String,
driverLabels: Map[String, String],
Expand Down Expand Up @@ -71,7 +71,7 @@ private[spark] class BaseDriverConfigurationStep(
.build()
}

val driverCustomAnnotations = ConfigurationUtils.parsePrefixedKeyValuePairs(
val driverCustomAnnotations = KubernetesUtils.parsePrefixedKeyValuePairs(
sparkConf, KUBERNETES_DRIVER_ANNOTATION_PREFIX)
require(!driverCustomAnnotations.contains(SPARK_APP_NAME_ANNOTATION),
s"Annotation with key $SPARK_APP_NAME_ANNOTATION is not allowed as it is reserved for" +
Expand All @@ -87,7 +87,7 @@ private[spark] class BaseDriverConfigurationStep(

val driverAnnotations = driverCustomAnnotations ++ Map(SPARK_APP_NAME_ANNOTATION -> appName)

val nodeSelector = ConfigurationUtils.parsePrefixedKeyValuePairs(
val nodeSelector = KubernetesUtils.parsePrefixedKeyValuePairs(
sparkConf, KUBERNETES_NODE_SELECTOR_PREFIX)

val driverCpuQuantity = new QuantityBuilder(false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ import java.io.File
import io.fabric8.kubernetes.api.model.ContainerBuilder

import org.apache.spark.deploy.k8s.Constants._
import org.apache.spark.deploy.k8s.submit.{KubernetesDriverSpec, KubernetesFileUtils}
import org.apache.spark.deploy.k8s.KubernetesUtils
import org.apache.spark.deploy.k8s.submit.KubernetesDriverSpec

/**
* Step that configures the classpath, spark.jars, and spark.files for the driver given that the
Expand All @@ -34,8 +35,8 @@ private[spark] class DependencyResolutionStep(
filesDownloadPath: String) extends DriverConfigurationStep {

override def configureDriver(driverSpec: KubernetesDriverSpec): KubernetesDriverSpec = {
val resolvedSparkJars = KubernetesFileUtils.resolveFileUris(sparkJars, jarsDownloadPath)
val resolvedSparkFiles = KubernetesFileUtils.resolveFileUris(
val resolvedSparkJars = KubernetesUtils.resolveFileUris(sparkJars, jarsDownloadPath)
val resolvedSparkFiles = KubernetesUtils.resolveFileUris(
sparkFiles, filesDownloadPath)

val sparkConf = driverSpec.driverSparkConf.clone()
Expand All @@ -46,7 +47,7 @@ private[spark] class DependencyResolutionStep(
sparkConf.set("spark.files", resolvedSparkFiles.mkString(","))
}

val resolvedClasspath = KubernetesFileUtils.resolveFilePaths(sparkJars, jarsDownloadPath)
val resolvedClasspath = KubernetesUtils.resolveFilePaths(sparkJars, jarsDownloadPath)
val resolvedDriverContainer = if (resolvedClasspath.nonEmpty) {
new ContainerBuilder(driverSpec.driverContainer)
.addNewEnv()
Expand Down
Loading