Repository navigation
Conversation
A VMM with VFIO devices releases them on its way out, and the host driver is slower at that when many guests go down at once. The grace after SIGTERM was fixed, so deleting 16 or more vGPU guests together hard-killed them mid-release and then failed most of the deletes about a second before the VMMs were gone, leaving the instances for a retry. The grace now grows by one second for every other VFIO teardown in flight, up to a minute. A guest terminated alone waits as before.
Confirm the VMM owner before direct deletes as well as stops. Keep cleanup pending if vGPU release fails or metadata is updated, and reject start and in-place restore until the stop is complete. Resume interrupted health-check restarts without charging the same attempt twice.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Deleting 16 or more vGPU guests on one host at the same moment failed most of the deletes with a 500, about a second before their VMMs had exited. The grace a VMM with VFIO devices gets after SIGTERM now grows with the number of such teardowns in flight.
Why it happened
A delete asks the guest to shut down and waits up to 5 s, then sends the VMM SIGTERM and waits 5 s, then SIGKILL and two waits of 2 s. A VMM with VFIO devices releases them on its way out, and the host driver is slower at that when many go at once. On a host with two L40S, with 6 GB guests on a 3 GB vGPU profile, on a build of #552, which does not change how a delete stops the VMM:
SIGTERM goes out 5 s in, so the VMMs needed up to 10 s after it. SIGKILL followed at 10 s and the request gave up at 14 s. Kernel stacks sampled while they waited were in the vGPU driver, under
nv_vgpu_vfio_migration_set_stateandnv_vgpu_vfio_close; the kernel log showed no errors.Every failed delete succeeded on retry and no device was left behind. But 42 VMMs across the two forked batches were hard-killed while they were releasing their device, which is what the SIGTERM grace is there to prevent.
What changes
Stops, deletes and QEMU failed-start rollbacks now count overlapping VFIO teardowns together. Each VMM gets the base SIGTERM grace (5 s) plus one second per other teardown, up to one minute extra. The wait remembers the largest overlap it sees, including teardowns that start after SIGTERM.
Stop and delete leave 1 s for cleanup. They reserve another 4 s for the two SIGKILL waits only if the deadline can fit the full base grace and those waits. Otherwise the VMM can still exit cleanly, but a timeout does not authorize SIGKILL. After a 5 s guest shutdown, that leaves at most 20 s for SIGTERM under the 30 s TTL reaper deadline, or 50 s under the 60 s API deadline. A canceled request or a budget too short for the base grace doesn't authorize SIGKILL; the instance is retained for retry. Failed-start rollback still has to reap its child and gives it the same overlap-based grace even if startup was canceled (at most 65 s before escalation).
A failed fork gets one minute to delete the child. For a fork from a running source, restoring the source and checking its readiness share a separate two-minute budget, independent of the failed request. Stop and delete record the VMM owner and pending cleanup before signaling a VFIO guest. If the socket disappears before cleanup finishes, the instance reports
Shutdown, notStopped. A retried stop confirms exit, releases the TAP and vGPU, and savesStoppedAt, including after the server restarts.A TTL update preserves the pending stop. Start and in-place snapshot restore reject it; a failed vGPU reset returns an error so stop can retry. Startup PCI reconciliation and TAP garbage collection preserve resources owned by a pending stop. The restart controller persists a reserved start with the completed VFIO stop, so a server restart in between does not consume another attempt. During health-check recovery, restart-policy updates return
409 invalid_state; manual stop still takes precedence. See GPU downgrade instructions before rolling back.Testing
Five regression tests failed against the
700c9b0implementation and passed ten consecutive runs under-raceonee5e16b: startup PCI/TAP preservation with a live owner, a crash between stop and start withmax_attempts=1, a policy update after a failed reset, a canceled running-source fork, and a canceled QEMU rollback during another teardown. 91 targeted instance tests, the QEMU and restart-policy package tests, the VFIO wait tests, andgo veton all four packages passed. These checks did not rerun the physical GPU batch.On
24289f1, regression tests reproduced premature detach on direct delete retry, a TTL update erasing the stop, restore replacing the pending instance, a failed device reset reported as success, and a health-check restart stuck inShutdown. The five regression cases passed 10 runs with-raceafter the fixes; 118 targeted instance tests, QEMU and restart-policy package tests, VFIO wait tests andgo vetpassed locally. The GPU hardware batch was not rerun.On
202e651, Linux subprocess tests reproduced canceled fork rollback leaving the child running and stop retry returning success without releasing its TAP or vGPU. A clock-controlled test with 8 s left gave up at 3 s on a child exiting at 4 s. All three regressions pass after the fixes (10 runs under-race). The lifecycle fixtures do not use GPU hardware.Before the first deadline fix, a clock-controlled test of a non-exiting process reproduced 35 s of guest + SIGTERM wait against the 30 s deadline, and 70 s against 60 s. The original overlap tests also passed when the queue was sampled only at entry.
The new tests check the reaper/API budgets, clean exit of both overlapping processes, and overlap between QEMU rollback and lifecycle teardown. Sampling only at entry or restoring fixed-grace QEMU rollback now fails the corresponding test. Focused Linux tests passed under
-race;go vetpassed for the affected packages.The full QEMU package passed. Two unrelated socket tests in
lib/hypervisorfailed locally and on unchangedmain:TestSocketCacheKeyChangesWhenSocketIsRecreatedandTestResolveProcessPIDDuringProcessChurn.The following hardware results are from the original run on Add opt-in vGPU snapshots and forks on a managed QEMU runtime #552 plus the queue change; the hardware batch was not rerun after the deadline and rollback fixes:
No VMM was hard-killed and no device was left behind.
Not covered