Skip to content

fix(render): warn on stderr when function runtimes can't be cleaned up - #402

Draft
jcogilvie wants to merge 2 commits into
crossplane:mainfrom
jcogilvie:jco/render-report-cleanup-failures
Draft

jcogilvie wants to merge 2 commits into
crossplane:mainfrom
jcogilvie:jco/render-report-cleanup-failures

Conversation

@jcogilvie

@jcogilvie jcogilvie commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

Description of your changes

Stacked on #404; only the top commit is new.

render xr/op reported cleanup failures only via log.Info, which is a no-op without --verbose, so leaked containers went unnoticed. They now also print to stderr:

warning: failed to clean up function runtimes; some resources (e.g. containers) may need to be removed manually: <err>

via a small exported render.WarnCleanupFailure(w, err), used by both command packages. Exit code is unchanged.

Fixes #399

I have:

Need help with this checklist? See the cheat sheet.

🤖 Generated with Claude Code

jcogilvie and others added 2 commits October 12, 2026 17:43
… Remove-policy containers

FunctionAddresses.Stop returned on the first runtime Stop error, leaving
the remaining runtimes running. It now attempts every runtime and returns
all failures joined.

StopFunctionRuntimes shared a single 5s deadline across all runtimes, and
ContainerStop used the daemon's default 10s grace period. A container slow
to exit on SIGTERM made ContainerStop fail, and the ContainerRemove that
should follow was skipped.

The Stop and Remove cleanup policies now stop with an explicit 3s grace
period. Remove then force removes the container whether or not the stop
succeeded, so a slow SIGTERM can no longer skip removal. Removal success
means success; if removal fails, the removal and stop errors are joined.

The Docker runtime bounds its own cleanup: ContainerStop and
ContainerRemove each get their own timeout, so a stop that hangs can't
leave removal without time to run. StopFunctionRuntimes only detaches the
caller's cancellation, so cleanup still runs after the render context is
cancelled; it no longer needs to know the Docker runtime's timings.

This changes the exported signature of StopFunctionRuntimes from
(logging.Logger, *FunctionAddresses) to (context.Context,
*FunctionAddresses) error, matching other cleanup functions in the repo.
The xr and op render commands log the returned error as before.

Also correct the doc comments: Remove, not Stop, is the default cleanup
policy.

Fixes crossplane#397

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Jonathan Ogilvie <jonathan.ogilvie@sumologic.com>
StopFunctionRuntimes returns its error, but `crossplane render xr` and
`crossplane render op` only reported it via log.Info, and the CLI's logger
is a no-op unless --verbose is set. As a result both commands silently
left Function containers behind when stopping them failed.

Add WarnCleanupFailure, which writes a short warning (including the error)
to a writer and does nothing for a nil error, and call it with kong's
stderr from both commands' deferred cleanup alongside the existing log
line. The exit code is unchanged.

Fixes crossplane#399

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Jonathan Ogilvie <jonathan.ogilvie@sumologic.com>
@jcogilvie
jcogilvie force-pushed the jco/render-report-cleanup-failures branch from 030c086 to 6a10910 Compare October 12, 2026 22:15
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.

render: Function cleanup failures are invisible without --verbose

1 participant