Skip to content

Clean up Firecracker TAP on stop - #493

Open
DarkaMaul wants to merge 12 commits into
mainfrom
codex/fix-stop-network-cleanup
Open

DarkaMaul wants to merge 12 commits into
mainfrom
codex/fix-stop-network-cleanup

Conversation

@DarkaMaul

Copy link
Copy Markdown
Contributor

Summary

coop stop now removes the instance’s TAP device after Firecracker exits. If Firecracker survives SIGKILL, stop returns an error and leaves the network in place rather than reporting a successful shutdown.

Testing

  • Added a Linux integration check that verifies the TAP exists before stop and is removed afterward.
  • Tested on a dropkit.

Comment thread src/backend.rs Outdated
Comment thread src/backend.rs Outdated
@hbrodin

hbrodin commented Sep 28, 2026

Copy link
Copy Markdown
Collaborator

Review summary: I left 2 inline findings on Firecracker TAP cleanup: a failed TAP deletion is reported as a successful stop, and an already-exited Firecracker instance bypasses the new cleanup path.

I reviewed correctness, security, design, conventions, tests, documentation, comments, and API usage. git diff --check and bash -n on the PR integration script passed. The PR checks passed, but the full Firecracker and Lima VM integration suites were not run in this review and are not among the PR checks. There was no earlier review feedback to carry forward.

Comment thread src/config.rs Outdated

@hbrodin hbrodin left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Follow-up review using the updated review, lifecycle, and path/trust guidance on current main. That guidance prompted a fresh check of failure paths and claims after the recent PR fixes, which surfaced the three inline issues below. I checked the new PID/socket paths against the filesystem trust guidance and found no supported guest-derived path escape. git diff --check and bash -n passed; I did not run the Firecracker or Lima VM integration suites.

Comment thread src/commands/lifecycle.rs Outdated
Comment thread src/commands/lifecycle.rs Outdated
Comment thread CHANGELOG.md Outdated
Comment thread src/config.rs
// curl exit 7 means it could not connect. With the probe running as
// root, this covers a missing listener without conflating it with the
// ordinary user's lack of write permission on the socket.
Some(7) => Ok(()),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Could we avoid treating curl exit 7 as proof that Firecracker has exited? I reproduced exit 7 with these curl flags against a live Unix listener whose accept queue was full. If this instance's PID file is missing or stale, both liveness probes can therefore return stopped, and coop stop removes its proxy credentials and TAP while the VM is still running.

A privileged probe that preserves the connect(2) error would distinguish a refused or missing socket from a busy listener: accept only ECONNREFUSED/ENOENT as confirmed exit, and leave EAGAIN, timeouts, and other failures uncertain. Please add a regression with a live listener and full accept queue that verifies stop retains the proxy and TAP; the current live-socket test has an empty queue, while the integration case kills Firecracker first.

@hbrodin

hbrodin commented Oct 2, 2026

Copy link
Copy Markdown
Collaborator

I left one inline finding on the Firecracker socket probe: curl exit 7 can also come from a live Unix listener with a full accept queue. I reproduced that result with the probe's curl flags. The proposed fix is to preserve the underlying connection error and keep uncertain states from authorizing TAP and proxy teardown.

I reviewed correctness, security, API usage, tests, design, conventions, docs, and comments on head 0c4b59c. git diff --check and bash -n passed. I did not run the Firecracker or Lima VM integration suites; they are not among this PR's CI checks. Earlier inline feedback appears addressed, apart from this new edge in the socket-probe fix.

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.

2 participants