-
Notifications
You must be signed in to change notification settings - Fork 919
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[KYUUBI #6003] Allow disabling user impersonation on launching engine #6003
Changes from 6 commits
e982e23
a1563e1
9273b94
033a322
8711c22
add20fd
c4002fe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2087,20 +2087,33 @@ object KyuubiConf { | |
.version("1.5.0") | ||
.fallbackConf(ENGINE_CONNECTION_URL_USE_HOSTNAME) | ||
|
||
val ENGINE_DO_AS_ENABLED: ConfigEntry[Boolean] = | ||
buildConf("kyuubi.engine.doAs.enabled") | ||
.doc("Whether to enable user impersonation on launching engine. When enabled, " + | ||
"for engines which supports user impersonation, e.g. SPARK, depends on the " + | ||
s"`kyuubi.engine.share.level`, different users will be used to launch the engine. " + | ||
"Otherwise, Kyuubi Server's user will always be used to launch the engine.") | ||
.version("1.9.0") | ||
.booleanConf | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's add this to 1.9.0 instead of a bugfix version There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay |
||
.createWithDefault(true) | ||
|
||
val ENGINE_SHARE_LEVEL: ConfigEntry[String] = buildConf("kyuubi.engine.share.level") | ||
.doc("Engines will be shared in different levels, available configs are: <ul>" + | ||
" <li>CONNECTION: engine will not be shared but only used by the current client" + | ||
" connection</li>" + | ||
" <li>USER: engine will be shared by all sessions created by a unique username," + | ||
s" see also ${ENGINE_SHARE_LEVEL_SUBDOMAIN.key}</li>" + | ||
" <li>CONNECTION: the engine will not be shared but only used by the current client" + | ||
" connection, and the engine will be launched by session user.</li>" + | ||
" <li>USER: the engine will be shared by all sessions created by a unique username," + | ||
s" and the engine will be launched by session user.</li>" + | ||
" <li>GROUP: the engine will be shared by all sessions created" + | ||
" by all users belong to the same primary group name." + | ||
" The engine will be launched by the group name as the effective" + | ||
" The engine will be launched by the primary group name as the effective" + | ||
" username, so here the group name is in value of special user who is able to visit the" + | ||
" computing resources/data of the team. It follows the" + | ||
" [Hadoop GroupsMapping](https://reurl.cc/xE61Y5) to map user to a primary group. If the" + | ||
" primary group is not found, it fallback to the USER level." + | ||
" <li>SERVER: the App will be shared by Kyuubi servers</li></ul>") | ||
" <li>SERVER: the engine will be shared by Kyuubi servers, and the engine will be launched" + | ||
" by Server's user.</li>" + | ||
" </ul>" + | ||
s" See also `${ENGINE_SHARE_LEVEL_SUBDOMAIN.key}` and `${ENGINE_DO_AS_ENABLED.key}`.") | ||
.version("1.2.0") | ||
.fallbackConf(LEGACY_ENGINE_SHARE_LEVEL) | ||
|
||
|
@@ -2115,8 +2128,8 @@ object KyuubiConf { | |
" all the capacity of the Trino.</li>" + | ||
" <li>HIVE_SQL: specify this engine type will launch a Hive engine which can provide" + | ||
" all the capacity of the Hive Server2.</li>" + | ||
" <li>JDBC: specify this engine type will launch a JDBC engine which can forward " + | ||
" queries to the database system through the certain JDBC driver, " + | ||
" <li>JDBC: specify this engine type will launch a JDBC engine which can forward" + | ||
" queries to the database system through the certain JDBC driver," + | ||
" for now, it supports Doris, MySQL, Phoenix, PostgreSQL and StarRocks.</li>" + | ||
" <li>CHAT: specify this engine type will launch a Chat engine.</li>" + | ||
"</ul>") | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,21 +34,23 @@ import org.apache.kyuubi.engine.{ApplicationManagerInfo, KyuubiApplicationManage | |
import org.apache.kyuubi.engine.KubernetesApplicationOperation.{KUBERNETES_SERVICE_HOST, KUBERNETES_SERVICE_PORT} | ||
import org.apache.kyuubi.engine.ProcBuilder.KYUUBI_ENGINE_LOG_PATH_KEY | ||
import org.apache.kyuubi.ha.HighAvailabilityConf | ||
import org.apache.kyuubi.ha.HighAvailabilityConf.HA_ZK_ENGINE_AUTH_TYPE | ||
import org.apache.kyuubi.ha.client.AuthTypes | ||
import org.apache.kyuubi.operation.log.OperationLog | ||
import org.apache.kyuubi.util.{KubernetesUtils, Validator} | ||
import org.apache.kyuubi.util.command.CommandLineUtils._ | ||
|
||
class SparkProcessBuilder( | ||
override val proxyUser: String, | ||
override val doAsEnabled: Boolean, | ||
override val conf: KyuubiConf, | ||
val engineRefId: String, | ||
val extraEngineLog: Option[OperationLog] = None) | ||
extends ProcBuilder with Logging { | ||
|
||
@VisibleForTesting | ||
def this(proxyUser: String, conf: KyuubiConf) { | ||
this(proxyUser, conf, "") | ||
def this(proxyUser: String, doAsEnabled: Boolean, conf: KyuubiConf) { | ||
this(proxyUser, doAsEnabled, conf, "") | ||
} | ||
|
||
import SparkProcessBuilder._ | ||
|
@@ -135,14 +137,12 @@ class SparkProcessBuilder( | |
var allConf = conf.getAll | ||
|
||
// if enable sasl kerberos authentication for zookeeper, need to upload the server keytab file | ||
if (AuthTypes.withName(conf.get(HighAvailabilityConf.HA_ZK_ENGINE_AUTH_TYPE)) | ||
== AuthTypes.KERBEROS) { | ||
if (AuthTypes.withName(conf.get(HA_ZK_ENGINE_AUTH_TYPE)) == AuthTypes.KERBEROS) { | ||
allConf = allConf ++ zkAuthKeytabFileConf(allConf) | ||
} | ||
// pass spark engine log path to spark conf | ||
(allConf ++ engineLogPathConf ++ extraYarnConf(allConf) ++ appendPodNameConf(allConf)).foreach { | ||
case (k, v) => | ||
buffer ++= confKeyValue(convertConfigKey(k), v) | ||
case (k, v) => buffer ++= confKeyValue(convertConfigKey(k), v) | ||
} | ||
|
||
setupKerberos(buffer) | ||
|
@@ -157,10 +157,12 @@ class SparkProcessBuilder( | |
protected def setupKerberos(buffer: mutable.Buffer[String]): Unit = { | ||
// if the keytab is specified, PROXY_USER is not supported | ||
tryKeytab() match { | ||
case None => | ||
case None if doAsEnabled => | ||
setSparkUserName(proxyUser, buffer) | ||
buffer += PROXY_USER | ||
buffer += proxyUser | ||
case None => // doAs disabled | ||
setSparkUserName(Utils.currentUser, buffer) | ||
case Some(name) => | ||
setSparkUserName(name, buffer) | ||
} | ||
|
@@ -175,11 +177,16 @@ class SparkProcessBuilder( | |
try { | ||
val ugi = UserGroupInformation | ||
.loginUserFromKeytabAndReturnUGI(principal.get, keytab.get) | ||
if (ugi.getShortUserName != proxyUser) { | ||
if (doAsEnabled && ugi.getShortUserName != proxyUser) { | ||
warn(s"The session proxy user: $proxyUser is not same with " + | ||
s"spark principal: ${ugi.getShortUserName}, so we can't support use keytab. " + | ||
s"Fallback to use proxy user.") | ||
None | ||
} else if (!doAsEnabled && ugi.getShortUserName != Utils.currentUser) { | ||
warn(s"The server's user: ${Utils.currentUser} is not same with " + | ||
wForget marked this conversation as resolved.
Show resolved
Hide resolved
|
||
s"spark principal: ${ugi.getShortUserName}, skip to use keytab. " + | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be |
||
"Fallback to use server's user.") | ||
None | ||
} else { | ||
Some(ugi.getShortUserName) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @yaooqinn @zhouyifan279 WDYT of this configuration name? My another candidate is
kyuubi.engine.impersonation.enabled
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 for kyuubi.engine.doAs.enabled.