Skip to content

xds: Change how xDS filters are created by introducing Filter.Provider (v1.71.x backport)#12089

Merged
shivaspeaks merged 1 commit into
grpc:v1.71.xfrom
shivaspeaks:backport-1.71-xds-filter-provider
May 23, 2025
Merged

xds: Change how xDS filters are created by introducing Filter.Provider (v1.71.x backport)#12089
shivaspeaks merged 1 commit into
grpc:v1.71.xfrom
shivaspeaks:backport-1.71-xds-filter-provider

Conversation

@shivaspeaks

Copy link
Copy Markdown
Member

Backport of #11883 to v1.71.x.

This is the first step towards supporting filter state retention in Java. The mechanism will be similar to the one described in A83 for C-core, and will serve the same purpose. However, the implementation details are very different due to the different nature of xDS HTTP filter support in C-core and Java.

In Java, xDS HTTP filters are backed by classes implementing io.grpc.xds.Filter, from here just called "Filters".
To support Filter state retention (next PR), Java's xDS implementation must be able to create unique Filter instances per:

  • Per HCM envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
  • Per filter name as specified in envoy.extensions.filters.network.http_connection_manager.v3.HttpFilter.name

This PR does not implements Filter state retention, but lays the groundwork for it by changing how filters are registered and instantiated. To achieve this, all existing Filter classes had to be updated to the new instantiation mechanism described below.

Prior to these this PR, Filters had no livecycle. FilterRegistry provided singleton instances for a given typeUrl. This PR introduces a new interface Filter.Provider, which instantiates Filter classes. All functionality that doesn't need an instance of a Filter is moved to the Filter.Provider. This includes parsing filter config proto into FilterConfig and determining the filter kind (client-side, server-side, or both).

This PR is limited to refactoring, and there's no changes to the existing behavior. Note that all Filter Providers still return singleton Filter instances. However, with this PR, it is now possible to create Providers that return a new Filter instance each time newInstance is called

grpc#11883)

This is the first step towards supporting filter state retention in
Java. The mechanism will be similar to the one described in [A83]
(https://github.com/grpc/proposal/blob/master/A83-xds-gcp-authn-filter.md#filter-call-credentials-cache)
for C-core, and will serve the same purpose. However, the
implementation details are very different due to the different nature
of xDS HTTP filter support in C-core and Java.

In Java, xDS HTTP filters are backed by classes implementing
`io.grpc.xds.Filter`, from here just called "Filters". To support
Filter state retention (next PR), Java's xDS implementation must be
able to create unique Filter instances per:
- Per HCM
  `envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager`
- Per filter name as specified in
  `envoy.extensions.filters.network.http_connection_manager.v3.HttpFilter.name`

This PR **does not** implements Filter state retention, but lays the
groundwork for it by changing how filters are registered and
instantiated. To achieve this, all existing Filter classes had to be
updated to the new instantiation mechanism described below.

Prior to these this PR, Filters had no livecycle. FilterRegistry
provided singleton instances for a given typeUrl. This PR introduces
a new interface `Filter.Provider`, which instantiates Filter classes.
All functionality that doesn't need an instance of a Filter is moved
to the Filter.Provider. This includes parsing filter config proto
into FilterConfig and determining the filter kind
(client-side, server-side, or both).

This PR is limited to refactoring, and there's no changes to the
existing behavior. Note that all Filter Providers still return
singleton Filter instances. However, with this PR, it is now possible
to create Providers that return a new Filter instance each time
`newInstance` is called.
@shivaspeaks shivaspeaks requested a review from kannanjgithub May 22, 2025 15:48
@shivaspeaks shivaspeaks merged commit 2fd8447 into grpc:v1.71.x May 23, 2025
19 of 21 checks passed
@shivaspeaks shivaspeaks deleted the backport-1.71-xds-filter-provider branch May 23, 2025 10:54
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Aug 22, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants