Trashing
When deleting a disk, either on its own or during deletion of a VM, the disk image on Ceph is not immediately removed, but moved to Ceph trash instead, where it could be recovered from later.
By default a disk is scheduled to be in trash for 14 days before it is purged and lost forever. Warren admin can configure the number of days, the configuration applies at the moment disk is deleted, disks that are already in trash keep their previous purge schedule.
Short lived disks are removed immediately on delete, instead of trashing. These disks most probably do not contain any useful data, so to preserve Ceph space they are not kept in trash. By default, “short lived” means disks younger than 4 hours, this too can be configured by Warren admins.
Do note that all snapshots and backups are not retained when disk is moved to trash, so snapshots and backups are not recoverable.
Restoring data from a deleted VM
Finding the data
First find the VM in admin UI, set Status filter to show Deleted VMs, use other filters to find the desired VM, then open its details view.
From details view, find the disk or disks that need to be recovered and copy their UUID. Also get the VM UUID, this will be needed later.
Actually restoring the Disk
Now admin API can be used to try and recover the disk from Ceph trash.
Call the disk restore API endpoint with the disk UUID.
curl --request PUT \ 'https://{{api_domain}}/v1/{{location_slug}}/storage/admin/disks/09e66ce4-5e29-480a-ad21-65f2b406e187/restore' \ --header 'apikey: meowmeowmeow'
If the disk has already been purged from trash then 404 Not Found
and this error message is returned:
{ "message": "Disk image does not exist and cannot be found in trash either, cannot restore" }
However, if the disk was in trash and recovery was successful then the disk JSON is returned:
{ "uuid": "09e66ce4-5e29-480a-ad21-65f2b406e187", "status": "Active", "snapshots": [], "user_id": 35, "billing_account_id": 129124, "size_gb": 20, "source_image_type": "OS_BASE", "source_image": "centos_8.2", "image_path": "vm-disk-images/09e66ce4-5e29-480a-ad21-65f2b406e187.img", "created_at": "2023-07-13T02:12:18.919+0000", "updated_at": "2023-07-13T09:21:12.994+0000", "acting_user_id": 35, "storage_pool_name": "vm-disk-images" }
The next step is to make the disk available to the user.
Detach first
Although the VM is deleted, the disk is still attached to the VM. It needs to be detached before it can be used with some other VM. Call admin API to detach the disk, the VM UUID is needed now.
curl --request POST \ 'https://{{api_domain}}/v1/{{location_slug}}/user-resource/admin/vm/storage/detach' \ --header 'apikey: meowmeowmeow' \ --header 'Content-Type: application/x-www-form-urlencoded' \ --data-urlencode 'uuid=08ff1c8c-6da5-4351-98fe-2c8a4a76817a' \ --data-urlencode 'storage_uuid=09e66ce4-5e29-480a-ad21-65f2b406e187'
Now the disk is ready to be used again.
Use it with a VM
There are two options, the disk can either attached to an existing VM or used as an existing primary disk when creating a new VM.