GitHub user VolodymyrLinuxovich added a comment to the discussion: Delete VM 
with backup offering - Cannot expunge

Hi @EduFrazao,

There is no setting for this today. The check lives in 
`checkAndRemoveBackupOfferingBeforeExpunge` in BackupManagerImpl. If the VM 
still has a backup offering with at least one backup, it throws the error you 
see. It only drops the offering by itself when there are no backups.

This also explains why your users never see the error. `destroyVirtualMachine` 
only runs that check when you pass expunge=true. A normal destroy skips it. The 
VM goes to Destroyed without complaint, and the error only shows up later in 
the scavenger log.

To unstick the VMs you already have, an admin can remove the offering from the 
destroyed VM. The lookup includes removed VMs, so it works in the Destroyed 
state.

```
cmk remove virtualmachinefrombackupoffering virtualmachineid=<uuid> forced=true
```

The next expunge pass then removes the VM. The existing backups are kept. Every 
bundled provider returns false for `willDeleteBackupsOnOfferingRemoval`, so 
nothing gets deleted on the backup side.

For hundreds of VMs you can list the stuck ones and loop over the result.

```
cmk list virtualmachines state=Destroyed listall=true 
filter=id,name,backupofferingid
```

Long term I think it's worth opening an issue. The check could run on every 
destroy so the user gets the error right away. Or there could be a setting to 
drop the offering on expunge.


GitHub link: 
https://github.com/apache/cloudstack/discussions/14893#discussioncomment-19965095

----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]

Reply via email to