Skip to content

extproc: implement ClientFilter and ClientFilterBuilder interface#9086

Open
eshitachandwani wants to merge 11 commits into
grpc:masterfrom
eshitachandwani:build_client_interceptor
Open

extproc: implement ClientFilter and ClientFilterBuilder interface#9086
eshitachandwani wants to merge 11 commits into
grpc:masterfrom
eshitachandwani:build_client_interceptor

Conversation

@eshitachandwani
Copy link
Copy Markdown
Member

@eshitachandwani eshitachandwani commented Apr 22, 2026

This PR is part of implementing A93: xds-ext-proc

NOTE : This PR has some coinciding changes with #9073 , they can be reviewed in that PR. The list of coinciding files:

  • optional.go
  • optional_test.go
  • extconfig.go

This PR adds the builder that implements the ClientFilter and ClientFilterBuilder interface. That includes creating the interceptor config from the base and the override config. It also includes making the ext_proc channel.

THis PR has a placeholder function for converting grpcService to ServerConfig proto. The function will be implemented later when implementing gRFC A102.

The interceptor struct has a resolver.ClientInterceptor embedded for now, but that will be removed in a later PR when we implement the resolver.ClientInterceptor interface. Since the filter will not be registered and no one is calling the resolver.ClientInterceptor function fro extproc filter , it will not panic.

#ext-proc-a93

RELEASE NOTES: None

@eshitachandwani eshitachandwani added this to the 1.82 Release milestone Apr 22, 2026
@eshitachandwani eshitachandwani added the Type: Feature New features or improvements in behavior label Apr 22, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 22, 2026

Codecov Report

❌ Patch coverage is 64.19753% with 29 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.01%. Comparing base (06fc26a) to head (76f6f0a).
⚠️ Report is 20 commits behind head on master.

Files with missing lines Patch % Lines
internal/xds/httpfilter/extconfig.go 0.00% 25 Missing ⚠️
internal/xds/httpfilter/extproc/ext_proc.go 86.20% 3 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9086      +/-   ##
==========================================
+ Coverage   80.52%   83.01%   +2.49%     
==========================================
  Files         413      417       +4     
  Lines       33543    33563      +20     
==========================================
+ Hits        27012    27864     +852     
+ Misses       4316     4273      -43     
+ Partials     2215     1426     -789     
Files with missing lines Coverage Δ
experimental/optional/optional.go 100.00% <100.00%> (ø)
internal/xds/httpfilter/extproc/config.go 100.00% <100.00%> (ø)
internal/xds/httpfilter/extproc/ext_proc.go 86.20% <86.20%> (ø)
internal/xds/httpfilter/extconfig.go 0.00% <0.00%> (ø)

... and 45 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@eshitachandwani
Copy link
Copy Markdown
Member Author

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces the Envoy external processing filter, providing configuration parsing logic and the infrastructure to build a client interceptor. Feedback addresses a critical uninitialized function variable that would cause a panic during filter construction and suggests a performance optimization for slice allocation when converting string matchers.

Comment thread internal/xds/httpfilter/extproc/ext_proc.go Outdated
Comment thread internal/xds/httpfilter/extproc/config.go Outdated
eshitachandwani and others added 3 commits April 26, 2026 22:33
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@eshitachandwani
Copy link
Copy Markdown
Member Author

As per offline discussion , changed override config to use the new optional type and changed the functions and tests accordingly.

@eshitachandwani
Copy link
Copy Markdown
Member Author

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a generic Option[T] type for optional values and establishes the foundational configuration and builder logic for the xDS external processing (extproc) HTTP filter. Feedback highlights critical concerns regarding resource management, specifically the creation of unmanaged grpc.ClientConn instances that could lead to leaks and performance issues. Additionally, the interceptor struct currently embeds an uninitialized interface, which would result in a nil pointer dereference panic if invoked.

Comment on lines +69 to +73
cc, err := createExtProcChannel(config.server)
if err != nil {
return nil, fmt.Errorf("extproc: failed to create client: %v", err)
}
extClient := v3procservicepb.NewExternalProcessorClient(cc)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

The current implementation creates a new grpc.ClientConn to the external processing server on every call to BuildClientInterceptor. This is problematic for several reasons:

  1. Resource Leak: The iresolver.ClientInterceptor interface does not have a Close method, and the gRPC-Go xDS framework does not currently provide a mechanism to close interceptors when they are replaced (e.g., during a configuration update). This means every connection created here will leak until the application exits.
  2. Performance: Creating a ClientConn is an expensive operation that involves starting name resolution and connection management goroutines.
  3. Redundancy: Multiple routes or clusters using the same external processing server will each create their own connection instead of sharing one.

The clientFilter should instead manage a cache of ClientConn instances (e.g., a map[string]*grpc.ClientConn keyed by the server configuration) and reuse them. These connections should then be closed in the clientFilter.Close() method.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Channel retention is in discussion and will be done later.

}

type interceptor struct {
resolver.ClientInterceptor
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

The interceptor struct embeds the resolver.ClientInterceptor interface but does not initialize it. Since this is an interface, any attempt by the gRPC framework to call its methods (such as NewStream) on the returned interceptor will result in a nil pointer dereference panic.

While the PR description notes that this will be addressed in a later PR, it is highly recommended to provide a placeholder implementation of the interface methods that returns an error (e.g., using status.Error(codes.Unimplemented, ...)), or at least add a prominent TODO or comment in the code to warn that this struct is currently in a broken state if used.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The next PR will do this.

@easwars
Copy link
Copy Markdown
Contributor

easwars commented May 12, 2026

@eshitachandwani
There is a whole lot of overlap with 9073, in which I had a bunch of comments. So, moving this back to you until the former is merged.

@easwars easwars assigned eshitachandwani and unassigned easwars and mbissa May 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: Feature New features or improvements in behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants