Skip to content

Commit df5e1f9

Browse files
abh1sardhslove
authored andcommitted
Set external Id to null after backupProvider.removeVMFromBackup (apache#10562)
1 parent b895051 commit df5e1f9

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

plugins/backup/veeam/src/main/java/org/apache/cloudstack/backup/VeeamBackupProvider.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,9 @@ public boolean assignVMToBackupOffering(final VirtualMachine vm, final BackupOff
191191
public boolean removeVMFromBackupOffering(final VirtualMachine vm) {
192192
final VeeamClient client = getClient(vm.getDataCenterId());
193193
final VmwareDatacenter vmwareDC = findVmwareDatacenterForVM(vm);
194+
if (vm.getBackupExternalId() == null) {
195+
throw new CloudRuntimeException("The VM does not have a backup job assigned.");
196+
}
194197
try {
195198
if (!client.removeVMFromVeeamJob(vm.getBackupExternalId(), vm.getInstanceName(), vmwareDC.getVcenterHost())) {
196199
logger.warn("Failed to remove VM from Veeam Job id: " + vm.getBackupExternalId());

server/src/main/java/org/apache/cloudstack/backup/BackupManagerImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,10 +395,10 @@ public boolean removeVMFromBackupOffering(final Long vmId, final boolean forced)
395395

396396
boolean result = false;
397397
try {
398+
result = backupProvider.removeVMFromBackupOffering(vm);
398399
vm.setBackupOfferingId(null);
399-
vm.setBackupExternalId(null);
400400
vm.setBackupVolumes(null);
401-
result = backupProvider.removeVMFromBackupOffering(vm);
401+
vm.setBackupExternalId(null);
402402
if (result && backupProvider.willDeleteBackupsOnOfferingRemoval()) {
403403
final List<Backup> backups = backupDao.listByVmId(null, vm.getId());
404404
for (final Backup backup : backups) {

0 commit comments

Comments
 (0)