aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcelo Vanzin <vanzin@cloudera.com>2015-08-19 10:51:59 -0700
committerMarcelo Vanzin <vanzin@cloudera.com>2015-08-19 10:51:59 -0700
commit5fd53c64bb01de74ae57a7068de85b34adc856cf (patch)
treedfa8b2bc81c4fbf35258c85dbe1c23c3fcea0edd
parent2fcb9cb9552dac1d78dcca5d4d5032b4fa6c985c (diff)
downloadspark-5fd53c64bb01de74ae57a7068de85b34adc856cf.tar.gz
spark-5fd53c64bb01de74ae57a7068de85b34adc856cf.tar.bz2
spark-5fd53c64bb01de74ae57a7068de85b34adc856cf.zip
[SPARK-9833] [YARN] Add options to disable delegation token retrieval.
This allows skipping the code that tries to talk to Hive and HBase to fetch delegation tokens, in case that somehow conflicts with the application being run. Author: Marcelo Vanzin <vanzin@cloudera.com> Closes #8134 from vanzin/SPARK-9833.
-rw-r--r--docs/running-on-yarn.md12
-rw-r--r--yarn/src/main/scala/org/apache/spark/deploy/yarn/Client.scala27
2 files changed, 33 insertions, 6 deletions
diff --git a/docs/running-on-yarn.md b/docs/running-on-yarn.md
index 8ac26e98da..5159ef9e33 100644
--- a/docs/running-on-yarn.md
+++ b/docs/running-on-yarn.md
@@ -369,6 +369,18 @@ If you need a reference to the proper location to put log files in the YARN so t
See <code>spark.yarn.config.gatewayPath</code>.
</td>
</tr>
+<tr>
+ <td><code>spark.yarn.security.tokens.${service}.enabled</code></td>
+ <td>true</td>
+ <td>
+ Controls whether to retrieve delegation tokens for non-HDFS services when security is enabled.
+ By default, delegation tokens for all supported services are retrieved when those services are
+ configured, but it's possible to disable that behavior if it somehow conflicts with the
+ application being run.
+ <p/>
+ Currently supported services are: hive, hbase
+ </td>
+</tr>
</table>
# Important notes
diff --git a/yarn/src/main/scala/org/apache/spark/deploy/yarn/Client.scala b/yarn/src/main/scala/org/apache/spark/deploy/yarn/Client.scala
index 262c6a8d63..bff585b46c 100644
--- a/yarn/src/main/scala/org/apache/spark/deploy/yarn/Client.scala
+++ b/yarn/src/main/scala/org/apache/spark/deploy/yarn/Client.scala
@@ -285,8 +285,8 @@ private[spark] class Client(
// multiple times, YARN will fail to launch containers for the app with an internal
// error.
val distributedUris = new HashSet[String]
- obtainTokenForHiveMetastore(hadoopConf, credentials)
- obtainTokenForHBase(hadoopConf, credentials)
+ obtainTokenForHiveMetastore(sparkConf, hadoopConf, credentials)
+ obtainTokenForHBase(sparkConf, hadoopConf, credentials)
val replication = sparkConf.getInt("spark.yarn.submit.file.replication",
fs.getDefaultReplication(dst)).toShort
@@ -1239,8 +1239,11 @@ object Client extends Logging {
/**
* Obtains token for the Hive metastore and adds them to the credentials.
*/
- private def obtainTokenForHiveMetastore(conf: Configuration, credentials: Credentials) {
- if (UserGroupInformation.isSecurityEnabled) {
+ private def obtainTokenForHiveMetastore(
+ sparkConf: SparkConf,
+ conf: Configuration,
+ credentials: Credentials) {
+ if (shouldGetTokens(sparkConf, "hive") && UserGroupInformation.isSecurityEnabled) {
val mirror = universe.runtimeMirror(getClass.getClassLoader)
try {
@@ -1297,8 +1300,11 @@ object Client extends Logging {
/**
* Obtain security token for HBase.
*/
- def obtainTokenForHBase(conf: Configuration, credentials: Credentials): Unit = {
- if (UserGroupInformation.isSecurityEnabled) {
+ def obtainTokenForHBase(
+ sparkConf: SparkConf,
+ conf: Configuration,
+ credentials: Credentials): Unit = {
+ if (shouldGetTokens(sparkConf, "hbase") && UserGroupInformation.isSecurityEnabled) {
val mirror = universe.runtimeMirror(getClass.getClassLoader)
try {
@@ -1394,4 +1400,13 @@ object Client extends Logging {
components.mkString(Path.SEPARATOR)
}
+ /**
+ * Return whether delegation tokens should be retrieved for the given service when security is
+ * enabled. By default, tokens are retrieved, but that behavior can be changed by setting
+ * a service-specific configuration.
+ */
+ def shouldGetTokens(conf: SparkConf, service: String): Boolean = {
+ conf.getBoolean(s"spark.yarn.security.tokens.${service}.enabled", true)
+ }
+
}