Repository navigation
feat(backend): run the task manager background services with the retention settings [INFP-507] - #10878
Closed
saltas888 wants to merge 13 commits into
Closed
feat(backend): run the task manager background services with the retention settings [INFP-507]#10878saltas888 wants to merge 13 commits into
saltas888 wants to merge 13 commits into
Conversation
2 of 5 tasks
saltas888
force-pushed
the
background-services-infp-507
branch
from
October 4, 2026 20:04
872ed77 to
35ded9c
Compare
This was referenced Oct 4, 2026
saltas888
force-pushed
the
background-services-infp-507
branch
from
October 4, 2026 21:19
35ded9c to
2905c9b
Compare
saltas888
force-pushed
the
background-services-infp-507
branch
from
October 8, 2026 12:28
2905c9b to
4e158c2
Compare
saltas888
force-pushed
the
background-services-infp-507
branch
from
October 8, 2026 12:55
4e158c2 to
5a2a4b4
Compare
saltas888
force-pushed
the
background-services-infp-507
branch
from
October 8, 2026 13:42
5a2a4b4 to
744177d
Compare
saltas888
force-pushed
the
background-services-infp-507
branch
2 times, most recently
from
October 11, 2026 20:04
825ed41 to
cc05cd4
Compare
saltas888
force-pushed
the
background-services-infp-507
branch
2 times, most recently
from
October 13, 2026 15:35
0be0f2f to
d1cfdc1
Compare
saltas888
force-pushed
the
background-services-infp-507
branch
from
October 14, 2026 13:26
d1cfdc1 to
b17e26e
Compare
saltas888
force-pushed
the
background-services-infp-507
branch
from
October 27, 2026 22:07
b17e26e to
abb9860
Compare
3 of 5 tasks
The command loads the Infrahub configuration from its CONFIG_FILE argument, applies the task manager retention to Prefect's settings the same way the task manager app factory does, then runs Prefect's `prefect server services start` entry point in the foreground, in the same process, so the services read the derived settings. The task manager environment fixture moves to a shared helper so the factory and command tests use the same isolation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…Infrahub `task-manager-background-svc` now runs `infrahub tasks background-services`, so the services apply the task manager retention like the task manager does. Both the task manager and the background services pass the three `INFRAHUB_TASK_MANAGER_RETENTION_*` variables through from the environment; when they are unset, the Infrahub defaults apply. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tch as done Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…er's own settings reader The command now passes the configuration file as a path to the reader that the task manager uses, which reads only the task_manager section. Its tests use the shared isolation of the retention tests and expect the empty per-type overrides that the default retention now logs. The task manager's message for PREFECT__SERVER_WEBSERVER_ONLY now names `infrahub tasks background-services` and is logged at INFO level, because a correct setup with the services in their own process also logs it. The changelog and the spec say the same. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UwJNFw8rccyxc4Wp9eZFbH
…round-services command Every infrahub command imported prefect.cli.server at startup, which loads Prefect's command-line framework (cyclopts and about 40 modules), although only `infrahub tasks background-services` uses it. The command now imports it when it runs. The Prefect server API still loads for every command, so the retention helper stays a module-level import. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UwJNFw8rccyxc4Wp9eZFbH
…e services start with The log lines that the command printed were already asserted by the task manager's own startup tests, and three of the four settings by its settings test. The command's test now checks only what the command adds: the services start once, with the retention of the file it is given. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UwJNFw8rccyxc4Wp9eZFbH
…guration file it is given A mistyped CONFIG_FILE on the command line was read as an empty file, so the services started with the default retention and deleted task runs older than 30 days. A path given on the command line must now be an existing file, or the command prints `Configuration file not found: <path>` and exits with code 1 before it changes any Prefect setting. The file that INFRAHUB_CONFIG names, or the default infrahub.toml, may still be absent, as for the task manager, because deployments such as the test compose files set every value in the environment. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UwJNFw8rccyxc4Wp9eZFbH
…mmand through the CLI The test ran the real command, so only the configuration validation kept it from starting Prefect's services, which run until they are stopped and write to Prefect's home directory. It now calls the function the command delegates to with a recording starter and asserts that the services did not start. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UwJNFw8rccyxc4Wp9eZFbH
…-services command The command runs under Infrahub's logging, which leaves the root logger at INFO, and docket, which runs Prefect's services, logs two INFO lines for every run of every service, about three lines a second. `prefect server services start` printed none of them. The command now sets the docket logger to WARNING after it applies the retention, so its log keeps the retention lines and docket's warnings and errors. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UwJNFw8rccyxc4Wp9eZFbH
…nit-test conftest The command-line tests and the task manager startup tests each defined the same fixture around the shared isolation helper. It now lives once in the unit-test conftest. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UwJNFw8rccyxc4Wp9eZFbH
The group was hidden when it held only internal commands. It now holds the background-services command that deployments run as a service and the flush commands that the upgrade points to, so `infrahub --help` lists it, and the group and its flush subgroup get descriptions. The execute command gets a description of what it does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UwJNFw8rccyxc4Wp9eZFbH
…en for earlier images The separate background-services container now runs `infrahub tasks background-services`, which images released before this command do not have, so the container exited and restarted in a loop. INFRAHUB_TESTING_TASKMGR_BACKGROUND_SVC_COMMAND now replaces the command, as PREFECT_SERVER_COMMAND already does for the task manager, so an earlier image can run `prefect server services start`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UwJNFw8rccyxc4Wp9eZFbH
…k manager containers The task manager and the separate background-services container write Infrahub log lines, but unlike the API server and the task workers they did not receive INFRAHUB_PRODUCTION or INFRAHUB_LOG_LEVEL, so they wrote JSON at INFO whatever the test stack selected. Both now take the values from INFRAHUB_TESTING_PRODUCTION and INFRAHUB_TESTING_LOG_LEVEL, and a unit test checks every Infrahub container in both compose files. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UwJNFw8rccyxc4Wp9eZFbH
saltas888
force-pushed
the
background-services-infp-507
branch
from
October 28, 2026 18:23
abb9860 to
e558115
Compare
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.
Why
Deployments that scale the task manager out run Prefect's background services (the cleanups, the event persister) in a separate container with
prefect server services start. That command never loads Infrahub's configuration, so thetask_manager.retentionsettings do not reach the services that enforce them: the flow-run cleanup stays off and events follow Prefect's defaults.Closes part of INFP-507.
What changed
infrahub tasks background-services [CONFIG_FILE]. It loads Infrahub's configuration, applies the same derived Prefect settings as the task manager (same code path: a pre-setPREFECT_*variable wins with a warning, an invalid retention stops it), refreshes Prefect's settings, logs the values in effect, then calls Prefect's ownstart_services()in the same process, asprefect server services startdoes.python_testcontainers/.../docker-compose.test.ymlanddocker-compose-cluster.test.yml) run the new command fortask-manager-background-svc, and pass the threeINFRAHUB_TASK_MANAGER_RETENTION_*variables through to that service and totask-manager.apply_infrahub_settings_to_prefecttakes an optional configuration file, so the command and the task manager share it.Behaviour to note: the background services now log through Infrahub's logging at
INFRAHUB_LOG_LEVEL(INFO by default) instead of Prefect's WARNING, which adds about two scheduler lines every 5 seconds in that container.The Helm chart change (the background-services deployment runs this command, retention values in
values.yaml) is opsmill/infrahub-helm#100, a draft until the chart's images move to Infrahub 1.13; the chart's upgrade hook needs no extra option.How to test
Checked on a scale-out test stack (
INFRAHUB_TESTING_TASKMGR_SCALEOUT=1, image built from this branch,INFRAHUB_TASK_MANAGER_RETENTION_TASK_HISTORY=12d): thetask-manager-background-svccontainer raninfrahub tasks background-services, loggedTask manager retention: PREFECT_SERVER_SERVICES_DB_VACUUM_RETENTION_PERIOD=P12D, and scheduledvacuum_old_flow_runs, which Prefect does not run by default;test_prefect_event_types.pypassed on that stack./pre-cipassed.Impact & rollout
prefect server services startthemselves should switch toinfrahub tasks background-services(changelog).Checklist
🤖 Generated with Claude Code