Tal Nisan has uploaded a new change for review.

Change subject: core: Add try/catch block in end action of ExportVmCommand
......................................................................

core: Add try/catch block in end action of ExportVmCommand

When exporting a VM with the collapse snapshot option, the VM ovf is
updated after the images export ends successfully. If this operation will
fail and throw an exception the source VM will be stayed in locked status.
This patch surrounds the operation with a try/catch block in order to log
the fault and continue the end action correctly to unlock the VM and it's
disks.

Bug-Url: https://bugzilla.redhat.com/1167297
Change-Id: I67e5119f0f65ce77bc30b6762192e927c88c4434
Signed-off-by: Tal Nisan <tni...@redhat.com>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ExportVmCommand.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java
M 
backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
3 files changed, 13 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/99/35699/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ExportVmCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ExportVmCommand.java
index d701a7d..d69ff8e 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ExportVmCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ExportVmCommand.java
@@ -54,6 +54,7 @@
 import org.ovirt.engine.core.common.vdscommands.VDSReturnValue;
 import org.ovirt.engine.core.compat.Guid;
 import org.ovirt.engine.core.compat.KeyValuePairCompat;
+import org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogDirector;
 import org.ovirt.engine.core.utils.GuidUtils;
 import org.ovirt.engine.core.utils.linq.LinqUtils;
 import org.ovirt.engine.core.utils.linq.Predicate;
@@ -547,9 +548,16 @@
         Snapshot activeSnapshot = getDbFacade().getSnapshotDao().get(
                 getDbFacade().getSnapshotDao().getId(vm.getId(), 
SnapshotType.ACTIVE));
         vm.setSnapshots(Arrays.asList(activeSnapshot));
-        updateCopyVmInSpm(getVm().getStoragePoolId(),
-                vm, getParameters()
-                        .getStorageDomainId());
+
+        try {
+            updateCopyVmInSpm(getVm().getStoragePoolId(),
+                    vm, getParameters()
+                            .getStorageDomainId());
+        }
+        catch (VdcBLLException e) {
+            log.error("Updating VM OVF in export domain failed.", e);
+            AuditLogDirector.log(this, 
AuditLogType.IMPORTEXPORT_IMPORT_VM_FAILED_UPDATING_OVF);
+        }
     }
 
     private void updateSnapshotOvf(VM vm) {
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java
index 993663e..723c3a7 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java
@@ -719,6 +719,7 @@
     IMPORTEXPORT_STARTING_EXPORT_VM(1162),
     IMPORTEXPORT_EXPORT_VM(1150),
     IMPORTEXPORT_EXPORT_VM_FAILED(1151, AuditLogSeverity.ERROR),
+    IMPORTEXPORT_IMPORT_VM_FAILED_UPDATING_OVF(1189, AuditLogSeverity.ERROR),
     IMPORTEXPORT_STARTING_IMPORT_VM(1165),
     IMPORTEXPORT_IMPORT_VM(1152),
     IMPORTEXPORT_IMPORT_VM_FAILED(1153, AuditLogSeverity.ERROR),
diff --git 
a/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
 
b/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
index 51c20ff..1444691 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
@@ -597,6 +597,7 @@
 IMPORTEXPORT_STARTING_IMPORT_VM=Starting to import Vm ${VmName} to Data Center 
${StoragePoolName}, Cluster ${VdsGroupName}
 IMPORTEXPORT_IMPORT_VM=Vm ${VmName} was imported successfully to Data Center 
${StoragePoolName}, Cluster ${VdsGroupName}
 IMPORTEXPORT_IMPORT_VM_FAILED=Failed to import Vm ${VmName} to Data Center 
${StoragePoolName}, Cluster ${VdsGroupName}
+IMPORTEXPORT_IMPORT_VM_FAILED_UPDATING_OVF=Failed to import Vm ${VmName} to 
Data Center ${StoragePoolName}, Cluster ${VdsGroupName}, could not update VM 
data in export.
 IMPORTEXPORT_STARTING_EXPORT_TEMPLATE=Starting to export Template 
${VmTemplateName} to ${StorageDomainName}
 IMPORTEXPORT_EXPORT_TEMPLATE=Template ${VmTemplateName} was exported 
successfully to ${StorageDomainName}
 IMPORTEXPORT_EXPORT_TEMPLATE_FAILED=Failed to export Template 
${VmTemplateName} to ${StorageDomainName}


-- 
To view, visit http://gerrit.ovirt.org/35699
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I67e5119f0f65ce77bc30b6762192e927c88c4434
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: ovirt-engine-3.5
Gerrit-Owner: Tal Nisan <tni...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to