瀏覽代碼

[livy] Add option to disable impersonation

Erick Tryzelaar 10 年之前
父節點
當前提交
28de49e3ee

+ 3 - 0
apps/spark/java/conf/livy-defaults.conf.tmpl

@@ -15,3 +15,6 @@
 # Location to find the livy assembly. If not specified, livy will determine the
 # assembly from the local jarfile. If using `yarn` sessions, this may be on HDFS.
 # livy.yarn.jar = hdfs://localhost:8020/user/hue/share/lib/livy-assembly.jar
+
+# If livy should use proxy users when submitting a job.
+# livy.impersonation.enabled = true

+ 4 - 0
apps/spark/java/livy-core/src/main/scala/com/cloudera/hue/livy/LivyConf.scala

@@ -25,6 +25,7 @@ import scala.collection.JavaConverters._
 object LivyConf {
   val SESSION_FACTORY_KEY = "livy.server.session.factory"
   val SPARK_SUBMIT_KEY = "livy.server.spark-submit"
+  val IMPERSONATION_ENABLED_KEY = "livy.impersonation.enabled"
 
   sealed trait SessionKind
   case class Process() extends SessionKind
@@ -84,6 +85,9 @@ class LivyConf(loadDefaults: Boolean) {
   /** Get a parameter as an Option */
   def getOption(key: String): Option[String] = Option(settings.get(key))
 
+  /** Get a parameter as a Boolean */
+  def getBoolean(key: String, default: Boolean) = getOption(key).map(_.toBoolean).getOrElse(default)
+
   /** Get a parameter as an Int */
   def getInt(key: String, default: Int) = getOption(key).map(_.toInt).getOrElse(default)
 

+ 5 - 1
apps/spark/java/livy-core/src/main/scala/com/cloudera/hue/livy/spark/SparkSubmitProcessBuilder.scala

@@ -256,7 +256,11 @@ class SparkSubmitProcessBuilder(livyConf: LivyConf) extends Logging {
     addList("--driver-class-path", _driverClassPath)
     addOpt("--driver-cores", _driverCores)
     addOpt("--executor-memory", _executorMemory)
-    addOpt("--proxy-user", _proxyUser)
+
+    if (livyConf.getBoolean(LivyConf.IMPERSONATION_ENABLED_KEY, true)) {
+      addOpt("--proxy-user", _proxyUser)
+    }
+
     addOpt("--driver-cores", _driverCores)
     addOpt("--executor-cores", _executorCores)
     addOpt("--num-executors", _numExecutors)

+ 6 - 0
apps/spark/src/spark/conf.py

@@ -74,6 +74,12 @@ LIVY_YARN_JAR = Config(
   help=_t("Path to livy-assembly.jar inside HDFS"),
   private=True)
 
+LIVY_IMPERSONATION_ENABLED = Config(
+  key="livy_impersonation_enabled",
+  help=_t("Use impersonation when submitting livy jobs"),
+  default=True,
+  type=coerce_bool)
+
 START_LIVY_SERVER = Config(
   key="start_livy_server",
   help=_t("Experimental option to launch livy"),

+ 5 - 0
apps/spark/src/spark/management/commands/livy_server.py

@@ -69,6 +69,11 @@ class Command(NoArgsCommand):
     if livy_yarn_jar:
       args.append("-Dlivy.yarn.jar=" + livy_yarn_jar)
 
+    if spark.conf.LIVY_IMPERSONATION_ENABLED.get():
+      args.append("-Dlivy.impersonation.enabled=true")
+    else:
+      args.append("-Dlivy.impersonation.enabled=false")
+
     args.append("com.cloudera.hue.livy.server.Main")
 
     LOG.info("Executing %r (%r) (%r)" % (args[0], args, env))

+ 3 - 0
desktop/conf.dist/hue.ini

@@ -1055,6 +1055,9 @@
   # Configure livy to start with 'process', 'thread', or 'yarn' workers.
   ## livy_server_session_kind=process
 
+  # If livy should use proxy users when submitting a job.
+  ## livy_impersonation_enabled=true
+
   # List of available types of snippets
   ## languages='[{"name": "Scala Shell", "type": "scala"},{"name": "PySpark Shell", "type": "python"},{"name": "Jar", "type": "Jar"},{"name": "Python", "type": "py"},{"name": "Impala SQL", "type": "impala"},{"name": "Hive SQL", "type": "hive"},{"name": "Text", "type": "text"}]'
 

+ 3 - 0
desktop/conf/pseudo-distributed.ini.tmpl

@@ -1062,6 +1062,9 @@
   # Configure livy to start with 'process', 'thread', or 'yarn' workers.
   ## livy_server_session_kind=process
 
+  # If livy should use proxy users when submitting a job.
+  ## livy_impersonation_enabled=true
+
   # List of available types of snippets
   ## languages='[{"name": "Scala Shell", "type": "scala"},{"name": "PySpark Shell", "type": "python"},{"name": "Jar", "type": "Jar"},{"name": "Python", "type": "py"},{"name": "Impala SQL", "type": "impala"},{"name": "Hive SQL", "type": "hive"},{"name": "Text", "type": "text"}]'