unwrap ForwardingSubchannel during Picks#12658
Draft
shivaspeaks wants to merge 6 commits intogrpc:masterfrom
Draft
unwrap ForwardingSubchannel during Picks#12658shivaspeaks wants to merge 6 commits intogrpc:masterfrom
shivaspeaks wants to merge 6 commits intogrpc:masterfrom
Conversation
ejona86
reviewed
Feb 17, 2026
xds/src/test/java/io/grpc/xds/WeightedRoundRobinLoadBalancerTest.java
Outdated
Show resolved
Hide resolved
xds/src/test/java/io/grpc/xds/WeightedRoundRobinLoadBalancerTest.java
Outdated
Show resolved
Hide resolved
xds/src/test/java/io/grpc/xds/WeightedRoundRobinLoadBalancerTest.java
Outdated
Show resolved
Hide resolved
Member
Author
|
Please also check the description of the PR, if we need to add anything or remove anything. |
ejona86
approved these changes
Feb 19, 2026
Member
ejona86
left a comment
There was a problem hiding this comment.
You should probably mark this PR as "Ready for review" (not Draft).
loosely-typed attributes
Attributes are strongly-typed. It's more about not needing to abuse attributes so to re-discover what should already be known.
|
|
||
| private static final class OrcaOobPicker extends SubchannelPicker { | ||
| private final SubchannelPicker delegate; | ||
| static final class OrcaOobPicker extends SubchannelPicker { |
Member
There was a problem hiding this comment.
Add @VisibleForTesting to both of these.
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.
This PR ensures that Load Balancing (LB) policies unwrap
ForwardingSubchannelinstances before returning them in aPickResult.Rationale: Currently, the identity of a subchannel is "awkward" because decorators break object identity. This forces the core channel to use internal workarounds like
getInternalSubchannel()to find the underlying implementation. Removing these wrappers during the pick process is a critical prerequisite for deleting Subchannel Attributes.By enforcing unwrapping,
ManagedChannelImplcan rely on the fact that a returned subchannel is the same instance it originally created. This allows the channel to use strongly-typed fields for state management (via "blind casting") rather than loosely-typed attributes. This also paves the way for the eventual removal of thegetInternalSubchannel()internal API.New APIs: To ensure we don't "drop data on the floor" during the unwrapping process, this PR adds two new non-static APIs to PickResult:
Unlike static factory methods, these instance methods follow a "copy-and-update" pattern that preserves all existing pick-level metadata (such as authority overrides or drop status) while only swapping the specific field required.