feat(testcontainers): configure Prefect docket URL for task-manager scaleout#9555
Draft
fatih-acar wants to merge 1 commit into
Draft
feat(testcontainers): configure Prefect docket URL for task-manager scaleout#9555fatih-acar wants to merge 1 commit into
fatih-acar wants to merge 1 commit into
Conversation
…caleout Point PREFECT_SERVER_DOCKET_URL at the cache Redis (db 2, next to messaging on db 1) so all Prefect pods share a Redis-backed docket when background services run separately. Without it each process uses its own memory:// docket, which Prefect documents as causing duplicate scheduled runs and duplicate automation actions. Drop the per-service PREFECT_SERVER_SERVICES_*_ENABLED toggles: PREFECT__SERVER_WEBSERVER_ONLY already disables all background services on the API process, and 'prefect server services start' runs them with their default enabled state (event_logger, debug only, is no longer force-enabled). ref: https://docs.prefect.io/v3/advanced/self-hosted Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: Fatih Acar <fatih@opsmill.com>
Contributor
There was a problem hiding this comment.
1 issue found across 3 files
Confidence score: 4/5
- In
python_testcontainers/infrahub_testcontainers/container.py, storing the new Docker URL in a global mutable env dict can bleed state into later non-scaleout runs in the same process, which may cause cross-test contamination or flaky behavior after merge; scope this value to the container/run instance (or restore/reset the global env after use) before merging.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="python_testcontainers/infrahub_testcontainers/container.py">
<violation number="1" location="python_testcontainers/infrahub_testcontainers/container.py:169">
P2: The new docket URL is stored in a global mutable env dict, so it can leak into later non-scaleout runs in the same process.</violation>
</file>
Shadow auto-approve: would not auto-approve because issues were found.
Re-trigger cubic
| "PREFECT_SERVER_SERVICES_EVENT_PERSISTER_ENABLED": "false", | ||
| "PREFECT_SERVER_SERVICES_TRIGGERS_ENABLED": "false", | ||
| "PREFECT_SERVER_SERVICES_TASK_RUN_RECORDER_ENABLED": "false", | ||
| "PREFECT_SERVER_DOCKET_URL": "redis://cache:6379/2", |
Contributor
There was a problem hiding this comment.
P2: The new docket URL is stored in a global mutable env dict, so it can leak into later non-scaleout runs in the same process.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At python_testcontainers/infrahub_testcontainers/container.py, line 169:
<comment>The new docket URL is stored in a global mutable env dict, so it can leak into later non-scaleout runs in the same process.</comment>
<file context>
@@ -166,10 +166,7 @@ def create_env_file(self, directory: Path, version: str) -> Path:
- "PREFECT_SERVER_SERVICES_EVENT_PERSISTER_ENABLED": "false",
- "PREFECT_SERVER_SERVICES_TRIGGERS_ENABLED": "false",
- "PREFECT_SERVER_SERVICES_TASK_RUN_RECORDER_ENABLED": "false",
+ "PREFECT_SERVER_DOCKET_URL": "redis://cache:6379/2",
}
)
</file context>
Contributor
Author
|
Related to #9132 |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Applies the Prefect self-hosted scaling guidance to the testcontainers task-manager scaleout setup (same change as opsmill/infrahub-helm#68 for the enterprise chart presets):
INFRAHUB_TESTING_TASKMGR_SCALEOUTis enabled,PREFECT_SERVER_DOCKET_URLnow points at the cache Redis on db 2 (messaging uses db 1) for both the task-manager API process and thetask-manager-background-svcreplicas. Without it each process runs its ownmemory://docket, which Prefect documents as causing duplicate scheduled runs and duplicate automation actions.PREFECT_SERVER_SERVICES_*_ENABLEDtoggles.PREFECT__SERVER_WEBSERVER_ONLY(the switchprefect server start --no-servicestoggles internally) already disables all background services on the API process, andprefect server services startruns them with their default enabled state. Noteevent_logger(debug-only, disabled by default upstream) is no longer force-enabled.In the compose files the API service keeps
PREFECT_SERVER_DOCKET_URLas a passthrough, so non-scaleout runs keep the defaultmemory://docket.Verification
container.pypasses a syntax check.docker compose configfailures are pre-existing unset-variable issues, reproduced identically on the unmodified files.🤖 Generated with Claude Code
Summary by cubic
Configure the Prefect server docket to use Redis in the
testcontainerstask-manager scaleout so the API and background services share one docket. This prevents duplicate scheduled runs and automation actions.New Features
PREFECT_SERVER_DOCKET_URLtoredis://cache:6379/2(db 2) whenINFRAHUB_TESTING_TASKMGR_SCALEOUTis enabled for the API and background replicas.PREFECT_SERVER_DOCKET_URLpassthrough on the API so non-scaleout runs stay onmemory://.Refactors
PREFECT_SERVER_SERVICES_*_ENABLEDflags; rely onPREFECT__SERVER_WEBSERVER_ONLYand default service behavior.event_logger(debug-only).Written for commit 19ebe43. Summary will update on new commits.