Repository navigation
feat(transport): support credential_provider on background Redis clients - #307
Conversation
QualOps Code Quality AnalysisStatus: Summary
🟠 High Issues (1)
🟡 Medium Issues (6)
...and 3 more medium issues 📊 Full ReportPowered by QualOps |
pontino
left a comment
There was a problem hiding this comment.
Tested against a local Redis with requirepass. The change itself works: with credential_provider the broker, reclaimer, monitor and delete-on-ack client all authenticate.
But the same whitelist still drops other things, and I think the whitelist itself is the problem. Details inline. Three more outside the diff:
redis.py:184— withbroker=the background clients get the default url and no kwargs.RedisTransport(broker=RedisBroker("rediss://x.redis.azure.net", credential_provider=p))→ reclaimer/monitor dialredis://localhost:6379with no auth. The other way round (RedisTransport(broker=b, credential_provider=p)) authenticates the background clients but not the broker.redis.py:951— the monitor loop only catchesResponseError.AuthenticationErroris aConnectionError, so when the token rotates the monitor task dies with no log, anddisconnect()re-raises it and skipsreclaimer.stop(),broker.stop()and the delete client. Reproduced with an ACL user: change password +CLIENT KILL USER. Pre-existing, but it is the Entra ID case this PR is for.pending_reclaimer.py:339—start()opens a new client on everyconnect()and never closes the old one. Two agents on one transport: 4 → 8 connections, 2 stay open afterstop()until GC. Pre-existing.if self._redis_client is None:like the delete client fixes it.
Description
RedisTransportonly passedcredential_providerto the broker connection, not to its long-lived background clients (the PEL reclaimer, the group monitor, and the delete-on-ack client). Those clients are built from a whitelisted subset of connection kwargs (_BACKGROUND_CLIENT_CONNECTION_KEYS), andcredential_providerwas missing from that whitelist.When the Redis server authenticates via a credential provider instead of a password in the URL — an ACL user, or a rotating token such as Azure Managed Redis / Microsoft Entra ID — the background clients connected unauthenticated and the server rejected them (
AuthenticationError: HELLO must be called with the client already authenticated), even though the broker itself connected fine. This change addscredential_providerto the whitelist so every connection authenticates from the same source.Type of Change
Related Issue
N/A — no tracked issue.
Changes Made
"credential_provider"to_BACKGROUND_CLIENT_CONNECTION_KEYSinsdk/eggai/transport/redis.py, so it is forwarded fromRedisTransport(**kwargs)to the reclaimer, group monitor, and delete-on-ack clients (the broker already received it).test_credential_provider_propagates_to_background_clientsinsdk/tests/test_redis.pyasserting the provider reaches_connection_kwargsand the reclaimer manager.[Unreleased] → Addedentry tosdk/CHANGELOG.md.Testing
make test)Manual Testing Steps
test_redis.py,test_redis_delete_on_ack.py,test_redis_shared_dlq.py) against a local Redis:90 passed.Changelog
sdk/CHANGELOG.mdunder[Unreleased]section (required for code changes)Checklist
make lintpasses)make formatapplied)Additional Notes
Companion to the existing
fix(transport): forward connection-resilience kwargs to the PEL reclaimerchange — same mechanism (keep the background clients' connections consistent with the broker's), one more kwarg the whitelist needs to carry. Enables Entra ID / managed-identity auth against Azure Managed Redis end-to-end.