Skip to content

fix(runs): Remove containers left by a cancelled create - #256

Merged
nfebe merged 1 commit into
mainfrom
fix/runs-create-leak
Nov 9, 2026
Merged

nfebe merged 1 commit into
mainfrom
fix/runs-create-leak

Conversation

@nfebe

@nfebe nfebe commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

A run cancelled or timed out while its container was being created left that container behind until the agent restarted. Creation now finishes before the cancellation applies, and anything it made is removed.

A run cancelled or timed out while its container was being created left
that container behind until the agent restarted. Creation now finishes
before the cancellation is applied, and anything it made is removed.
@sourceant

sourceant Bot commented Nov 9, 2026

Copy link
Copy Markdown

Code Review Summary

Container creation is now wrapped so it finishes under a detached, one-minute-bounded context even when the caller's context ends, then fails with the caller's context error and destroys whatever the daemon created. A pre-flight context check avoids contacting the daemon at all when the caller is already done. Firecracker's root-image preparation uses the same wrapper, so its container is cleaned up too. Tests exercise cancellation reaching the daemon across both runtimes.

🚀 Key Improvements

  • Orphaned containers from cancelled creates are destroyed via DestroyByID instead of waiting for an agent restart.
  • Already-cancelled calls short-circuit before the daemon is contacted.
  • Firecracker root-image creation inherits the same cleanup path.

📉 Regressions

  • A create cancelled mid-flight now blocks until the daemon call finishes, up to one minute, before returning.

@sourceant sourceant Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review complete. See the overview comment for a summary.

@nfebe
nfebe merged commit a77407d into main Nov 9, 2026
6 checks passed
@nfebe
nfebe deleted the fix/runs-create-leak branch November 9, 2026 14:52
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.

1 participant