feat: [grpc] Add retry logic when certificate mismatch for existing credentials & Agent Identity workloads - #18019
Conversation
feat: Add passphrase handling to client cert callback
feat: Add cert rotation handling support
chore: Add passphrase in _mtls_helper for requests
…rase chore: Modify _mtls_helper call to include additional variable passphrase
Updated mock return values in test cases to include None for additional parameters.
Updated mock callback to return an additional None value.
Updated mock call_client_cert_callback to include a None value in the return tuple.
chore: Add unit tests for cert rotation handling for grpc
chore: Add tests for grpc cert roatation handling changes
There was a problem hiding this comment.
Code Review
This pull request introduces mTLS certificate rotation and automatic retry capabilities for gRPC transport by implementing a refreshing channel wrapper and call interceptors. It also updates helper utilities to support key passphrases. The review feedback suggests handling potential CancelledError exceptions gracefully when checking futures to prevent thread crashes, and recommends removing several redundant getattr checks for attributes that are guaranteed to be initialized in their respective class constructors.
fix: Refactor gRPC call handling and state management
|
The github status checks are stuck. You could try closing and re-opening this PR to re-trigger them |
cdd91ce to
524247b
Compare
Signed-off-by: Radhika Agrawal <agrawalradhika@google.com>
…mments and fix doctrings chore: Update Refactor mTLS gRPC client interceptor logic based on comments and fix doctrings
…ype hint for passphrase. chore: Refactor error handling for certificate retrieval and update type hint for passphrase.
fix: Refactor deadline error handling in grpc.py
daniel-sanche
left a comment
There was a problem hiding this comment.
I left some comments after a first pass, but I need to spend more time reviewing some of these wrappers.
First though, are you sure this is the right layer? I don't have much context on this change, but IIRC, gapic libraries use a different channel type. So I just want to make sure this is accomplishing what you want it to
9ee9410 to
7b3f17b
Compare
Signed-off-by: Radhika Agrawal <agrawalradhika@google.com>
7b3f17b to
d8050ed
Compare
chore: Refactor gRPC call handling with base wrapper class
chore: Include Wrapper in CertRotationInterceptor initialization
…hannel factory arguments. chore: Refactor MTLS channel creation to use a partial function for channel factory arguments.
…ate rotation This file implements an mTLS Interceptor and Channel Wrapper that supports automatic retry logic for certificate rotation in gRPC calls.
Updated the gRPC transport module to use mtls_interceptor for mutual TLS support. Removed the old CertRotationInterceptor and MTLSRefreshingChannel classes.
chore: Rename _mtls_interceptor.py to mtls_interceptor.py to make public
Fix import statement for mtls_interceptor
Refactor mTLS interceptor and channel logic for improved certificate rotation handling.
fix: Remove unnecessary blank line in test file
feat: [grpc] Add retry logic when certificate mismatch for existing credentials & Agent Identity workloads
This PR introduces mTLS certificate rotation and encrypted private key passphrase handling to the gRPC transport. It implements an interceptor and a refreshing channel to automatically reload client certificates upon authentication failures when certificates rotate. It also updates tests and mock return values across all transports.
See go/grpc-cert-rotation-in-pythonsdk-for-x509 for details.