[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,28 +1171,40 @@ public class BackupManagerImpl extends ManagerBase implements BackupManager {
}
final Map<VirtualMachine, Backup.Metric> metrics = backupProvider.getBackupMetrics(dataCenter.getId(), new ArrayList<>(vms));
try {
for (final VirtualMachine vm : metrics.keySet()) {
final Backup.Metric metric = metrics.get(vm);
if (metric != null) {
// Sync out-of-band backups
backupProvider.syncBackups(vm, metric);
// Emit a usage event, update usage metric for the VM by the usage server
UsageEventUtils.publishUsageEvent(EventTypes.EVENT_VM_BACKUP_USAGE_METRIC, vm.getAccountId(),
vm.getDataCenterId(), vm.getId(), "Backup-" + vm.getHostName() + "-" + vm.getUuid(),
vm.getBackupOfferingId(), null, metric.getBackupSize(), metric.getDataSize(),
Backup.class.getSimpleName(), vm.getUuid());
}
}
} catch (final Throwable e) {
LOG.error(String.format("Failed to sync backup usage metrics and out-of-band backups due to: [%s].", e.getMessage()), e);
}
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()) {
tryToSyncVMBackups(backupProvider, metrics, vm);
}
}
private void tryToSyncVMBackups(BackupProvider backupProvider, Map<VirtualMachine, Backup.Metric> metrics, VirtualMachine vm) {
try {
final Backup.Metric metric = metrics.get(vm);
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
backupProvider.syncBackups(vm, metric);
// Emit a usage event, update usage metric for the VM by the usage server
UsageEventUtils.publishUsageEvent(EventTypes.EVENT_VM_BACKUP_USAGE_METRIC, vm.getAccountId(),
vm.getDataCenterId(), vm.getId(), "Backup-" + vm.getHostName() + "-" + vm.getUuid(),
vm.getBackupOfferingId(), null, metric.getBackupSize(), metric.getDataSize(),
Backup.class.getSimpleName(), vm.getUuid());
}
} catch (final Exception 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);
}
}
@Override
public Long getDelay() {
return BackupSyncPollingInterval.value() * 1000L;