xds/extauthz: add clientInterceptor implementation for gRFC A92. - #9300
xds/extauthz: add clientInterceptor implementation for gRFC A92.#9300Pranjali-2501 wants to merge 10 commits into
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #9300 +/- ##
==========================================
- Coverage 83.26% 83.13% -0.14%
==========================================
Files 423 424 +1
Lines 35236 35482 +246
==========================================
+ Hits 29341 29497 +156
- Misses 4402 4458 +56
- Partials 1493 1527 +34
🚀 New features to boost your workflow:
|
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request implements the client-side filter and interceptor for the external authorization (ext_authz) HTTP filter in gRPC-Go, including refcounted channel sharing, header filtering, and header/response header mutations. Feedback is provided regarding a potential race condition in NewStream when incrementing the refcount of a closing channel, a timestamp inconsistency from calling time.Now() twice, and a potential nil-pointer panic in clientStream.Header() if the underlying stream returns nil metadata.
| // Increment authzClient's refcount so the Check RPC keeps the connection | ||
| // open even if the interceptor is closed concurrently. Decrement is deferred | ||
| // to release the reference when NewStream completes. | ||
| i.authzClient.Increment() | ||
| defer i.authzClient.Decrement() |
There was a problem hiding this comment.
There is a potential race condition if Close() is called concurrently with NewStream. If Close() runs after the i.closed.Load() check but before i.authzClient.Increment(), the refcount can drop to 0 and trigger channel cleanup. Calling Increment() on a 0-refcount object is invalid and can lead to panics or use-after-free bugs. Using TryIncrement() instead ensures we safely attempt to increment the refcount and gracefully fail if the channel is already being cleaned up.
| // Increment authzClient's refcount so the Check RPC keeps the connection | |
| // open even if the interceptor is closed concurrently. Decrement is deferred | |
| // to release the reference when NewStream completes. | |
| i.authzClient.Increment() | |
| defer i.authzClient.Decrement() | |
| // Increment authzClient's refcount so the Check RPC keeps the connection | |
| // open even if the interceptor is closed concurrently. Decrement is deferred | |
| // to release the reference when NewStream completes. | |
| if !i.authzClient.TryIncrement() { | |
| return nil, status.Errorf(codes.Unavailable, "extauthz: interceptor is closed") | |
| } | |
| defer i.authzClient.Decrement() |
This PR implements the client-side filter and interceptor logic along with unit and end-to-end tests for the
ext_authzHTTP filter as specified in gRFC A92: xDS external authorization HTTP Filter. This PR also adds client-side metrics support for ext_authz.RELEASE NOTES: N/A