Skip to content

Commit 7bff922

Browse files
turboFeipan3793
andcommitted
[KYUUBI #7055] Support to filter out server only configs with prefixes
### Why are the changes needed? To filter out server only configs with prefixes. For some kyuubi configs, there is no related defined ConfigEntry, and we can not filter out them and have to populate them to engien end. For example: ``` kyuubi.kubernetes.28.master.address=k8s://master kyuubi.backend.server.event.kafka.broker=localhost:9092 kyuubi.metadata.store.jdbc.driver=com.mysql.cj.jdbc.Driver kyuubi.metadata.store.jdbc.datasource.maximumPoolSize=600 kyuubi.metadata.store.jdbc.datasource.minimumIdle=100 kyuubi.metadata.store.jdbc.datasource.idleTimeout=60000 ``` This PR supports to exclude them by setting: ``` kyuubi.config.server.only.prefixes=kyuubi.backend.server.event.kafka.,kyuubi.metadata.store.jdbc.datasource.,kyuubi.kubernetes.28. ``` ### How was this patch tested? UT ### Was this patch authored or co-authored using generative AI tooling? No. Closes #7055 from turboFei/server_only_configs. Closes #7055 6c804ff [Cheng Pan] Update kyuubi-common/src/main/scala/org/apache/kyuubi/config/KyuubiConf.scala bd391a6 [Wang, Fei] exclude Lead-authored-by: Fei Wang <fwang12@ebay.com> Co-authored-by: Cheng Pan <pan3793@gmail.com> Co-authored-by: Wang, Fei <fwang12@ebay.com> Signed-off-by: Wang, Fei <fwang12@ebay.com> (cherry picked from commit 2ec8b46) Signed-off-by: Wang, Fei <fwang12@ebay.com>
1 parent 8cb8187 commit 7bff922

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

kyuubi-common/src/main/scala/org/apache/kyuubi/config/KyuubiConf.scala

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,16 @@ case class KyuubiConf(loadSysDefault: Boolean = true) extends Logging {
193193
cloned
194194
}
195195

196+
private lazy val serverOnlyPrefixes = get(KyuubiConf.SERVER_ONLY_PREFIXES)
197+
private lazy val serverOnlyPrefixConfigKeys = settings.keys().asScala
198+
// for ConfigEntry, respect the serverOnly flag and exclude it here
199+
.filter(key => getConfigEntry(key) == null)
200+
.filter { key =>
201+
serverOnlyPrefixes.exists { prefix =>
202+
key.startsWith(prefix)
203+
}
204+
}
205+
196206
def getUserDefaults(user: String): KyuubiConf = {
197207
val cloned = KyuubiConf(false)
198208

@@ -205,6 +215,7 @@ case class KyuubiConf(loadSysDefault: Boolean = true) extends Logging {
205215
cloned.set(k, v)
206216
}
207217
serverOnlyConfEntries.foreach(cloned.unset)
218+
serverOnlyPrefixConfigKeys.foreach(cloned.unset)
208219
cloned
209220
}
210221

@@ -2884,6 +2895,22 @@ object KyuubiConf {
28842895
.stringConf
28852896
.createWithDefault("ENGINE")
28862897

2898+
val SERVER_ONLY_PREFIXES: ConfigEntry[Set[String]] =
2899+
buildConf("kyuubi.config.server.only.prefixes")
2900+
.internal
2901+
.serverOnly
2902+
.doc("A comma-separated list of prefixes for server-only configs. It's used to filter out " +
2903+
"the server-only configs to prevent passing them to the engine end. Note that, " +
2904+
"it only take affects for the configs that is not defined as a Kyuubi ConfigEntry. " +
2905+
"For example, you can exclude `kyuubi.kubernetes.28.master.address=k8s://master` by " +
2906+
"setting it to `kyuubi.kubernetes.28.`.")
2907+
.version("1.11.0")
2908+
.stringConf
2909+
.toSet()
2910+
.createWithDefault(Set(
2911+
"kyuubi.backend.server.event.kafka.",
2912+
"kyuubi.metadata.store.jdbc.datasource."))
2913+
28872914
val ENGINE_SPARK_SHOW_PROGRESS: ConfigEntry[Boolean] =
28882915
buildConf("kyuubi.session.engine.spark.showProgress")
28892916
.doc("When true, show the progress bar in the Spark's engine log.")

kyuubi-common/src/test/scala/org/apache/kyuubi/config/KyuubiConfSuite.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,4 +230,10 @@ class KyuubiConfSuite extends KyuubiFunSuite {
230230
assert(kubernetesConf2.get(KyuubiConf.KUBERNETES_AUTHENTICATE_OAUTH_TOKEN_FILE) ==
231231
Some("/var/run/secrets/kubernetes.io/token.ns2"))
232232
}
233+
234+
test("KYUUBI #7053 - Support to exclude server only configs with prefixes") {
235+
val kyuubiConf = KyuubiConf(false)
236+
kyuubiConf.set("kyuubi.backend.server.event.kafka.broker", "localhost:9092")
237+
assert(kyuubiConf.getUserDefaults("kyuubi").getAll.size == 0)
238+
}
233239
}

0 commit comments

Comments
 (0)