Delete should also attempt graceful stop before hard kill#109
Delete should also attempt graceful stop before hard kill#109sjmiller609 wants to merge 5 commits intomainfrom
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
| if !gracefulShutdown { | ||
| log.DebugContext(ctx, "graceful shutdown before delete did not complete", "instance_id", id) | ||
| } | ||
| } |
There was a problem hiding this comment.
Delete flow leaks gRPC connection back into pool
Low Severity
Step 3 calls guest.CloseConn(dialer.Key()) to remove the pooled gRPC connection before killing the hypervisor. But step 4's tryGracefulGuestShutdown then calls guest.ShutdownInstance, which calls guest.GetOrCreateConn, creating a new connection and adding it back into connPool. After the instance is deleted, this new connection is never removed from the pool. Each delete of a running instance leaks one gRPC connection entry (with associated reconnection goroutines) that accumulates for the lifetime of the server process.


Summary
resolveStopTimeoutTesting
I asked how well does existing testing cover this
Note
Medium Risk
Touches instance lifecycle shutdown/delete paths and adds SIGKILL/Wait4 logic, which could affect VM termination and resource cleanup if edge cases are missed. CI now enforces
gofmt, reducing risk of formatting-only drift but not validating runtime behavior.Overview
Updates instance lifecycle behavior so
deleteattempts a graceful guest shutdown (via the guest-agent) when the VM isRunning, using a centrally resolved stop timeout.Refactors stop/delete to share
resolveStopTimeout+tryGracefulGuestShutdown, reduces the default stop timeout to 5s, and strengthens stop fallback behavior to shut down the hypervisor then SIGKILL/reap the process if it is still alive; docs are updated to reflect this.Adds a CI step on Linux and macOS to fail builds on unformatted Go code (
gofmt -l), with the remainder of the diff being formatting-only changes.Written by Cursor Bugbot for commit edf0161. This will update automatically on new commits. Configure here.