rhtyd commented on a change in pull request #5017:
URL: https://github.com/apache/cloudstack/pull/5017#discussion_r642396201



##########
File path: 
server/src/main/java/org/apache/cloudstack/backup/BackupManagerImpl.java
##########
@@ -671,6 +667,14 @@ public boolean deleteBackup(final Long backupId) {
         if (offering == null) {
             throw new CloudRuntimeException("VM backup offering ID " + 
vm.getBackupOfferingId() + " does not exist");
         }
+        List<Backup> backupsForVm = backupDao.listByVmId(vm.getDataCenterId(), 
vmId);
+        if (CollectionUtils.isNotEmpty(backupsForVm)) {
+            backupsForVm = backupsForVm.stream().filter(vmBackup -> 
vmBackup.getId() != backupId).collect(Collectors.toList());
+            if (backupsForVm.size() <= 0 && vm.getRemoved() != null) {
+                removeVMFromBackupOffering(vmId, true);

Review comment:
       My worry is deletion of single last backup may remove it? And if backup 
policy could have an related regression. For example on expunging a VM should 
we expunge a backup policy? Or not?




-- 
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.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to