SadiJr commented on code in PR #7238:
URL: https://github.com/apache/cloudstack/pull/7238#discussion_r1112998525


##########
server/src/main/java/org/apache/cloudstack/backup/BackupManagerImpl.java:
##########
@@ -585,17 +595,64 @@ public boolean restoreBackup(final Long backupId) {
 
         final BackupOffering offering = 
backupOfferingDao.findByIdIncludingRemoved(vm.getBackupOfferingId());
         if (offering == null) {
-            throw new CloudRuntimeException("Failed to find backup offering of 
the VM backup");
+            throw new CloudRuntimeException("Failed to find backup offering of 
the VM backup.");
         }
 
-        final BackupProvider backupProvider = 
getBackupProvider(offering.getProvider());
-        if (!backupProvider.restoreVMFromBackup(vm, backup)) {
-            throw new CloudRuntimeException("Error restoring VM from backup ID 
" + backup.getId());
+        String backupDetailsInMessage = 
ReflectionToStringBuilderUtils.reflectOnlySelectedFields(backup, "uuid", 
"externalId", "vmId", "type", "status", "date");
+        try {
+            updateVmState(vm, VirtualMachine.Event.RestoringRequested);
+            updateVolumeState(vm, Volume.Event.RestoreRequested);
+            final BackupProvider backupProvider = 
getBackupProvider(offering.getProvider());
+            if (!backupProvider.restoreVMFromBackup(vm, backup)) {
+                throw new CloudRuntimeException(String.format("Error restoring 
%s from backup [%s].", vm, backupDetailsInMessage));
+            }
+        } catch (Exception e) {

Review Comment:
   @DaanHoogland the restore process is executed by a backup provider outside 
of ACS. I am using the catch-all (Exception) to ensure that no provider-side 
exception is missed. Therefore, we have a proper handling of exceptions, and 
rollbacks if needed. Please let me know if my explanation is enough 
(communication is not my strong point :()



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to