Repository navigation
fix: delete inline boot disk on VM destroy - #4
Merged
Merged
Conversation
An inline-create boot disk is a first-class storage volume owned by the VM, not a separate cloudless_storage resource. TerminateVM does not cascade-delete it, and Terraform does not track it independently, so `terraform destroy` left the boot disk orphaned (status=ready, still billing). vmResource.Delete now deletes the boot disk (via boot_disk_id) once the VM is gone — unless boot_disk references an existing storage_id, which is managed elsewhere and must not be deleted here. The mock previously synthesized a boot-disk ID without recording a storage volume, so it could not surface the leak; it now models the inline boot disk as a real BOOT storage that terminate does not remove. Add a unit test asserting the boot disk is gone after destroy.
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.
Problem
terraform destroyof acloudless_vmwith an inlineboot_diskorphans the boot storage volume — it staysstatus=ready(and billing) on the cluster. Observed live: atf-cloudless-test-vm-bootvolume left unattached after destroy.Root cause
An inline-create boot disk is a first-class storage volume owned by the VM, not a separate
cloudless_storageresource.vmResource.Deleteonly calledTerminateVM, which does not cascade-delete the boot disk, and Terraform doesn't track the disk independently — so nothing ever deleted it.Fix
vmResource.Deletenow callsDeleteStorage(boot_disk_id)once the VM is gone.boot_diskreferences an existingstorage_id(that volume is managed elsewhere, e.g. acloudless_storageresource).Test / mock
The mock previously synthesized a boot-disk ID on inline create but never recorded a storage volume, so it couldn't surface the leak. It now models the inline boot disk as a real
BOOTstorage that VM terminate does not remove — mirroring the real API. New unit testTestUnitVM_Delete_RemovesInlineBootDiskfails without the fix (disk leaks) and passes with it.Notes
Builds on the inline boot disk path fixed in #3.