Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/19954#discussion_r157320177
  
    --- Diff: 
resource-managers/kubernetes/core/src/main/scala/org/apache/spark/deploy/k8s/InitContainerBootstrap.scala
 ---
    @@ -0,0 +1,127 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package org.apache.spark.deploy.k8s
    +
    +import scala.collection.JavaConverters._
    +
    +import io.fabric8.kubernetes.api.model.{ContainerBuilder, 
EmptyDirVolumeSource, EnvVarBuilder, PodBuilder, VolumeMount, 
VolumeMountBuilder}
    +
    +import org.apache.spark.{SparkConf, SparkException}
    +import org.apache.spark.deploy.k8s.Config._
    +import org.apache.spark.deploy.k8s.Constants._
    +
    +/**
    + * This is separated out from the init-container steps API because this 
component can be reused to
    + * set up the init-container for executors as well.
    + */
    +private[spark] trait InitContainerBootstrap {
    +  /**
    +   * Bootstraps an init-container that downloads dependencies to be used 
by a main container.
    +   */
    +  def bootstrapInitContainer(
    +      originalPodWithInitContainer: PodWithDetachedInitContainer)
    +  : PodWithDetachedInitContainer
    +}
    +
    +private[spark] class InitContainerBootstrapImpl(
    +    initContainerImage: String,
    +    dockerImagePullPolicy: String,
    +    jarsDownloadPath: String,
    +    filesDownloadPath: String,
    +    downloadTimeoutMinutes: Long,
    +    initContainerConfigMapName: String,
    +    initContainerConfigMapKey: String,
    +    sparkRole: String,
    +    sparkConf: SparkConf)
    +  extends InitContainerBootstrap {
    +
    +  override def bootstrapInitContainer(
    +      podWithDetachedInitContainer: PodWithDetachedInitContainer): 
PodWithDetachedInitContainer = {
    +    val sharedVolumeMounts = Seq[VolumeMount](
    +      new VolumeMountBuilder()
    +        .withName(INIT_CONTAINER_DOWNLOAD_JARS_VOLUME_NAME)
    +        .withMountPath(jarsDownloadPath)
    +        .build(),
    +      new VolumeMountBuilder()
    +        .withName(INIT_CONTAINER_DOWNLOAD_FILES_VOLUME_NAME)
    +        .withMountPath(filesDownloadPath)
    +        .build())
    +
    +    val initContainerCustomEnvVarKeyPrefix = sparkRole match {
    +      case SPARK_POD_DRIVER_ROLE => KUBERNETES_DRIVER_ENV_KEY
    +      case SPARK_POD_EXECUTOR_ROLE => "spark.executorEnv."
    +      case _ => throw new SparkException(s"$sparkRole is not a valid Spark 
pod role")
    +    }
    +    val initContainerCustomEnvVars = 
sparkConf.getAllWithPrefix(initContainerCustomEnvVarKeyPrefix)
    +      .toSeq
    +      .map(env =>
    --- End diff --
    
    `.map { env =>`


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to