1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-11-08 19:26:48 +00:00

fix(computes): a deleted compute's VMs keep their owners

Deleting a compute removed its VMs from the panel together with their
owners, while the VMs kept running on the host: added again, the host's
VMs came back with no owners. A compute's delete now treats each VM as
one that left its compute: its owners follow the same UUID on another
compute or wait in a tombstone for the retention period. One function,
forget(), does this for the refresh and for the delete; the API's
compute delete goes through the same model delete.

The delete holds the compute exclusive and locks its row before its
VMs', as the reconcile does: a reconcile, VM operation or job on the
compute makes it busy instead of losing owners to a concurrent restore
or deadlocking with it.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
catborise 2026-10-22 11:49:42 +03:00
parent fbe93d9aee
commit 2dee5ba41c
7 changed files with 92 additions and 14 deletions

View file

@ -19,7 +19,7 @@ class DeletePageTests(TestCase):
compute = Compute.objects.create(name="del-host", hostname="192.0.2.9", login="u", password="p", type=1)
vm = Instance.objects.create(compute=compute, name="del-vm", uuid="d0000000-0000-4000-8000-000000000001")
pages = {
reverse("compute_delete", args=[compute.id]): "the panel forgets them and who owns them",
reverse("compute_delete", args=[compute.id]): "their owners are kept for 30 days on the Removed VMs page",
reverse("admin:user_delete", args=[user.id]): "the VMs themselves stay",
reverse("admin:group_delete", args=[Group.objects.create(name="del-group").id]): "lose the permissions",
reverse("admin:tombstone_delete", args=[InstanceTombstone.objects.create(uuid=vm.uuid, name="gone").id]):