You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by sh...@apache.org on 2023/10/05 08:29:24 UTC
[cloudstack] branch main updated: [Veeam] Don't interrupt backup syncronization (#7225)
This is an automated email from the ASF dual-hosted git repository.
shwstppr pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/main by this push:
new 4c59dea0d13 [Veeam] Don't interrupt backup syncronization (#7225)
4c59dea0d13 is described below
commit 4c59dea0d1369cb71b84b304f024a1f4ef968bbe
Author: SadiJr <sa...@gmail.com>
AuthorDate: Thu Oct 5 05:29:18 2023 -0300
[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 <sa...@scclouds.com.br>
---
.../cloudstack/backup/BackupManagerImpl.java | 44 ++++++++++++++--------
1 file changed, 28 insertions(+), 16 deletions(-)
diff --git a/server/src/main/java/org/apache/cloudstack/backup/BackupManagerImpl.java b/server/src/main/java/org/apache/cloudstack/backup/BackupManagerImpl.java
index 5da3514b848..ddcb15f6151 100644
--- a/server/src/main/java/org/apache/cloudstack/backup/BackupManagerImpl.java
+++ b/server/src/main/java/org/apache/cloudstack/backup/BackupManagerImpl.java
@@ -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;