Skip to content

feat: add streaming support for transparent cert rotation retries - #2

Draft
agrawalradhika-cell wants to merge 14 commits into
mainfrom
feature/cert-rotation-streaming
Draft

feat: add streaming support for transparent cert rotation retries#2
agrawalradhika-cell wants to merge 14 commits into
mainfrom
feature/cert-rotation-streaming

Conversation

@agrawalradhika-cell

Copy link
Copy Markdown
Owner

No description provided.

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

Copy link
Copy Markdown

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 implements automatic mTLS channel refreshing and retrying on UNAUTHENTICATED errors in the gRPC transport by introducing custom interceptors and a refreshing channel wrapper. It also updates an asynchronous test in the aiohttp transport tests to be properly defined and awaited. However, a critical issue was identified where several standard library modules (collections.abc, random, threading, time) used in the new classes are not imported, which will cause runtime NameErrors.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +19 to +22
import logging
import logging

_LOGGER = logging.getLogger(__name__)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

critical

Several standard library modules (collections.abc, random, threading, time) are used in the newly added classes but are not imported in this file, which will cause NameError exceptions at runtime. Additionally, there is a duplicate import of logging and duplicate definition of _LOGGER that should be cleaned up.

Suggested change
import logging
import logging
_LOGGER = logging.getLogger(__name__)
import collections.abc
import logging
import random
import threading
import time

agrawalradhika-cell and others added 10 commits June 11, 2026 20:47
Signed-off-by: Radhika Agrawal <agrawalradhika@google.com>
- Handled race conditions when old streams fail during cert rotation by tracking `attempt_cert`.
- Dropped the flawed `_channel.close()` that abruptly killed in-flight streams. Subscriptions are now safely migrated and the old channel is allowed to drain.
- Implemented `_ReplayableIterator` with dual-lock synchronization and `_can_replay` checks. This guarantees zombie threads gracefully abort context handoffs instead of dropping data or deadlocking.
- Fixed the `IndentationError` in `test_aiohttp_requests.py`.
- Added new test suite to cover the tricky streaming handoff concurrency bugs.
@agrawalradhika-cell
agrawalradhika-cell force-pushed the feature/cert-rotation-streaming branch from 2fa4713 to 5447aad Compare July 16, 2026 21:19
Jetski added 3 commits July 17, 2026 21:38
* Implemented ThreadPoolExecutor on _MTLSCallInterceptor for async retry
* Corrected callback threading deadlocks by breaking apart Future resolution
* Resolved ABC TypeError omission of traceback() method
* Prevented stream data-loss by restoring can_replay restrictions
* Fixed bidi callback destruction with inner_call ID checks
* Resolved re-entrant deadlock in refresh_logic channel migration
* Added cancellation state guards to prevent zombie pipeline revivals
* Introduced 5-second IO throttle TTL cache to check_parameters_for_unauthorized_response to handle thundering herd.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant