[KYUUBI #7511][SPARK] Start Spark Connect in the Spark SQL engine - #7670
Open
alexandrefimov wants to merge 1 commit into
Open
[KYUUBI #7511][SPARK] Start Spark Connect in the Spark SQL engine#7670alexandrefimov wants to merge 1 commit into
alexandrefimov wants to merge 1 commit into
Conversation
The Spark SQL engine can serve Spark Connect clients next to its Thrift frontend. Connect is started by configuration only - the plugin goes into spark.plugins and the bound endpoint is read back reflectively - because io.grpc is relocated in this module and a compile-time reference to SparkConnectService does not compile here. That also keeps the default spark-3.5 build free of Connect classes. Which engines serve Connect is decided in SparkProcessBuilder, where the values are the server's own. kyuubi.engine.spark.connect.enabled is immutable, but the engine rebuilds its KyuubiConf from every spark.kyuubi.* entry it is handed, so the prefixed copy of that key is dropped from the engine's command line. An engine that would not run as the session user - any share level but USER, or doAs disabled - starts without Connect rather than failing, because a plan submitted over Spark Connect runs as the user the engine runs as, not as the client's user_id. With Connect on, the engine still refuses to start when the runtime cannot authenticate its clients - Spark 3.5 serves Connect with no authentication at all - or when no token is configured: an endpoint that authenticates nobody is worse than no endpoint. The Spark 4.0 requirement is a capability probe rather than a version comparison.
Contributor
Author
|
The one red check, Could someone re-run it? The |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why are the changes needed?
Part of #7511, the first slice agreed there: Spark Connect running inside the Spark SQL engine, next to the Thrift frontend, so that Spark Connect clients reach a Kyuubi-managed engine — the same
SparkContext, the same session extensions, and so the same authorization rules a JDBC client gets.This PR starts the service and stops there. The endpoint is not advertised in discovery yet, the engine's idle and shutdown checks do not count Connect sessions yet, and the token still travels on the command line; those are the next PRs on this issue, and the new deployment page lists them as limitations so the feature is not mistaken for finished.
Connect is started by configuration alone: the driver plugin goes into
spark.pluginsand the bound endpoint is read back reflectively. A compile-time reference does not build in the engine module —io.grpcis relocated toorg.apache.kyuubi.shade.io.grpcthere and the Scala signatures ofSparkConnectServicecarryio.grpctypes — which also keeps the defaultspark-3.5build free of Connect classes.Which engines serve Connect is decided in
SparkProcessBuilder, where the values are the server's own.kyuubi.engine.spark.connect.enabledis immutable, but the engine rebuilds itsKyuubiConffrom everyspark.kyuubi.*entry it is handed, so the prefixed copy of that key is dropped from the engine's command line. An engine that would not run as the session user — any share level butUSER, orkyuubi.engine.doAs.enabled=false— starts without Connect rather than failing, because the share level is the session's own choice. That matters because a plan submitted over Connect runs as the user the engine runs as and not as the client'suser_id: on 4.0.3 with the Ranger extension, a client claiminguser_id=bobagainst an engine launched fortestaliceis denied astestalice.With Connect on, the engine does refuse to start when the runtime cannot authenticate its clients — Spark 3.5 serves Connect with no authentication at all,
spark.connect.authenticate.tokenarrived in 4.0 — or when no token is configured. An endpoint that authenticates nobody is worse than no endpoint. The Spark 4.0 requirement is a capability probe (Connect.getAuthenticateTokenis present) rather than a version comparison, following the "feature detection, not version strings" rule inAGENTS.md.How was this patch tested?
SparkConnectLauncherSuitecovers the configuration the engine writes (the plugin appended once and only once, an ephemeral port unless the deployment picked one, deployment values kept), each of the three refusals, and the reflection itself against stand-in classes shaped like Spark's.SparkProcessBuilderSuitecovers the server-side decision, including a session trying to turn Connect on throughspark.kyuubi.engine.spark.connect.enabled.No suite starts the real service: the engine module does not depend on
spark-connect, and adding the client stubs is a problem of its own, since Spark 4.x builds them against protobuf 4.x while Kyuubi carries 3.25.8. So this commit was also run end to end against Spark 4.0.3 —spark-4.0.3-bin-hadoop3, server built with-Pspark-4.0 -Pscala-2.13,spark.master=local[*],USERshare level, beeline as the client:Spark Connect service is listening on sc://192.168.1.85:57214— the port it reports is the one the service bound, read back through the reflection this PR adds — and JDBC queries keep working;?spark.kyuubi.engine.spark.connect.enabled=true: the value does reach the session,SETreturnstrue, while the engine's launch command carries no such config and Connect never starts;kyuubi.engine.share.level=CONNECTION: the server logsNot starting Spark Connect for this engine: it serves the session user only with kyuubi.engine.share.level=USER and kyuubi.engine.doAs.enabled=true, which are CONNECTION and true here, and that engine starts without Connect;no Spark Connect token is configured. Set spark.connect.authenticate.token or the SPARK_CONNECT_AUTHENTICATE_TOKEN environment variable so that clients are authenticated.The Spark 3.5 case — Connect without authentication — is covered by the suite only; I did not build a 3.5 runtime for it.
Was this patch authored or co-authored using generative AI tooling?
Assisted-by: Claude Opus 5