Skip to content

feat(testcontainers): configure Prefect docket URL for task-manager scaleout#9555

Draft
fatih-acar wants to merge 1 commit into
release-1.10from
fac-prefect-docket
Draft

feat(testcontainers): configure Prefect docket URL for task-manager scaleout#9555
fatih-acar wants to merge 1 commit into
release-1.10from
fac-prefect-docket

Conversation

@fatih-acar

@fatih-acar fatih-acar commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

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):

  • Docket URL: when INFRAHUB_TESTING_TASKMGR_SCALEOUT is enabled, PREFECT_SERVER_DOCKET_URL now points at the cache Redis on db 2 (messaging uses db 1) for both the task-manager API process and the task-manager-background-svc replicas. Without it each process runs its own memory:// docket, which Prefect documents as causing duplicate scheduled runs and duplicate automation actions.
  • Service separation cleanup: drops the per-service PREFECT_SERVER_SERVICES_*_ENABLED toggles. PREFECT__SERVER_WEBSERVER_ONLY (the switch prefect server start --no-services toggles internally) already disables all background services on the API process, and prefect server services start runs them with their default enabled state. Note event_logger (debug-only, disabled by default upstream) is no longer force-enabled.

In the compose files the API service keeps PREFECT_SERVER_DOCKET_URL as a passthrough, so non-scaleout runs keep the default memory:// docket.

Verification

  • Both compose files parse and place the env vars on the right services (PyYAML structural check); container.py passes a syntax check.
  • docker compose config failures 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 testcontainers task-manager scaleout so the API and background services share one docket. This prevents duplicate scheduled runs and automation actions.

  • New Features

    • Set PREFECT_SERVER_DOCKET_URL to redis://cache:6379/2 (db 2) when INFRAHUB_TESTING_TASKMGR_SCALEOUT is enabled for the API and background replicas.
    • In compose, keep PREFECT_SERVER_DOCKET_URL passthrough on the API so non-scaleout runs stay on memory://.
  • Refactors

    • Remove PREFECT_SERVER_SERVICES_*_ENABLED flags; rely on PREFECT__SERVER_WEBSERVER_ONLY and default service behavior.
    • Stop force-enabling event_logger (debug-only).

Written for commit 19ebe43. Summary will update on new commits.

Review in cubic

…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>

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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>

@fatih-acar

Copy link
Copy Markdown
Contributor Author

Related to #9132

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