Skip to content

Commit 35e809e

Browse files
authored
Set external Id to null after backupProvider.removeVMFromBackup (#10562)
1 parent 95c2481 commit 35e809e

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
@@ -199,6 +199,9 @@ public boolean assignVMToBackupOffering(final VirtualMachine vm, final BackupOff
199199
public boolean removeVMFromBackupOffering(final VirtualMachine vm) {
200200
final VeeamClient client = getClient(vm.getDataCenterId());
201201
final VmwareDatacenter vmwareDC = findVmwareDatacenterForVM(vm);
202+
if (vm.getBackupExternalId() == null) {
203+
throw new CloudRuntimeException("The VM does not have a backup job assigned.");
204+
}
202205
try {
203206
if (!client.removeVMFromVeeamJob(vm.getBackupExternalId(), vm.getInstanceName(), vmwareDC.getVcenterHost())) {
204207
LOG.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
@@ -368,10 +368,10 @@ public boolean removeVMFromBackupOffering(final Long vmId, final boolean forced)
368368

369369
boolean result = false;
370370
try {
371+
result = backupProvider.removeVMFromBackupOffering(vm);
371372
vm.setBackupOfferingId(null);
372-
vm.setBackupExternalId(null);
373373
vm.setBackupVolumes(null);
374-
result = backupProvider.removeVMFromBackupOffering(vm);
374+
vm.setBackupExternalId(null);
375375
if (result && backupProvider.willDeleteBackupsOnOfferingRemoval()) {
376376
final List<Backup> backups = backupDao.listByVmId(null, vm.getId());
377377
for (final Backup backup : backups) {

0 commit comments

Comments
 (0)