Skip to content

enable child channel plugins#12578

Open
AgraVator wants to merge 23 commits into
grpc:masterfrom
AgraVator:child-channel-plugin
Open

enable child channel plugins#12578
AgraVator wants to merge 23 commits into
grpc:masterfrom
AgraVator:child-channel-plugin

Conversation

@AgraVator

@AgraVator AgraVator commented Dec 22, 2025

Copy link
Copy Markdown
Contributor

Implements grpc/proposal#529

Comment on lines +34 to +37
ObjectPool<XdsClient> getOrCreate(
String target, BootstrapInfo bootstrapInfo, MetricRecorder metricRecorder,
ManagedChannel parentChannel);

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.

Should this be a generic object instead of ManagedChannel ?

Comment on lines +130 to +149
return new XdsServerWrapper("0.0.0.0:" + port, delegate, xdsServingStatusListener,
filterChainSelectorManager, xdsClientPoolFactory, bootstrapOverride, filterRegistry);
filterChainSelectorManager, xdsClientPoolFactory, bootstrapOverride, filterRegistry,
this.childChannelConfigurer);

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.

Why does this not pass the builder object ?

kannanjgithub
kannanjgithub previously approved these changes Jan 6, 2026
Comment thread api/src/main/java/io/grpc/ChildChannelConfigurer.java Outdated
Comment thread api/src/main/java/io/grpc/ChildChannelConfigurer.java Outdated

@ejona86 ejona86 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.

I know there will be changes based on the gRFC discussion, but here are some things I noticed.

Comment thread api/src/main/java/io/grpc/ChildChannelConfigurers.java Outdated
Comment thread api/src/main/java/io/grpc/ChildChannelConfigurers.java Outdated
Comment thread api/src/main/java/io/grpc/ManagedChannel.java Outdated
Comment thread api/src/main/java/io/grpc/Server.java Outdated
@AgraVator AgraVator marked this pull request as ready for review March 18, 2026 09:04
Comment thread api/src/main/java/io/grpc/ChannelConfigurer.java Outdated
Comment thread api/src/main/java/io/grpc/MetricRecorder.java Outdated
Comment thread api/src/main/java/io/grpc/ManagedChannelBuilder.java Outdated
Comment thread core/src/main/java/io/grpc/internal/ManagedChannelImplBuilder.java Outdated
@AgraVator AgraVator requested a review from kannanjgithub June 3, 2026 11:55
@AgraVator AgraVator requested a review from ejona86 June 3, 2026 11:55
Comment thread api/src/main/java/io/grpc/ChannelConfigurator.java Outdated
Comment thread api/src/main/java/io/grpc/ChannelConfigurator.java Outdated
Comment on lines +641 to +639
@Internal
protected T addMetricSink(MetricSink metricSink) {
public T addMetricSink(MetricSink metricSink) {

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.

What's happening here? Why will this no longer be internal? Even if we were going to make it public, we wouldn't have it go immediately stable; it'd be experimental first.

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.

When an application or test implements ChannelConfigurator, it receives a reference to the child channel's ManagedChannelBuilder.
If addMetricSink were protected (or package-private), then class implementations of ChannelConfigurator outside of the io.grpc package (such as user applications or test suites like FakeControlPlaneXdsIntegrationTest.java) would not be able to call builder.addMetricSink(sink) to register their metric sinks.

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.

What is the problem with that? What new thing do they need to do because of ChannelConfigurator? If addMetricSink() being hidden was a problem, wouldn't that be a pre-existing problem?

GrpcOpenTelemetry.configureChannelBuilder() still works fine with ChannelConfigurator, and it calls addMetricSink() on the user's behalf.

Comment thread api/src/main/java/io/grpc/ManagedChannelBuilder.java
Comment thread api/src/main/java/io/grpc/ServerBuilder.java Outdated
Comment thread api/src/main/java/io/grpc/NameResolver.java Outdated
Comment thread xds/src/main/java/io/grpc/xds/XdsNameResolver.java Outdated
Comment thread xds/src/main/java/io/grpc/xds/XdsServerBuilder.java Outdated
Comment thread xds/src/main/java/io/grpc/xds/XdsServerBuilder.java
// NamedFilterConfig.filterStateKey -> filter_instance.
private final HashMap<String, Filter> activeFiltersDefaultChain = new HashMap<>();

private ChannelConfigurator channelConfigurator = new ChannelConfigurator() {};

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.

We really want this field to be final. I see there is some difficulty with the constructors here, but we should handle that with another constructor that has both ScheduledExecutorService and ChannelConfigurator.

(And we should really clean this up by using ObjectPool/SharedResourcePool/FixedObjectPool to get rid of sharedTimeService. But that is pre-existing.)

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.

I've sent out #12841 to clean that up. Obviously the two PRs will conflict. I'm fine with waiting until this goes in and handling the conflicts. If you want it to go in first to clean up this PR, just tell me.

@AgraVator AgraVator requested a review from ejona86 June 8, 2026 06:35
Comment thread api/src/main/java/io/grpc/ChannelConfigurator.java
Comment thread api/src/main/java/io/grpc/ChannelConfigurator.java
Comment thread api/src/main/java/io/grpc/ChannelConfigurator.java
@AgraVator AgraVator requested a review from kannanjgithub June 12, 2026 08:42

@ejona86 ejona86 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.

This needs some more work, but I'm comfortable with Kannan reviewing it after the changes from these comments come in (no need to wait for me).

* Sets a configurator that will be applied to all internal child channels created by this
* channel.
*
* <p>This allows injecting configuration (like credentials, interceptors, or flow control)

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.

Remove "credentials", it doesn't do that and shouldn't be used for that. And with the text about strongly discouraging casting it to specific implementation types, flow control isn't possible to configure either.

*
* @since 1.83.0
*/
public Builder setChildChannelConfigurator(ChannelConfigurator channelConfigurator) {

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.

getChildChannelConfigurator() is @Internal but this isn't. Seems weird to have them be different.

}

private NameResolver.Args createArgs() {
ChannelConfigurator channelConfigurator = builder -> { };

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.

Delete this, now that NameResolver.Args fills in the same default noop?

return new XdsClientResult(SharedXdsClientPoolProvider.getDefaultProvider()
.getOrCreate(target, bootstrapInfo, metricRecorder, transportCallCredentials));
.getOrCreate(target, bootstrapInfo, metricRecorder, transportCallCredentials,
null));

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.

Looks like we need to add another override for the additional parameter, for use in GoogleCloudToProdNameResolver.

if (hasMetrics) {
break;
}
Thread.sleep(100);

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.

What is this for?

* xDS + OpenTelemetry E2E integration test using a fake control plane.
*/
@RunWith(Parameterized.class)
public class FakeControlPlaneXdsOtelIntegrationTest {

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 test doesn't seem to do anything special. It isn't actually checking that xds client metrics are propagating. If you disable xds in this test, it will still pass, because it is using the generic grpc.client. prefix, which the RPC itself satisfies.

}
assertThat(hasMetrics).isTrue();
} finally {
channel.shutdownNow();

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.

Use GrpcCleanupRule instead of try-finally+shutdown.

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