Skip to content
This repository was archived by the owner on Jan 9, 2020. It is now read-only.

Commit 04aa26f

Browse files
committed
handle most PR comments
1 parent 7cdae31 commit 04aa26f

File tree

9 files changed

+36
-26
lines changed

9 files changed

+36
-26
lines changed

docs/running-on-kubernetes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,7 @@ from the other deployment modes. See the [configuration page](configuration.html
780780
</td>
781781
</tr>
782782
<tr>
783-
<td><code>spark.kubernetes.kerberos.rewewer.principal</code></td>
783+
<td><code>spark.kubernetes.kerberos.renewer.principal</code></td>
784784
<td>(none)</td>
785785
<td>
786786
Assuming you have set <code>spark.kubernetes.kerberos.enabled</code> to be true. This will let you specify

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,13 @@ private[spark] class HadoopConfBootstrapImpl(
4747
override def bootstrapMainContainerAndVolumes(
4848
originalPodWithMainContainer: PodWithMainContainer)
4949
: PodWithMainContainer = {
50-
logInfo("HADOOP_CONF_DIR defined. Mounting HDFS specific .xml files")
51-
val keyPaths = hadoopConfigFiles.map(file =>
50+
logInfo("HADOOP_CONF_DIR defined. Mounting Hadoop specific .xml files")
51+
val keyPaths = hadoopConfigFiles.map{ file =>
52+
val fileStringPath = file.toPath.getFileName.toString
5253
new KeyToPathBuilder()
53-
.withKey(file.toPath.getFileName.toString)
54-
.withPath(file.toPath.getFileName.toString)
55-
.build())
54+
.withKey(fileStringPath)
55+
.withPath(fileStringPath)
56+
.build() }
5657
val hadoopSupportedPod = new PodBuilder(originalPodWithMainContainer.pod)
5758
.editSpec()
5859
.addNewVolume()
@@ -64,7 +65,7 @@ private[spark] class HadoopConfBootstrapImpl(
6465
.endVolume()
6566
.endSpec()
6667
.build()
67-
val mainContainerWithMountedHadoopConf = new ContainerBuilder(
68+
val hadoopSupportedContainer = new ContainerBuilder(
6869
originalPodWithMainContainer.mainContainer)
6970
.addNewVolumeMount()
7071
.withName(HADOOP_FILE_VOLUME)
@@ -81,6 +82,6 @@ private[spark] class HadoopConfBootstrapImpl(
8182
.build()
8283
originalPodWithMainContainer.copy(
8384
pod = hadoopSupportedPod,
84-
mainContainer = mainContainerWithMountedHadoopConf)
85+
mainContainer = hadoopSupportedContainer)
8586
}
8687
}

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,11 @@ private[spark] class KerberosTokenConfBootstrapImpl(
3939
secretItemKey: String,
4040
userName: String) extends KerberosTokenConfBootstrap with Logging{
4141

42-
4342
override def bootstrapMainContainerAndVolumes(
4443
originalPodWithMainContainer: PodWithMainContainer)
4544
: PodWithMainContainer = {
4645
logInfo("Mounting HDFS DT from Secret for Secure HDFS")
47-
val dtMountedPod = new PodBuilder(originalPodWithMainContainer.pod)
46+
val secretMountedPod = new PodBuilder(originalPodWithMainContainer.pod)
4847
.editOrNewSpec()
4948
.addNewVolume()
5049
.withName(SPARK_APP_HADOOP_SECRET_VOLUME_NAME)
@@ -54,7 +53,8 @@ private[spark] class KerberosTokenConfBootstrapImpl(
5453
.endVolume()
5554
.endSpec()
5655
.build()
57-
val mainContainerWithMountedKerberos = new ContainerBuilder(
56+
// TODO: ENV_HADOOP_TOKEN_FILE_LOCATION should point to the latest token data item key.
57+
val secretMountedContainer = new ContainerBuilder(
5858
originalPodWithMainContainer.mainContainer)
5959
.addNewVolumeMount()
6060
.withName(SPARK_APP_HADOOP_SECRET_VOLUME_NAME)
@@ -70,7 +70,7 @@ private[spark] class KerberosTokenConfBootstrapImpl(
7070
.endEnv()
7171
.build()
7272
originalPodWithMainContainer.copy(
73-
pod = dtMountedPod,
74-
mainContainer = mainContainerWithMountedKerberos)
73+
pod = secretMountedPod,
74+
mainContainer = secretMountedContainer)
7575
}
7676
}

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,6 @@ package object config extends Logging {
157157
.stringConf
158158
.createOptional
159159

160-
private[spark] val KUBERNETES_SHUFFLE_DIR =
161-
ConfigBuilder("spark.kubernetes.shuffle.dir")
162-
.doc("Path to the shared shuffle directories.")
163-
.stringConf
164-
.createOptional
165-
166160
private[spark] val KUBERNETES_SHUFFLE_APISERVER_URI =
167161
ConfigBuilder("spark.kubernetes.shuffle.apiServer.url")
168162
.doc("URL to the Kubernetes API server that the shuffle service will monitor for Spark pods.")
@@ -523,7 +517,7 @@ package object config extends Logging {
523517
.createOptional
524518

525519
private[spark] val KUBERNETES_KERBEROS_RENEWER_PRINCIPAL =
526-
ConfigBuilder("spark.kubernetes.kerberos.rewnewer.principal")
520+
ConfigBuilder("spark.kubernetes.kerberos.renewer.principal")
527521
.doc("Specify the principal" +
528522
" you wish to renew and retrieve your Kerberos values with")
529523
.stringConf

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,11 @@ package object constants {
120120
private[spark] val SPARK_HADOOP_PREFIX = "spark.hadoop."
121121
private[spark] val HADOOP_SECURITY_AUTHENTICATION =
122122
SPARK_HADOOP_PREFIX + "hadoop.security.authentication"
123+
124+
// Kerberos Token-Refresh Server
125+
private[spark] val KERBEROS_REFRESH_LABEL_KEY = "refresh-hadoop-tokens"
126+
private[spark] val KERBEROS_REFRESH_LABEL_VALUE = "yes"
127+
123128
// Bootstrapping dependencies via a secret
124129
private[spark] val MOUNTED_SMALL_FILES_SECRET_MOUNT_PATH = "/etc/spark-submitted-files"
125130

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,12 @@ private[spark] class DriverConfigurationStepsOrchestrator(
120120
val hadoopConfigSteps =
121121
hadoopConfDir.map { conf =>
122122
val hadoopStepsOrchestrator =
123-
new HadoopStepsOrchestrator(namespace, hadoopConfigMapName, submissionSparkConf, conf)
123+
new HadoopStepsOrchestrator(
124+
kubernetesResourceNamePrefix,
125+
namespace,
126+
hadoopConfigMapName,
127+
submissionSparkConf,
128+
conf)
124129
val hadoopConfSteps = hadoopStepsOrchestrator.getHadoopSteps()
125130
Some(new HadoopConfigBootstrapStep(hadoopConfSteps, hadoopConfigMapName))}
126131
.getOrElse(Option.empty[DriverConfigurationStep])

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ package org.apache.spark.deploy.k8s.submit.submitsteps.hadoopsteps
1818

1919
import java.io.File
2020

21-
import org.apache.commons.io.FileUtils.readFileToString
21+
import com.google.common.base.Charsets
22+
import com.google.common.io.Files
2223

2324
import org.apache.spark.deploy.k8s.{HadoopConfBootstrap, PodWithMainContainer}
2425
import org.apache.spark.deploy.k8s.constants._
@@ -48,7 +49,7 @@ private[spark] class HadoopConfMounterStep(
4849
driverContainer = bootstrappedPodAndMainContainer.mainContainer,
4950
configMapProperties =
5051
hadoopConfigurationFiles.map(file =>
51-
(file.toPath.getFileName.toString, readFileToString(file))).toMap,
52+
(file.toPath.getFileName.toString, Files.toString(file, Charsets.UTF_8))).toMap,
5253
additionalDriverSparkConf = hadoopConfigSpec.additionalDriverSparkConf ++
5354
Map(HADOOP_CONF_DIR_LOC -> hadoopConfDir)
5455
)

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import org.apache.spark.internal.Logging
4646
* DriverSpec.
4747
*/
4848
private[spark] class HadoopKerberosKeytabResolverStep(
49+
kubernetesResourceNamePrefix: String,
4950
submissionSparkConf: SparkConf,
5051
maybePrincipal: Option[String],
5152
maybeKeytab: Option[File],
@@ -94,12 +95,13 @@ private[spark] class HadoopKerberosKeytabResolverStep(
9495
hadoopUGI.getTokenRenewalInterval(tokens, hadoopConf).getOrElse(Long.MaxValue)
9596
val currentTime: Long = hadoopUGI.getCurrentTime
9697
val initialTokenDataKeyName = s"$KERBEROS_SECRET_LABEL_PREFIX-$currentTime-$renewalInterval"
97-
val uniqueSecretName = s"$HADOOP_KERBEROS_SECRET_NAME.$currentTime"
98+
val uniqueSecretName =
99+
s"$kubernetesResourceNamePrefix-$HADOOP_KERBEROS_SECRET_NAME.$currentTime"
98100
val secretDT =
99101
new SecretBuilder()
100102
.withNewMetadata()
101103
.withName(uniqueSecretName)
102-
.withLabels(Map("refresh-hadoop-tokens" -> "yes").asJava)
104+
.withLabels(Map(KERBEROS_REFRESH_LABEL_KEY -> KERBEROS_REFRESH_LABEL_VALUE).asJava)
103105
.endMetadata()
104106
.addToData(initialTokenDataKeyName, Base64.encodeBase64String(data))
105107
.build()

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,11 @@ import org.apache.spark.internal.Logging
2727
* Returns the complete ordered list of steps required to configure the hadoop configurations.
2828
*/
2929
private[spark] class HadoopStepsOrchestrator(
30+
kubernetesResourceNamePrefix: String,
3031
namespace: String,
3132
hadoopConfigMapName: String,
3233
submissionSparkConf: SparkConf,
33-
hadoopConfDir: String) extends Logging{
34+
hadoopConfDir: String) extends Logging {
3435
private val isKerberosEnabled = submissionSparkConf.get(KUBERNETES_KERBEROS_SUPPORT)
3536
private val maybePrincipal = submissionSparkConf.get(KUBERNETES_KERBEROS_PRINCIPAL)
3637
private val maybeKeytab = submissionSparkConf.get(KUBERNETES_KERBEROS_KEYTAB)
@@ -81,6 +82,7 @@ private[spark] class HadoopStepsOrchestrator(
8182
existingSecretName,
8283
maybeExistingSecretItemKey.get))).getOrElse(Some(
8384
new HadoopKerberosKeytabResolverStep(
85+
kubernetesResourceNamePrefix,
8486
submissionSparkConf,
8587
maybePrincipal,
8688
maybeKeytab,

0 commit comments

Comments
 (0)