[Veeam] Don't interrupt backup syncronization (#7225)

When ACS  is synchronizing the Veeam backups, if one backup fails in this process, all the other backups are skipped and ignored. This behavior is fixed by this PR; if one backup fails in syncronization, only this backup is skipped, and the others continue the process.

Co-authored-by: SadiJr <sadi@scclouds.com.br>
This commit is contained in:
SadiJr 2023-10-05 05:29:18 -03:00 committed by GitHub
parent b9e423b7a9
commit 4c59dea0d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1171,10 +1171,27 @@ public class BackupManagerImpl extends ManagerBase implements BackupManager {
} }
final Map<VirtualMachine, Backup.Metric> metrics = backupProvider.getBackupMetrics(dataCenter.getId(), new ArrayList<>(vms)); final Map<VirtualMachine, Backup.Metric> metrics = backupProvider.getBackupMetrics(dataCenter.getId(), new ArrayList<>(vms));
try { syncBackupMetrics(backupProvider, metrics);
}
} catch (final Throwable t) {
LOG.error(String.format("Error trying to run backup-sync background task due to: [%s].", t.getMessage()), t);
}
}
/**
* Tries to sync the VM backups. If one backup synchronization fails, only this VM backups are skipped, and the entire process does not stop.
*/
private void syncBackupMetrics(final BackupProvider backupProvider, final Map<VirtualMachine, Backup.Metric> metrics) {
for (final VirtualMachine vm : metrics.keySet()) { for (final VirtualMachine vm : metrics.keySet()) {
tryToSyncVMBackups(backupProvider, metrics, vm);
}
}
private void tryToSyncVMBackups(BackupProvider backupProvider, Map<VirtualMachine, Backup.Metric> metrics, VirtualMachine vm) {
try {
final Backup.Metric metric = metrics.get(vm); final Backup.Metric metric = metrics.get(vm);
if (metric != null) { if (metric != null) {
LOG.debug(String.format("Trying to sync backups of VM [%s] using backup provider [%s].", vm.getUuid(), backupProvider.getName()));
// Sync out-of-band backups // Sync out-of-band backups
backupProvider.syncBackups(vm, metric); backupProvider.syncBackups(vm, metric);
// Emit a usage event, update usage metric for the VM by the usage server // Emit a usage event, update usage metric for the VM by the usage server
@ -1183,13 +1200,8 @@ public class BackupManagerImpl extends ManagerBase implements BackupManager {
vm.getBackupOfferingId(), null, metric.getBackupSize(), metric.getDataSize(), vm.getBackupOfferingId(), null, metric.getBackupSize(), metric.getDataSize(),
Backup.class.getSimpleName(), vm.getUuid()); Backup.class.getSimpleName(), vm.getUuid());
} }
} } catch (final Exception e) {
} catch (final Throwable e) { LOG.error(String.format("Failed to sync backup usage metrics and out-of-band backups of VM [%s] due to: [%s].", vm.getUuid(), e.getMessage()), e);
LOG.error(String.format("Failed to sync backup usage metrics and out-of-band backups due to: [%s].", e.getMessage()), e);
}
}
} catch (final Throwable t) {
LOG.error(String.format("Error trying to run backup-sync background task due to: [%s].", t.getMessage()), t);
} }
} }