Skip to content

Commit bd391a6

Browse files
committed
exclude
1 parent 127c736 commit bd391a6

2 files changed

Lines changed: 33 additions & 0 deletions

File tree

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

@@ -2843,6 +2854,22 @@ object KyuubiConf {
28432854
.stringConf
28442855
.createWithDefault("ENGINE")
28452856

2857+
val SERVER_ONLY_PREFIXES: ConfigEntry[Set[String]] =
2858+
buildConf("kyuubi.config.server.only.prefixes")
2859+
.internal
2860+
.serverOnly
2861+
.doc("A comma-separated list of prefixes for server-only configs. It's used to filter out " +
2862+
"the server-only configs to prevent passing them to the engine end. Note that, " +
2863+
"it only take affects for the configs that is not defined as a Kyuubi ConfigEntry. " +
2864+
"For example, you can exclude `kyuubi.kubernetes.28.master.address=k8s://master` by" +
2865+
" setting it to `kyuubi.kubernetes.28.`.")
2866+
.version("1.11.0")
2867+
.stringConf
2868+
.toSet()
2869+
.createWithDefault(Set(
2870+
"kyuubi.backend.server.event.kafka.",
2871+
"kyuubi.metadata.store.jdbc.datasource."))
2872+
28462873
val ENGINE_SPARK_SHOW_PROGRESS: ConfigEntry[Boolean] =
28472874
buildConf("kyuubi.session.engine.spark.showProgress")
28482875
.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)