|
26 | 26 | import com.cloud.hypervisor.kvm.storage.KVMStoragePoolManager; |
27 | 27 | import com.cloud.resource.CommandWrapper; |
28 | 28 | import com.cloud.resource.ResourceWrapper; |
| 29 | +import com.cloud.utils.Pair; |
29 | 30 | import org.apache.cloudstack.backup.CleanupKbossBackupErrorAnswer; |
30 | 31 | import org.apache.cloudstack.backup.CleanupKbossBackupErrorCommand; |
31 | 32 | import org.apache.cloudstack.storage.to.BackupDeltaTO; |
@@ -57,23 +58,24 @@ public Answer execute(CleanupKbossBackupErrorCommand command, LibvirtComputingRe |
57 | 58 | cleanupBackupDeltasOnSecondary(command, storagePoolManager, kbossTOS); |
58 | 59 |
|
59 | 60 | if (command.isRunningVM()) { |
60 | | - return new CleanupKbossBackupErrorAnswer(command, cleanupRunningVm(command, serverResource)); |
| 61 | + Pair<List<VolumeObjectTO>, Boolean> volumeTosAndIsVmRunning = cleanupRunningVm(command, serverResource); |
| 62 | + return new CleanupKbossBackupErrorAnswer(command, volumeTosAndIsVmRunning.first(), volumeTosAndIsVmRunning.second()); |
61 | 63 | } |
62 | 64 |
|
63 | | - return new CleanupKbossBackupErrorAnswer(command, mergeDeltasForStoppedVmIfNeeded(command, serverResource)); |
| 65 | + return new CleanupKbossBackupErrorAnswer(command, mergeDeltasForStoppedVmIfNeeded(command, serverResource), false); |
64 | 66 | } |
65 | 67 |
|
66 | | - private List<VolumeObjectTO> cleanupRunningVm(CleanupKbossBackupErrorCommand command, LibvirtComputingResource serverResource) { |
| 68 | + private Pair<List<VolumeObjectTO>, Boolean> cleanupRunningVm(CleanupKbossBackupErrorCommand command, LibvirtComputingResource serverResource) { |
67 | 69 | Domain dm = null; |
68 | 70 | try { |
69 | 71 | dm = serverResource.getDomain(serverResource.getLibvirtUtilitiesHelper().getConnection(), command.getVmName()); |
70 | | - return mergeDeltasForRunningVmIfNeeded(command, serverResource, dm); |
| 72 | + return new Pair<>(mergeDeltasForRunningVmIfNeeded(command, serverResource, dm), true); |
71 | 73 | } catch (LibvirtException e) { |
72 | 74 | if (e.getError().getCode() == Error.ErrorNumber.VIR_ERR_NO_DOMAIN && IsVmReallyStopped(command, serverResource)) { |
73 | | - return mergeDeltasForStoppedVmIfNeeded(command, serverResource); |
| 75 | + return new Pair<>(mergeDeltasForStoppedVmIfNeeded(command, serverResource), false); |
74 | 76 | } |
75 | 77 | logger.error("Error while trying to get VM [{}]. Aborting the process.", command.getVmName(), e); |
76 | | - return List.of(); |
| 78 | + return new Pair<>(List.of(), false); |
77 | 79 | } finally { |
78 | 80 | if (dm != null) { |
79 | 81 | try { |
|
0 commit comments