-
Notifications
You must be signed in to change notification settings - Fork 29
replace custom Azure Redis auth -> redis-entraid #308
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
rootflo-hardik
wants to merge
9
commits into
develop
Choose a base branch
from
fix/redis_connection_for_azure_entra_auth
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
9642377
replace custom Azure Redis auth -> redis-entraid
rootflo-hardik d5fbfdb
disable Celery mingle/gossip to avoid CROSSSLOT on Azure Redis
rootflo-hardik 4f8f7fc
add 10s timeout to Azure Redis token fetch via redis-entraid
rootflo-hardik a1af20e
hash tag for default queue on Azure Managed Redis
rootflo-hardik 69cf0ef
same default queue for producer also
rootflo-hardik b2a3570
disable remote control to eliminate pidbox CROSSSLOT errors
rootflo-hardik 2928139
co-locate unacked keys to same Redis hash slot
rootflo-hardik a6097ea
celery - add llmconfig service to agents_container
rootflo-hardik b323bc0
wiring llm_config properly inside agent inference
rootflo-hardik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
wavefront/server/modules/db_repo_module/db_repo_module/cache/azure_redis_auth.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| import os | ||
| import threading | ||
|
|
||
| import redis | ||
|
|
||
| _patched = False | ||
|
|
||
|
|
||
| def patch_redis_for_azure() -> None: | ||
| global _patched | ||
| if _patched or os.getenv('CLOUD_PROVIDER', '').lower() != 'azure': | ||
| return | ||
|
|
||
| from redis_entraid.cred_provider import create_from_default_azure_credential | ||
| from redis.credentials import CredentialProvider | ||
|
|
||
| _inner = create_from_default_azure_credential(('https://redis.azure.com/.default',)) | ||
|
|
||
| class _TimedProvider(CredentialProvider): | ||
| def get_credentials(self): | ||
| result = [] | ||
| exc = [] | ||
|
|
||
| def _fetch(): | ||
| try: | ||
| result.append(_inner.get_credentials()) | ||
| except Exception as e: | ||
| exc.append(e) | ||
|
|
||
| t = threading.Thread(target=_fetch, daemon=True) | ||
| t.start() | ||
| t.join(timeout=10) | ||
| if t.is_alive(): | ||
| raise TimeoutError('Azure Redis token fetch timed out after 10s') | ||
| if exc: | ||
| raise exc[0] | ||
| return result[0] | ||
|
|
||
| provider = _TimedProvider() | ||
| original_init = redis.ConnectionPool.__init__ | ||
|
|
||
| def patched_init(self, *args, **kw): | ||
| kw.pop('password', None) | ||
| kw.pop('username', None) | ||
| kw['credential_provider'] = provider | ||
| original_init(self, *args, **kw) | ||
|
|
||
| redis.ConnectionPool.__init__ = patched_init | ||
| _patched = True | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🌐 Web query:
Celery 5.4 worker_process_init signal documentation child process main worker broker connection timing💡 Result:
In Celery 5.4, the worker_process_init signal is dispatched within each individual pool child process immediately after it is initialized by the prefork pool, but before it begins processing tasks [1][2]. Key technical details regarding your query: 1. Signal Timing: The worker_process_init signal is triggered by the process_initializer function [2]. This function is responsible for setting up the environment for the child process (e.g., resetting signals, initializing logging, and configuring task execution) [2]. Because it is called as part of the process initialization sequence, it runs in the child process context, not the main worker process context [1][2]. 2. Broker Connection Timing: The main Celery worker process is responsible for managing the connection to the message broker [3]. Broker connections are established by the Consumer bootstep in the main process [3][4]. Child processes in the prefork pool do not independently establish their own primary connections to the broker to fetch tasks; instead, they receive tasks from the main process via an internal pipe/queue mechanism [2]. Therefore, worker_process_init completes its execution before the child processes are ready to receive and execute tasks, and it operates independently of the main process's broker connection lifecycle [2]. 3. Development Constraint: Handlers attached to the worker_process_init signal must not block for more than 4 seconds [1][5]. If a handler takes longer, the worker assumes the child process failed to start and will kill it [1][5]. In summary, worker_process_init is a child-process-specific hook that runs during the boot phase of pool workers, long before they start consuming tasks, and it is entirely separate from the main process's broker connection logic [1][2].
Citations:
🏁 Script executed:
Repository: rootflo/wavefront
Length of output: 1875
🏁 Script executed:
Repository: rootflo/wavefront
Length of output: 1155
🏁 Script executed:
Repository: rootflo/wavefront
Length of output: 9143
Patch Azure Redis auth at module import.
worker_process_initonly runs in pool children, so the main worker process can open the Redis broker/backend connection before this monkey-patch applies. Callpatch_redis_for_azure()at import time and keep the signal handler for child processes.🤖 Prompt for AI Agents