Skip to content

Commit 89d3985

Browse files
ifilonenkodaspalrahul
authored andcommitted
[SPARK-25372][YARN][K8S] Deprecate and generalize keytab / principal config
## What changes were proposed in this pull request? SparkSubmit already logs in the user if a keytab is provided, the only issue is that it uses the existing configs which have "yarn" in their name. As such, the configs were changed to: `spark.kerberos.keytab` and `spark.kerberos.principal`. ## How was this patch tested? Will be tested with K8S tests, but needs to be tested with Yarn - [x] K8S Secure HDFS tests - [x] Yarn Secure HDFS tests vanzin Closes apache#22362 from ifilonenko/SPARK-25372. Authored-by: Ilan Filonenko <if56@cornell.edu> Signed-off-by: Marcelo Vanzin <vanzin@cloudera.com>
1 parent bbd38dd commit 89d3985

9 files changed

Lines changed: 29 additions & 13 deletions

File tree

R/pkg/R/sparkR.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,8 @@ sparkConfToSubmitOps[["spark.driver.extraLibraryPath"]] <- "--driver-library-pat
626626
sparkConfToSubmitOps[["spark.master"]] <- "--master"
627627
sparkConfToSubmitOps[["spark.yarn.keytab"]] <- "--keytab"
628628
sparkConfToSubmitOps[["spark.yarn.principal"]] <- "--principal"
629+
sparkConfToSubmitOps[["spark.kerberos.keytab"]] <- "--keytab"
630+
sparkConfToSubmitOps[["spark.kerberos.principal"]] <- "--principal"
629631

630632

631633
# Utility function that returns Spark Submit arguments as a string

R/pkg/vignettes/sparkr-vignettes.Rmd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@ Property Name | Property group | spark-submit equivalent
157157
`spark.driver.extraClassPath` | Runtime Environment | `--driver-class-path`
158158
`spark.driver.extraJavaOptions` | Runtime Environment | `--driver-java-options`
159159
`spark.driver.extraLibraryPath` | Runtime Environment | `--driver-library-path`
160-
`spark.yarn.keytab` | Application Properties | `--keytab`
161-
`spark.yarn.principal` | Application Properties | `--principal`
160+
`spark.kerberos.keytab` | Application Properties | `--keytab`
161+
`spark.kerberos.principal` | Application Properties | `--principal`
162162

163163
**For Windows users**: Due to different file prefixes across operating systems, to avoid the issue of potential wrong prefix, a current workaround is to specify `spark.sql.warehouse.dir` when starting the `SparkSession`.
164164

core/src/main/scala/org/apache/spark/SparkConf.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,11 @@ private[spark] object SparkConf extends Logging {
726726
DRIVER_MEMORY_OVERHEAD.key -> Seq(
727727
AlternateConfig("spark.yarn.driver.memoryOverhead", "2.3")),
728728
EXECUTOR_MEMORY_OVERHEAD.key -> Seq(
729-
AlternateConfig("spark.yarn.executor.memoryOverhead", "2.3"))
729+
AlternateConfig("spark.yarn.executor.memoryOverhead", "2.3")),
730+
KEYTAB.key -> Seq(
731+
AlternateConfig("spark.yarn.keytab", "2.5")),
732+
PRINCIPAL.key -> Seq(
733+
AlternateConfig("spark.yarn.principal", "2.5"))
730734
)
731735

