DaanHoogland commented on code in PR #10140:
URL: https://github.com/apache/cloudstack/pull/10140#discussion_r1988920461
##########
engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java:
##########
@@ -2345,6 +2349,17 @@ public void doInTransactionWithoutResult(final
TransactionStatus status) throws
throw new CloudRuntimeException("Unable to destroy " +
vm);
} else {
if (expunge) {
+ if (vm.getBackupOfferingId() != null) {
+ List<Backup> backupsForVm =
backupDao.listByVmId(vm.getDataCenterId(), vm.getId());
+ if (CollectionUtils.isEmpty(backupsForVm)) {
+
backupManager.removeVMFromBackupOffering(vm.getId(), true);
+ } else {
+ throw new
CloudRuntimeException(String.format("This VM [uuid: %s, name: %s] has a "
+ + "Backup Offering [id:
%s, external id: %s] with %s backups. Please, remove the backup offering "
+ + "before proceeding to VM
exclusion!", vm.getUuid(), vm.getInstanceName(), vm.getBackupOfferingId(),
+ vm.getBackupExternalId(),
backupsForVm.size()));
+ }
+ }
Review Comment:
extract method?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]