Skip to content

Commit ccd118f

Browse files
authored
A83 update: document Java's filter state retention. (#491)
Document Java's implementation details for xDS HTTP Filter state retention.
1 parent 806e1a4 commit ccd118f

1 file changed

Lines changed: 57 additions & 3 deletions

File tree

A83-xds-gcp-authn-filter.md

Lines changed: 57 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ A83: xDS GCP Authentication Filter
44
* Approver: @ejona86, @dfawley
55
* Status: {Draft, In Review, Ready for Implementation, Implemented}
66
* Implemented in: <language, ...>
7-
* Last updated: 2025-09-17
7+
* Last updated: 2025-09-19
88
* Discussion at: https://groups.google.com/g/grpc-io/c/76a0zWJChX4
99

1010
## Abstract
@@ -298,9 +298,60 @@ a cache size change will wind up affecting the old filter instance,
298298
which in principle it shouldn't, but that is considered acceptable for
299299
this type of change.
300300

301-
##### Java and Go
301+
##### Java
302302

303-
TODO(sergiitk, ejona86, dfawley): Fill this in.
303+
In Java, xDS HTTP Filter objects will be responsible for retaining their own
304+
state.
305+
306+
The GCP Authentication filter will store the call credentials cache as a regular
307+
field on a `GcpAuthenticationFilter` object. No in-filter logic will be needed
308+
to separate caches per filter instance name, as Java's implementation
309+
will produce distinct `GcpAuthenticationFilter` instances, and therefore,
310+
different caches.
311+
312+
To achieve this, we need to make several key changes to the class design.
313+
314+
In Java, each xDS HTTP Filter has a corresponding concrete implementation of the
315+
`io.grpc.xds.Filter` interface. We will refer these classes as "Filters" from
316+
here.
317+
318+
Currently, Filter classes are stateless singletons, registered by type URL in a
319+
global `FilterRegistry`. We will make Filter classes stateful and use the
320+
concrete instances to retain data across LDS / RDS updates as necessary.
321+
322+
We will introduce a new interface `Filter.Provider` with a `newInstance`
323+
method to instantiate Filter classes. All stateless `Filter` methods, such as
324+
config parsing, will be moved to `Filter.Provider`.
325+
326+
We will implement `Filter.Provider` in each existing Filter class (as an
327+
inner static class). Filters that do not need to retain filter state
328+
may implement `newInstance` to keep returning a singleton instance of self.
329+
330+
We will update `FilterRegistry` to register `Filter.Provider` instances instead
331+
of `Filter` instances.
332+
333+
Next, we will implement the lifecycle of Filter objects, which differs between
334+
client-side and server-side Filters. This will be implemented separately in
335+
`XdsNameResolver` and `XdsServerWrapper` respectively, due to the structural
336+
differences in their configurations.
337+
338+
The filter state is scoped to `HttpConnectionManager` (HCM) instance.
339+
340+
On the client-side, each `XdsNameResolver` has a single HCM, which contains a
341+
single list of L7 filters.
342+
343+
Server-side, however, may have multiple `FilterChain` instances (from the
344+
`filter_chains` repeated field and an optional `default_filter_chain`), each
345+
with its own HCM and L7 filters. To keep track of individual L4 filter chains
346+
across LDS updates, we'll use their unique names. The state will not be retained
347+
for any unnamed L4 filter chain.
348+
349+
Filter instances are shut down when they are removed from their HCM, or when the
350+
HCM itself is removed (e.g., during client or server shutdown).
351+
352+
##### Go
353+
354+
TODO(dfawley, easwars): Fill this in.
304355

305356
### Filter Behavior
306357

@@ -405,5 +456,8 @@ Java implementation:
405456
- implement GCP auth filter (https://github.com/grpc/grpc-java/pull/11638)
406457
- xDS cluster metadata parsing (https://github.com/grpc/grpc-java/pull/11741)
407458
- propagate audience from cluster resource in gcp auth filter (https://github.com/grpc/grpc-java/pull/11972)
459+
- filter state retention:
460+
- make Filter objects stateful (https://github.com/grpc/grpc-java/pull/11883)
461+
- implement the lifecycle of Filter objects (https://github.com/grpc/grpc-java/pull/11936)
408462

409463
Will be implemented in all other languages, timelines TBD.

0 commit comments

Comments
 (0)