Skip to content

fix: delete inline boot disk on VM destroy - #4

Merged
gurinderu merged 1 commit into
mainfrom
fix/vm-delete-orphans-boot-disk
May 22, 2026
Merged

gurinderu merged 1 commit into
mainfrom
fix/vm-delete-orphans-boot-disk

Conversation

@gurinderu

Copy link
Copy Markdown
Contributor

Problem

terraform destroy of a cloudless_vm with an inline boot_disk orphans the boot storage volume — it stays status=ready (and billing) on the cluster. Observed live: a tf-cloudless-test-vm-boot volume 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_storage resource. vmResource.Delete only called TerminateVM, which does not cascade-delete the boot disk, and Terraform doesn't track the disk independently — so nothing ever deleted it.

Fix

  • vmResource.Delete now calls DeleteStorage(boot_disk_id) once the VM is gone.
  • It skips deletion when boot_disk references an existing storage_id (that volume is managed elsewhere, e.g. a cloudless_storage resource).

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 BOOT storage that VM terminate does not remove — mirroring the real API. New unit test TestUnitVM_Delete_RemovesInlineBootDisk fails without the fix (disk leaks) and passes with it.

Notes

Builds on the inline boot disk path fixed in #3.

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.
@gurinderu
gurinderu merged commit bce3cc9 into main May 22, 2026
1 check passed
@gurinderu
gurinderu deleted the fix/vm-delete-orphans-boot-disk branch May 22, 2026 16:38
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.

1 participant