Files
compose/pkg
Guillaume Lours 54785c4be6 feat(hooks): clean up retained pre_start containers on compose down
A pre_start hook container retained after failure (introduced in the
previous commit) is created without ConfigHashLabel so getContainers()
and every downstream compose operation (down, ps, stop, rm) is blind
to it. Without explicit cleanup it would survive compose down.

This commit adds removePreStartHookContainers(), called from down()
after regular container teardown and before network removal (so hook
containers are gone before their networks are removed). The cleanup is
project-wide on a full compose down; scoped to the requested services
when compose down <svc...> is used. Individual ContainerRemove errors
are logged at warn level and do not abort the teardown.

Changes:
- pkg/compose/down.go: removePreStartHookContainers helper + call in down()
- pkg/compose/filters.go: add //nolint:unparam to hookFilter (param is
  architecturally correct; today only preStartHookType is in use)
- pkg/compose/down_test.go: update all existing down tests to expect the
  new ContainerList call; add TestDownRemovesRetainedPreStartHookContainers
  and TestDownHookContainerRemovalFailureIsNonFatal

Signed-off-by: Guillaume Lours <[email protected]>
2026-08-20 18:57:02 +02:00
..