Skip to content

[MINOR][NETWORK][3.5] Improve Transport Context Stream Manager Delegation - #58612

Open
holdenk wants to merge 2 commits into
apache:branch-3.5from
holdenk:f003-r2-branch-3.5
Open

holdenk wants to merge 2 commits into
apache:branch-3.5from
holdenk:f003-r2-branch-3.5

Conversation

@holdenk

@holdenk holdenk commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

Improve Transport Context Stream Manager Delegation by requiring authentication when enabled
This is a backport of 3b47eee behind a feature flag since 3.5 is in extended LTS mode.

Generated-By: Claude (multiple models) and Cursor with Kimi (K3)

@pan3793 pan3793 changed the title [BACKPORT][MINOR] Improve Transport Context Stream Manager Delegation [MINOR][NETWORK][3.5] Improve Transport Context Stream Manager Delegation Sep 8, 2026

@HyukjinKwon HyukjinKwon left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 blocking, 0 non-blocking, 0 nits.
Clean, faithful backport: the StreamManager wrapper fails closed on chunk/stream serving before authentication and delegates lifecycle callbacks unconditionally; the documentation and tests are accurate.

Verification

Confirmed the fail-closed contract: getChunk, openStream, and both checkAuthorization overloads call checkAuthenticated() (AbstractAuthRpcHandler.java:149/155/161/167), which throws SecurityException while !isAuthenticated (line 143); the six lifecycle/accounting callbacks delegate with no auth check (e.g. connectionTerminated, line 173). Verified the base StreamManager.checkAuthorization overloads are empty no-ops, matching the Javadoc. Verified TransportContext wires the chunk-fetch handler through the per-channel handler (channelRpcHandler.getStreamManager(), line 211). Checked the one cross-thread question: isAuthenticated is non-volatile but has a single writer on the channel I/O thread (receive(), line 62); the chunk-fetch path reads it on the chunkFetchWorkers executor, and Netty's per-message executor handoff establishes happens-before from the auth write to that read, so visibility holds and the worst case is fail-closed. Both concrete subclasses inherit getStreamManager without override.

PR metadata suggestions

  • Document: the title/body frame this as a delegation "improvement" tagged [MINOR], but the effect is a security hardening -- StreamRequest/ChunkFetchRequest were served pre-auth on channels behind an auth bootstrap (the file-distribution channel was unprotected even with spark.authenticate enabled) and now fail closed. Consider stating that in the body so the change's intent is clear.

@HyukjinKwon HyukjinKwon left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One follow-up on the default-behavior change in this backport (see inline).

@Override
public StreamManager getStreamManager() {
return delegate.getStreamManager();
return new AuthCheckingStreamManager(delegate.getStreamManager());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This flips a default on a maintenance branch: on a channel behind an authentication bootstrap, StreamRequest/ChunkFetchRequest that used to be served now throw SecurityException until the channel authenticates. On master that hardening is clearly the right call, but shipping it in a [3.5] patch release changes runtime behavior operators did not opt into -- anything that today relies on stream/chunk serving before the handshake completes on such a channel would start getting rejected after a minor upgrade.

Could we gate the fail-closed path behind a config that defaults to the current (pre-PR) behavior on branch-3.5 (and can default on in master), so the patch release stays behavior-compatible and operators opt into the stricter check? If we would rather not add a flag, let's at least call the behavior change out explicitly in the description and release notes so it is not a silent default change in a maintenance line.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that's fair

Co-Authored-By: Holden Karau <holden@pigscanfly.ca>
Add spark.network.auth.requireAuthForStreamRequests (default false on
branch-3.5) so the AuthCheckingStreamManager fail-closed path is opt-in
and the patch release keeps the historical pre-auth serving behavior
unless operators enable it.

Co-authored-by: Cursor <cursoragent@cursor.com>

Co-Authored-By: Holden Karau <holden@pigscanfly.ca>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants