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, 12 insertions(+), 3 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/64/35664/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 3223e91..9dc4ea6 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 @@ -547,9 +547,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 b531a87..05920af 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 @@ -720,6 +720,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 c2783f7..675c231 100644 --- a/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties +++ b/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties @@ -596,6 +596,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/35664 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I67e5119f0f65ce77bc30b6762192e927c88c4434 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Tal Nisan <tni...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches