Set external Id to null after backupProvider.removeVMFromBackup (#10562)

This commit is contained in:
Abhisar Sinha 2025-03-17 22:16:05 +05:30 committed by GitHub
parent 95c24810ab
commit 35e809e7ce
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 3 deletions

View File

@ -199,6 +199,9 @@ public class VeeamBackupProvider extends AdapterBase implements BackupProvider,
public boolean removeVMFromBackupOffering(final VirtualMachine vm) {
final VeeamClient client = getClient(vm.getDataCenterId());
final VmwareDatacenter vmwareDC = findVmwareDatacenterForVM(vm);
if (vm.getBackupExternalId() == null) {
throw new CloudRuntimeException("The VM does not have a backup job assigned.");
}
try {
if (!client.removeVMFromVeeamJob(vm.getBackupExternalId(), vm.getInstanceName(), vmwareDC.getVcenterHost())) {
LOG.warn("Failed to remove VM from Veeam Job id: " + vm.getBackupExternalId());

View File

@ -368,10 +368,10 @@ public class BackupManagerImpl extends ManagerBase implements BackupManager {
boolean result = false;
try {
vm.setBackupOfferingId(null);
vm.setBackupExternalId(null);
vm.setBackupVolumes(null);
result = backupProvider.removeVMFromBackupOffering(vm);
vm.setBackupOfferingId(null);
vm.setBackupVolumes(null);
vm.setBackupExternalId(null);
if (result && backupProvider.willDeleteBackupsOnOfferingRemoval()) {
final List<Backup> backups = backupDao.listByVmId(null, vm.getId());
for (final Backup backup : backups) {