Skip to content

fix(render): stop every function runtime and always remove Remove-policy containers - #404

Draft
jcogilvie wants to merge 1 commit into
crossplane:mainfrom
jcogilvie:jco/render-robust-stop
Draft

jcogilvie wants to merge 1 commit into
crossplane:mainfrom
jcogilvie:jco/render-robust-stop

Conversation

@jcogilvie

Copy link
Copy Markdown
Collaborator

Description of your changes

Makes function runtime cleanup robust so one failing or slow runtime can't leave others (or their containers) behind:

  • FunctionAddresses.Stop now attempts every runtime and returns all failures joined (each still wrapped with the function name and target), instead of returning on the first error.
  • StopFunctionRuntimes gives each runtime its own 30s timeout rather than one shared 5s budget, which was shorter than Docker's default 10s stop grace period. Its exported signature is unchanged.
  • The Docker Remove cleanup policy now does a single ContainerRemove with Force: true (kill + remove), so a container slow to exit on SIGTERM can no longer cause removal to be skipped. Stop and Orphan semantics are unchanged.
  • Doc-comment fix: the comments claimed Stop is the default cleanup policy; Remove is (AnnotationValueRuntimeDockerCleanupDefault).

Tested with a new unit test, TestFunctionAddressesStop, which stops a map of fake runtimes (some failing) across many iterations so map ordering can't hide a regression, and asserts every runtime was stopped and every failure is reported. There's no existing seam for the Docker stop closure, so it isn't unit tested.

Fixes #397

I have:

  • Read and followed Crossplane's contribution process.
  • Run ./nix.sh flake check to ensure this PR is ready for review. (nix isn't available locally; ran go build ./..., go test ./cmd/crossplane/render/..., and golangci-lint run ./cmd/crossplane/render/... instead, all clean.)
  • Added or updated unit tests.
  • Linked a PR or a docs tracking issue to document this change.
  • Added backport release-x.y labels to auto-backport this PR.

Need help with this checklist? See the cheat sheet.

🤖 Generated with Claude Code

…icy 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,
shorter than Docker's default 10s stop grace period. A container slow to
exit on SIGTERM made ContainerStop fail and the following ContainerRemove
was skipped. Each runtime now gets its own 30s timeout, and the Remove
cleanup policy uses a single forced ContainerRemove, which kills and
removes the container in one call.

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>
@jcogilvie
jcogilvie force-pushed the jco/render-robust-stop branch from 1df3916 to d46f858 Compare October 1, 2026 22:08
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: stopping Function runtimes aborts on the first error, and the shared 5s budget skips container removal

1 participant