pan3793 commented on code in PR #7710:
URL: https://github.com/apache/kyuubi/pull/7710#discussion_r3917374728
##########
kyuubi-server/src/main/scala/org/apache/kyuubi/engine/KubernetesApplicationOperation.scala:
##########
@@ -217,14 +217,27 @@ class KubernetesApplicationOperation extends
ApplicationOperation with Logging {
}
private[kyuubi] def getKubernetesClientInitializeInfo(
- kyuubiConf: KyuubiConf): Seq[KubernetesInfo] = {
- kyuubiConf.get(KyuubiConf.KUBERNETES_CLIENT_INITIALIZE_LIST).map { init =>
- val (context, namespace) = init.split(":") match {
- case Array(ctx, ns) => (Some(ctx).filterNot(_.isEmpty),
Some(ns).filterNot(_.isEmpty))
- case Array(ctx) => (Some(ctx).filterNot(_.isEmpty), None)
- case _ => (None, None)
+ kyuubiConf: KyuubiConf,
+ environment: Map[String, String] = sys.env): Seq[KubernetesInfo] = {
+ val configuredInitializeInfo =
+ kyuubiConf.get(KyuubiConf.KUBERNETES_CLIENT_INITIALIZE_LIST).map { init
=>
+ val (context, namespace) = init.split(":") match {
+ case Array(ctx, ns) => (Some(ctx).filterNot(_.isEmpty),
Some(ns).filterNot(_.isEmpty))
+ case Array(ctx) => (Some(ctx).filterNot(_.isEmpty), None)
+ case _ => (None, None)
+ }
+ KubernetesInfo(context, namespace)
}
- KubernetesInfo(context, namespace)
+ if (configuredInitializeInfo.nonEmpty) {
+ configuredInitializeInfo
+ } else if (environment.get(KUBERNETES_SERVICE_HOST).exists(_.nonEmpty) &&
Review Comment:
One more thought: `kyuubi-common` already has `Utils.isOnK8s`, but it checks
`/var/run/secrets/kubernetes.io`, which under-detects pods running with
`automountServiceAccountToken: false`. The env-var check you use here matches
client-go's `rest.InClusterConfig()` semantics (kubelet always injects
`KUBERNETES_SERVICE_HOST`/`PORT`, even with `enableServiceLinks: false`), so it
is the more authoritative signal.
Could you fix `Utils.isOnK8s` to use the env-var check and reuse it here?
For testability, add an env parameter:
```scala
def isOnK8s(env: Map[String, String] = sys.env): Boolean =
env.get("KUBERNETES_SERVICE_HOST").exists(_.nonEmpty) &&
env.get("KUBERNETES_SERVICE_PORT").exists(_.nonEmpty)
```
This also makes the existing caller in `SparkSQLEngine` (prefer-IP
registration, KYUUBI #3597 (1.7.0)) behave correctly when automount is disabled.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]