apache / cloudstack

Apache CloudStack is an opensource Infrastructure as a Service (IaaS) cloud computing platform
https://cloudstack.apache.org/
Apache License 2.0
2.05k stars 1.1k forks source link

Destroying VMs also deleting the associated VM Snapshots #6604

Closed gg4126 closed 5 months ago

gg4126 commented 2 years ago
ISSUE TYPE
COMPONENT NAME
API, UI
CLOUDSTACK VERSION
CloudStack 4.17.0.1
CONFIGURATION

advanced networking

OS / ENVIRONMENT

RHEL 7.9

SUMMARY

The VM Snapshots and VM “Backup & Recovery” are two different things; Currently CloudStack supports the VM backup & recovery by means of third party Veeam Plugin which requires paid subscription. We noticed that when we destroy (without Expunging) VMs, it is also deleting the associated VM Snapshots, in fact we wanted to use these VM snapshots as our recovery points. So, Is it possible to retain the VM snapshots even when the VMs are getting destroyed so that we can pick and choose the desired VM snapshot to recover the VM.

STEPS TO REPRODUCE
step1: Navigate to the desired instances under compute tab, and click "Take VM Snapshot" w/ Snapshot memory & Quiesce VM Enabled
step2: Navigate to Instances, pick the VM and destroy it (without choosing Expunge).
step3: After the VM is destroyed, you will notice that the associated VM Snapshots under Storage tab are also deleted.
EXPECTED RESULTS
Destroying VMs should NOT delete the associated VM Snapshots coz these snapshots can be used to recreate the VM using the desired VM snapshot from of these backed-up VM snapshots.
ACTUAL RESULTS
Destroying VMs also deleting the associated VM Snapshots - the whole chain parent and children VM snapshots
boring-cyborg[bot] commented 2 years ago

Thanks for opening your first issue here! Be sure to follow the issue template!

shwstppr commented 2 years ago

@gg4126 this would require some major changes as currently VM snapshots are not backed up on to secondary storage and live in the same dir as the VM (atleast on VMware which I checked). For now using B&R plugin would be a better option

damonb123 commented 2 years ago

I think the issue is the snapshots are deleted on "VM.DESTROY", instead of on "VM.EXPUNGING". Since the VM can be recovered after being destroyed, but cant be recovered after expunging. So in the "VM.DESTROYED" event process, the snapshots should not be deleted.

shwstppr commented 2 years ago

@gg4126 I will test again but in my case snapshot wasn't deleted when VM was destroyed and only deleted when the VM was expunged. I was using VMware as hypervisor. Are you using KVM?

shwstppr commented 2 years ago

@gg4126 I will test again but in my case snapshot wasn't deleted when VM was destroyed and only deleted when the VM was expunged. I was using VMware as hypervisor. Are you using KVM?

gg4126 commented 2 years ago

Yes, we saw this behavior on KVM based VMs.

weizhouapache commented 1 year ago

@gg4126 on KVM, the vm snapshots are saved as in the qcow2 image file of the vm instance. If the vm is expunged (cloudstack will expunge vm in Destroy state after a period), the vm image is removed, as well as the vm snapshots.

it would be better to use volume snapshots (a.k.a snapshots), which are persisted on primary or secondary storage, instead of vm snapshots.

rohityadavcloud commented 5 months ago

By design, it's not possible to retain VM snapshot and delete the VM with VM snapshots. The suggest approach is to take volume snapshots and convert them into templates when needed to restore VMs. Or, take backup using the B&R framework.

Due to this design we can't support retaining VM snapshots across support hypervisors and volumes. Closing on this remark.