732736
/**

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,10 @@ private[spark] class SparkSubmit extends Logging {
520520
confKey = "spark.driver.extraJavaOptions"),
521521
OptionAssigner(args.driverExtraLibraryPath, ALL_CLUSTER_MGRS, ALL_DEPLOY_MODES,
522522
confKey = "spark.driver.extraLibraryPath"),
523+
OptionAssigner(args.principal, ALL_CLUSTER_MGRS, ALL_DEPLOY_MODES,
524+
confKey = PRINCIPAL.key),
525+
OptionAssigner(args.keytab, ALL_CLUSTER_MGRS, ALL_DEPLOY_MODES,
526+
confKey = KEYTAB.key),
523527

524528
// Propagate attributes for dependency resolution at the driver side
525529
OptionAssigner(args.packages, STANDALONE | MESOS, CLUSTER, confKey = "spark.jars.packages"),
@@ -537,8 +541,6 @@ private[spark] class SparkSubmit extends Logging {
537541
OptionAssigner(args.jars, YARN, ALL_DEPLOY_MODES, confKey = "spark.yarn.dist.jars"),
538542
OptionAssigner(args.files, YARN, ALL_DEPLOY_MODES, confKey = "spark.yarn.dist.files"),
539543
OptionAssigner(args.archives, YARN, ALL_DEPLOY_MODES, confKey = "spark.yarn.dist.archives"),
540-
OptionAssigner(args.principal, YARN, ALL_DEPLOY_MODES, confKey = "spark.yarn.principal"),
541-
OptionAssigner(args.keytab, YARN, ALL_DEPLOY_MODES, confKey = "spark.yarn.keytab"),
542544

543545
// Other options
544546
OptionAssigner(args.executorCores, STANDALONE | YARN | KUBERNETES, ALL_DEPLOY_MODES,

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,14 @@ private[deploy] class SparkSubmitArguments(args: Seq[String], env: Map[String, S
199199
numExecutors = Option(numExecutors)
200200
.getOrElse(sparkProperties.get("spark.executor.instances").orNull)
201201
queue = Option(queue).orElse(sparkProperties.get("spark.yarn.queue")).orNull
202-
keytab = Option(keytab).orElse(sparkProperties.get("spark.yarn.keytab")).orNull
203-
principal = Option(principal).orElse(sparkProperties.get("spark.yarn.principal")).orNull
202+
keytab = Option(keytab)
203+
.orElse(sparkProperties.get("spark.kerberos.keytab"))
204+
.orElse(sparkProperties.get("spark.yarn.keytab"))
205+
.orNull
206+
principal = Option(principal)
207+
.orElse(sparkProperties.get("spark.kerberos.principal"))
208+
.orElse(sparkProperties.get("spark.yarn.principal"))
209+
.orNull
204210
dynamicAllocationEnabled =
205211
sparkProperties.get("spark.dynamicAllocation.enabled").exists("true".equalsIgnoreCase)
206212

core/src/main/scala/org/apache/spark/internal/config/package.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,11 @@ package object config {
152152
private[spark] val SHUFFLE_SERVICE_PORT =
153153
ConfigBuilder("spark.shuffle.service.port").intConf.createWithDefault(7337)
154154

155-
private[spark] val KEYTAB = ConfigBuilder("spark.yarn.keytab")
155+
private[spark] val KEYTAB = ConfigBuilder("spark.kerberos.keytab")
156156
.doc("Location of user's keytab.")
157157
.stringConf.createOptional
158158

159-
private[spark] val PRINCIPAL = ConfigBuilder("spark.yarn.principal")
159+
private[spark] val PRINCIPAL = ConfigBuilder("spark.kerberos.principal")
160160
.doc("Name of the Kerberos principal.")
161161
.stringConf.createOptional
162162

docs/running-on-yarn.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ providers can be disabled individually by setting `spark.security.credentials.{s
465465
<table class="table">
466466
<tr><th>Property Name</th><th>Default</th><th>Meaning</th></tr>
467467
<tr>
468-
<td><code>spark.yarn.keytab</code></td>
468+
<td><code>spark.kerberos.keytab</code></td>
469469
<td>(none)</td>
470470
<td>
471471
The full path to the file that contains the keytab for the principal specified above. This keytab
@@ -477,7 +477,7 @@ providers can be disabled individually by setting `spark.security.credentials.{s
477477
</td>
478478
</tr>
479479
<tr>
480-
<td><code>spark.yarn.principal</code></td>
480+
<td><code>spark.kerberos.principal</code></td>
481481
<td>(none)</td>
482482
<td>
483483
Principal to be used to login to KDC, while running on secure clusters. Equivalent to the

docs/sparkr.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,12 @@ The following Spark driver properties can be set in `sparkConfig` with `sparkR.s
7070
<td><code>--master</code></td>
7171
</tr>
7272
<tr>
73-
<td><code>spark.yarn.keytab</code></td>
73+
<td><code>spark.kerberos.keytab</code></td>
7474
<td>Application Properties</td>
7575
<td><code>--keytab</code></td>
7676
</tr>
7777
<tr>
78-
<td><code>spark.yarn.principal</code></td>
78+
<td><code>spark.kerberos.principal</code></td>
7979
<td>Application Properties</td>
8080
<td><code>--principal</code></td>
8181
</tr>

streaming/src/main/scala/org/apache/spark/streaming/Checkpoint.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ class Checkpoint(ssc: StreamingContext, val checkpointTime: Time)
5959
"spark.yarn.jars",
6060
"spark.yarn.keytab",
6161
"spark.yarn.principal",
62+
"spark.kerberos.keytab",
63+
"spark.kerberos.principal",
6264
"spark.ui.filters",
6365
"spark.mesos.driver.frameworkId")
6466

0 commit comments

Comments
 (0)