feat(emr): run a session's Spark Connect server on its cluster in the docker runner mode (#8751)

With runner-mode docker, StartSession now runs the session's Spark
Connect server on its cluster, as "Amazon EMR launches a Spark Connect
Server as a YARN application on your cluster": a container on the
cluster as a step's is, in the image its steps run in, its HDFS and
YARN started first where they are not running, the server's driver in
that container and its executors on the cluster's YARN. Its
spark-defaults are the cluster's, then the session's
EngineConfigurations, with the server's port; it runs as the session's
ExecutionRoleArn, else the cluster's instance profile.

A client reaches it through Floci as an EMR Serverless session's server
is reached (#8731): GetSessionEndpoint answers Floci's address and a
token, and a client connects with
sc://<host>:<port>/;x-aws-proxy-auth=<token>;authorization=<session id>,
AWS's string with Floci's port. The proxy drops the authorization
parameter, which AWS's own proxy reads, before the call reaches the
server.

The session is SUBMITTED until its container runs, STARTING until the
server answers, then IDLE, BUSY while a call runs on its server and
IDLE again once none does. TerminateSession goes through TERMINATING
until the server has stopped; the idle timeout stops it too, and the
cluster's end ends its sessions and stops their servers on its own,
its storage released only once the last of them has gone. A server that exits on its own, or does not answer within
10 minutes, fails the session; one a restart left behind fails as
interrupted, its container removed.

What EMR Serverless's sessions and these share moves into
emrserverless.SparkConnectServers: running each server, asking it
whether it answers, the tokens, the calls a session takes, and one
check for its next deadline; and SparkConnectSessionOwner, the states a
session goes through as its server starts, answers, takes calls and
stops, each service giving only how it stores, ends and checks its
sessions (both models implement SparkConnectSession). A server being stopped takes no new call, a call's
busy and idle reach the owner in order under the server's own lock, and
a server's entry goes even where its owner fails to hear it stopped. A step's setup on its cluster (its image, storage,
metadata address, added nodes and HDFS) moves into a preparation that
steps and sessions' servers share.

EmrSessionServerNightlyIntegrationTest runs it for real on an
emr-spark-8.1.0 cluster with Spark 4's JVM client from that image: a
wrong token refused, queries run, a missing table's Spark error back,
TerminateSession removing the server. The nightly job's timeout and
image prefetch take the new check.
This commit is contained in:
Priamo Germosen authored and GitHub committed 2026-11-17 12:18:09 -04:00
1 parent 948dcadae8
commit 2517edb471
23 files changed
+1926 -451

No files matched your search

+5 -4
View File
@@ -31,10 +31,11 @@ jobs:
# The checks run one after another, each within its own @Timeout bounds, so the job allows their sum, and about
# twenty minutes for the build, the image and the prefetch: EmrPigStepsNightlyIntegrationTest's 30,
# EmrFlociContainerNightlyIntegrationTest's 20 and 4 for its setup,
# EmrServerlessCustomImageNightlyIntegrationTest's 85 and 21 for its setup, and
# EmrServerlessSparkConnectNightlyIntegrationTest's 30, 190 in all. A check added, or a bound raised, raises this
# with it, so a slow check fails with its own message rather than the job being cancelled with none.
timeout-minutes: 210
# EmrServerlessCustomImageNightlyIntegrationTest's 85 and 21 for its setup,
# EmrServerlessSparkConnectNightlyIntegrationTest's 30, and EmrSessionServerNightlyIntegrationTest's 40, 230 in all.
# A check added, or a bound raised, raises this with it, so a slow check fails with its own message rather than the
# job being cancelled with none.
timeout-minutes: 250
# A fork's schedule would spend its owner's minutes on checks it never asked for; a draft waits until it is
# ready for review, as the CI shards do.
if: >-