Status: Accepted
Date: 2026-10-14
Source: specs/archive/022-post-render-container-overrides/ (spec, plan, research D-001 to D-012, contracts); issue #457
Supersedes: ADR-045 §2 (the empty-list
marker and the chart {{- with }} guard) and §5 (the null clear marker for charts without that
guard). Both described how a driver template passed command and args to the chart, and no
template does that any more.
Keeps: ADR-045 §1 (component scope only, no layering), §3 (per-field typed errors) and §4 (a
set value is a non-empty list of strings; [] is rejected).
Extends: ADR-058 to command and
args. The strategic-merge patch and the JSON6902 guard that ADR-058 builds for env vars and image
overrides now also carry these two fields, so a wrong container name fails the reconcile with
COMPONENT_CONTAINER_NOT_FOUND also when command or args is the only override.
Related: ADR-057 (the component container, §3 patch
order, §4 retired-filter precedent, §6 per-key replace on update); the user migration guide
Migrating Container Overrides.
A user can set a container override: the command or args of one component in one deployment.
Before this change, the override reached the pod only when the driver's values.j2.yml passed the
component_command or component_args filter to a value that the Helm chart exposes
(ADR-045 §2 and §5). This had three effects:
- When a driver did not call the filters, Styrmin stored the override, did not apply it and reported no error. The deployment edit drawer showed the Command and Args editors for every component.
- A user could override only the fields that the chart exposes as values. The infrahub chart has no
commandvalue, so theserverandtask-workercomponents of theinfrahubandinfrahub-enterprisedrivers acceptedargsonly. - Each driver author wrote template code that matched how the chart reads the value, so that the
chart's own value applied when no override was set: an empty list for
simple-app, whose chart skips an empty list, andnullfor the infrahub charts, which renderargswithout a check.
Env vars (ADR-057) and image overrides (ADR-058) already reached pods through post-render patches
to the component container that the driver declares, with no template code. command and args
were the only per-component container overrides left on the values template.
ContainerEnvPatch is renamed ContainerMergePatch
(agent/service/kubernetes/resources/blocks/patches.py) and gains command: list[str] | None and
args: list[str] | None next to env. The patch names the component container and writes each
field only when it is set, so a field without an override keeps the value the chart renders. The
JSON6902 guard ComponentContainerPatch and the order inside spec.postRenderers do not change
(ADR-057 §3, ADR-058 §3).
command and args are lists of strings with no patchMergeKey in the Kubernetes schema, so
kustomize's strategic merge replaces the whole list. This was checked on 2026-10-14 with
kubectl kustomize (kustomize v5.7.1) on a Deployment with an init container, a sidecar and the
component container, with the guard applied after the merge:
- an
argspatch replaced the wholeargslist of the component container and kept the chart'scommand; - the sidecar and the init container did not change;
- the component container moved to
containers[0]; - the strings
'yes','8000','','null'and$(HOME)came out as the same strings; - a wrong container name failed the render at the guard, which
parse_guard_failurereads asCOMPONENT_CONTAINER_NOT_FOUND.
The patch is serialised with yaml.dump only. User strings are never formatted into YAML text, so
a value that contains a newline and - op: remove stays one list element and cannot add patch
operations.
services/component_container/overrides.py holds the rule and the value it produces:
override_applies(container, is_orphaned)returns true only when the component declares a component container and the override is not orphaned.ApplicableOverridesis a frozen dataclass withenv,image,commandandargs, and anis_emptyproperty.applicable_overrides(name, component, version)builds that value from aComponentContext, with every override checked byoverride_applies. The image override has{{ app.version }}replaced byversionand is validated, as before. It replacesapplicable_envandapplicable_image.
The patch builder and the action primitives (get_component_images, execute_commands) call
applicable_overrides. The GraphQL read fields ComponentEnvVars.isApplicable,
ComponentImageOverride.isApplicable and the new ComponentContainerOverrides.isApplicable call
override_applies with the deployment's component container and the entry's orphan flag, because
the read path has no ComponentContext.
execute_commands(env_from_component=...) now also resolves the image override when it reads the
env vars, so an image reference that is invalid at the context's application version raises
InvalidImageReferenceError there. Such a reference is already rejected on write and before an
application version change (ADR-058 §5), so the sources expect no new failure in practice.
build_component_container_patches builds the merge patch and the guard for a component when
applicable_overrides(...).is_empty is false. A component whose only override is command or
args therefore gets the guard, and a wrong container name fails the reconcile with
COMPONENT_CONTAINER_NOT_FOUND (spec FR-004). The log line records command_set and args_set as
booleans and never the values, because args often carry flags such as --password=....
A cleared override needs no marker. The patches are built again on every render; with no stored
value the field is not in the merge patch, or no patch is built when nothing else applies, so the
chart's own command and args reach the pod. The change to spec.postRenderers reaches the
HelmRelease because the operator replaces each spec key it writes on update (ADR-057 §6). The E2E
run recorded in specs/archive/022-post-render-container-overrides/e2e-evidence.md read the container
after a clear and found the values captured before any override was set; the operator's change
detection needed no fix (research D-012).
Both filters stay registered in get_jinja_environment() as stubs that raise
RetiredTemplateFilterError (RETIRED_TEMPLATE_FILTER, metadata filter and migration_guide),
as component_env_vars does (ADR-057 §4). The helper _resolved_container_override is deleted.
RetiredTemplateFilterError builds its message from the filter name. For the two container
override filters the message tells deployment users to move the deployment to a driver version
that no longer calls the filter, tells driver authors to remove the filter call and declare
components.<name>.container, and links CONTAINER_OVERRIDES_MIGRATION_GUIDE_URL
(https://docs.styrmin.app/docs/drivers/migrating-container-overrides, in
services/exceptions.py). The component_env_vars message and URL do not change.
The stubs raise whatever the context holds, so a driver version that calls them fails its next
render also when no override is set. The operator records Failed to create HelmRelease: <message> and applies no HelmRelease, so the pods that run keep running. There is no deprecation
period, because Styrmin is before version 1.0 and few third-party drivers exist (spec A-003).
A driver version that calls a retired filter is also rejected when it is loaded (added after the PR
review). JinjaTemplateValidator (services/driver/validators.py) walks the Filter nodes of the
parsed values.j2.yml, also inside conditions and filter blocks, and raises
RetiredTemplateFilterError with retired_filter_load_message(), which names the line of the call.
This covers component_env_vars too. The render-time stubs stay registered for driver versions
loaded before this check.
In services/deployment.py:
ComponentContainerSlot(now inservices/env_vars/exceptions.py) isLiteral["env_vars", "image", "command", "args"], and_validate_component_container_targetschecks all four slots by default._slot_adds_or_changestreatscommandandargslikeimage: a write adds or changes the slot when the submitted value is notNoneand differs from the stored value. A removal (nullor an omitted key) and the same list sent again pass.ComponentContainerNotDeclaredErroracceptsoverride="command"andoverride="args", and its message names the field.
The order of checks does not change: unknown component and list shape first, the container check
last, on deploy, updateDeployment and updateDeploymentVersion. The SDK, styrminctl apply
and the UI call these mutations, so they get the same check. The check reads the driver version
that the deployment is pinned to after the write.
The block only documented which components accepted an override; the component container now answers that question. It is removed from the driver format, the database and the API:
Specificationno longer has the field. A driver file that still contains the block fails to load: abeforemodel validator raises aremoved_keyerror that names the block and linksCONTAINER_OVERRIDES_MIGRATION_GUIDE_URL(changed after the PR review from the genericextra_forbiddenerror, which named neither). Other unknown keys underspeckeep the generic error. The old validator, its loader call andDriverContainerOverrideDocComponentMismatchError(DRIVER_CONTAINER_OVERRIDE_DOC_COMPONENT_MISMATCH) are deleted.- The Alembic revision
faf47e166160dropsapplicationdriverversion.container_overrides. Its downgrade adds the column back, nullable and empty. - GraphQL loses
ApplicationDriverVersion.containerOverridesand theDriverContainerOverrideDoctype, and the SDK losesget_driver_container_override_docs.
No error code is added (spec FR-011).
- A driver needs no template code for
commandandargs; declaring the component container is enough. A user can overridecommandon the infrahubserverandtask-workercomponents, which the old templates could not pass. - The example drivers moved to new versions:
simple-app3,infrahub4 andinfrahub-enterprise3. A deployment pinned to an older version of these drivers fails its next render until it moves to a migrated version. - Some stored overrides apply for the first time after the move, for example
commandon the infrahubservercomponent, or any stored value on a driver whose template never called the filters. The migration guide tells users to review stored values before the move. - An override reaches the component container only. Other containers, init containers, and
Job,CronJobandDaemonSetworkloads are not patched. In the in-repo charts thecommandandargsvalues reached only the component container (spec A-002), so stored overrides give the same containercommandandargsbefore and after the move. The parity testbackend/tests/integration/test_container_override_migration_parity.pychecks this for the three example drivers. - Once any override applies, the component container is
containers[0], which changes the default container ofkubectl logsfor pods with several containers (ADR-057 §3). - An empty list is still rejected, so an override cannot remove the chart's
commandto fall back to the image'sENTRYPOINT. - The deployment edit drawer shows the Command and Args editors only on a component with a component container. A stored value on a component without one is shown read-only with a not applied badge and can be removed.
styrminctl deployments applyreadsisApplicableback for env vars, image overrides andcommand/argsoverrides, and warns about a component whose submitted overrides do not apply.- The action primitives use the env vars and the image override from
applicable_overrides.commandandargsoverrides do not reach action Jobs. - Rolling Styrmin back below this change after loading migrated drivers stops container overrides: the older release applies them only through the filters, which the migrated templates no longer call. The stored values are kept.
- The
prune_none_on_createflag that ADR-045 §5 added to the HelmRelease apply is unchanged. - The list replacement is observed kustomize behaviour, not a documented contract. The E2E reads the pod template after set, change and clear on the helm-controller that the agent chart installs.
- JSON6902
addoperations for/commandand/argsinside the guard patch. RFC 6902addreplaces an existing member, so this also works. Rejected because it puts value overrides into the guard, which only moves and checks the container, and because the PRD chose the merge patch. - A separate strategic-merge patch per field. Rejected: more patches per workload with no gain.
- Keeping the name
ContainerEnvPatch. Rejected: the name would describe one of three fields. - Adding
applicable_commandandapplicable_argsnext toapplicable_envandapplicable_image. Rejected: four copies of the same condition. - Building a
ComponentContextin the GraphQL read fields. Rejected: the read path would need the whole rendering context for one boolean. - Unregistering the two filters. Rejected: Jinja would fail with "No filter named ...", which names no migration guide.
- Keeping the template route and fixing drivers one at a time. Rejected for the reasons in the Context: a driver that does not call the filters stores overrides without applying them, and each driver repeats chart-specific template code.
The spec leaves these out; no decision was taken on them:
- removing a
commandorargsthat the chart renders, so that the image'sENTRYPOINTorCMDapplies; - overrides on init containers, other containers, or
Job,CronJobandDaemonSetworkloads; - more than one component container per component;
- environment-scope or deployment-scope
commandandargs; - a UI or CLI list of the overrides that start to apply after the move to a migrated driver version;
- a way to find the deployments pinned to driver versions that call the retired filters;
{{ app.version }}substitution incommandandargs.