Skip to content

Commit 16add92

Browse files
wForgetyaooqinn
authored andcommitted
[KYUUBI #1522] Pass the client ip to engine
<!-- Thanks for sending a pull request! Here are some tips for you: 1. If this is your first time, please read our contributor guidelines: https://kyuubi.readthedocs.io/en/latest/community/contributions.html 2. If the PR is related to an issue in https://github.com/apache/incubator-kyuubi/issues, add '[KYUUBI #XXXX]' in your PR title, e.g., '[KYUUBI #XXXX] Your PR title ...'. 3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][KYUUBI #XXXX] Your PR title ...'. --> ### _Why are the changes needed?_ <!-- Please clarify why the changes are needed. For instance, 1. If you add a feature, you can talk about the use case of it. 2. If you fix a bug, you can clarify why it is a bug. --> Pass the client ip to engine. For details: #1522 ### _How was this patch tested?_ - [ ] Add some test cases that check the changes thoroughly including negative and positive cases if possible - [ ] Add screenshots for manual tests if appropriate - [X] [Run test](https://kyuubi.readthedocs.io/en/latest/develop_tools/testing.html#running-tests) locally before make a pull request Closes #1524 from wForget/KYUUBI-1522. Closes #1522 c9d54ed [Wang Zhen] fix word error a16d914 [Wang Zhen] [KYUUBI-1522] Pass the client ip to engine Authored-by: Wang Zhen <wangzhen07@qiyi.com> Signed-off-by: Kent Yao <yao@apache.org>
1 parent 078edcd commit 16add92

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/kyuubi/engine/spark/session/SparkSQLSessionManager.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ class SparkSQLSessionManager private (name: String, spark: SparkSession)
5757
password: String,
5858
ipAddress: String,
5959
conf: Map[String, String]): SessionHandle = {
60-
info(s"Opening session for $user@$ipAddress")
60+
val clientIp = conf.getOrElse(CLIENT_IP_KEY, ipAddress)
61+
info(s"Opening session for $user@$clientIp")
6162
val sparkSession =
6263
try {
6364
if (singleSparkSession) {
@@ -78,7 +79,7 @@ class SparkSQLSessionManager private (name: String, spark: SparkSession)
7879
protocol,
7980
user,
8081
password,
81-
ipAddress,
82+
clientIp,
8283
conf,
8384
this,
8485
sparkSession)

kyuubi-common/src/main/scala/org/apache/kyuubi/session/package.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,6 @@ package object session {
2727
val METACONF_PREFIX = "metaconf:"
2828

2929
val SPARK_PREFIX = "spark."
30+
31+
val CLIENT_IP_KEY = "kyuubi.client.ip"
3032
}

kyuubi-server/src/main/scala/org/apache/kyuubi/session/KyuubiSessionManager.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,14 @@ class KyuubiSessionManager private (name: String) extends SessionManager(name) {
5050
conf: Map[String, String]): SessionHandle = {
5151

5252
val username = Option(user).filter(_.nonEmpty).getOrElse("anonymous")
53-
53+
// inject client ip into session conf
54+
val newConf = conf + (CLIENT_IP_KEY -> ipAddress)
5455
val sessionImpl = new KyuubiSessionImpl(
5556
protocol,
5657
username,
5758
password,
5859
ipAddress,
59-
conf,
60+
newConf,
6061
this,
6162
this.getConf.getUserDefaults(user))
6263
try {

0 commit comments

Comments
 (0)