Avoid metadata writes when deleting instances without vGPUs - #486
Merged
Merged
Conversation
yummybomb
marked this pull request as ready for review
September 18, 2026 15:41
hiroTamada
approved these changes
Sep 18, 2026
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.
Why
#485 made
DELETEreturn an error when vGPU release fails, instead of logging a warning and continuing. That was the right call for instances that actually hold a vGPU, but it exposed a pre-existing problem: delete calledreleaseStoredVGPUPersistedfor every instance, GPU or not, and that helper always rewrites the metadata file via a temp file and rename.For an instance with no vGPU that write does nothing useful. Before #485 its failure was swallowed, so nobody noticed. After #485 an
ENOSPCon that write aborts the delete before any instance data is removed. On a full disk that means the only way to free space is blocked by the lack of space.What changed
releaseStoredVGPUPersistedwhen the instance has a vGPU assignment. This matches howstartand the vGPU reconciler already gate the same helper.Testing
TestDeleteWithoutVGPUDoesNotRewriteMetadataasserts the metadata file keeps the same inode through delete for a non-GPU instance. It fails onmainand passes here.-race; the new test and the existing vGPU delete tests were repeated 25 times.Not covered: no hypervisor was started and the full instances suite was not run. Instances that carry a restart policy still need one metadata write during delete to block auto-restart, so a full disk can still fail those; none of our callers set a restart policy today.
Note
Medium Risk
Touches instance delete teardown ordering for vGPU vs non-vGPU paths; wrong gating could skip needed GPU cleanup or regress disk-full delete behavior.
Overview
Delete no longer calls
releaseStoredVGPUPersistedfor instances without a vGPU assignment, aligning delete with how start already gates that helper. Previously every delete attempted a metadata rewrite (temp file + rename) even when there was nothing to release; after #485 a failed write (e.g. ENOSPC) could abort deletion before any instance data was removed.When a vGPU is assigned, behavior is unchanged: release runs inside the same guard, failures still return an error and retain metadata for retry, and network/device teardown still does not run on failure.
Adds
TestDeleteWithoutVGPUDoesNotRewriteMetadata, which checks the metadata file keeps the same inode through delete for a non-GPU instance (via a hook during device detach).Reviewed by Cursor Bugbot for commit 50b4444. Bugbot is set up for automated code reviews on this repo. Configure here.