Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

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.

https://documenter.getpostman.com/view/2599901/RznLEagg?version=latest#abf9b9d8-822b-4db6-802d-86113c5b0c66

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 can be either attached to an existing VM or used as an existing primary disk when creating a new VM.

Create new VM with existing disk

Check the admin API documentation for more information. Here’s a basic example:

curl --request POST \
  'https://{{api_domain}}/v1/{{location_slug}}/user-resource/admin/vm' \
  --header 'apikey: meowmeowmeow' \
  --header 'Content-Type: application/x-www-form-urlencoded' \
  --data-urlencode 'user_id=35' \
  --data-urlencode 'billing_account_id=129124' \
  --data-urlencode 'os_name=centos' \
  --data-urlencode 'os_version=8.2' \
  --data-urlencode 'name=using a restored disk' \
  --data-urlencode 'ram=2048' \
  --data-urlencode 'vcpu=2' \
  --data-urlencode 'password=WhatEver1234' \
  --data-urlencode 'username=theuser' \
  --data-urlencode 'disk_uuid=09e66ce4-5e29-480a-ad21-65f2b406e187'

Attach disk to an existing VM

Alternatively, attach the disk to some VM that the user already has so they can recover the data from the restored disk. Again refer to admin API documentation for more information.

curl --request POST \
  'https://{{api_domain}}/v1/{{location_slug}}/user-resource/admin/vm/storage/attach' \
  --header 'apikey: meowmeowmeow' \
  --header 'Content-Type: application/x-www-form-urlencoded' \
  --data-urlencode 'uuid=f2f759c5-9a82-4c7a-9aec-d62be56f948e' \
  --data-urlencode 'storage_uuid=09e66ce4-5e29-480a-ad21-65f2b406e187'
  • No labels