Francesco Romani has uploaded a new change for review. Change subject: engine: do not report VM on error if migration fails ......................................................................
engine: do not report VM on error if migration fails If a migration fails, we report a confusing and alarming message to the user, because an event is added reporting the VM as down. This patch fix this problem using the new ExitReason field. Change-Id: I694dfa739af5edf37ae06b2dea2ad246f17777a2 Bug-Url: https://bugzilla.redhat.com/697277 Signed-off-by: Francesco Romani <from...@redhat.com> --- M backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VdsUpdateRunTimeInfo.java 1 file changed, 22 insertions(+), 4 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/90/25090/1 diff --git a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VdsUpdateRunTimeInfo.java b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VdsUpdateRunTimeInfo.java index 4eb2d77..244f574 100644 --- a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VdsUpdateRunTimeInfo.java +++ b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VdsUpdateRunTimeInfo.java @@ -1510,7 +1510,7 @@ if (exitStatus != VmExitStatus.Normal) { - auditVmOnDownEvent(exitStatus, vmDynamic.getExitMessage(), vmStatistics.getId()); + auditVmOnDownEvent(exitStatus, vmDynamic.getExitMessage(), vmDynamic.getExitReason(), vmStatistics.getId()); // Vm failed to run - try to rerun it on other Vds if (cacheVm != null) { @@ -1530,7 +1530,7 @@ // if went down normally during migration process (either on source or on destination) // don't generate an event if (cacheVm != null) { - auditVmOnDownEvent(exitStatus, vmDynamic.getExitMessage(), vmStatistics.getId()); + auditVmOnDownEvent(exitStatus, vmDynamic.getExitMessage(), vmDynamic.getExitReason(), vmStatistics.getId()); } // Vm moved safely to down status. May be migration - just remove it from Async Running command. @@ -1539,10 +1539,28 @@ } /** + * Decide the audit log type depending on the reason why a VM has gone in status 'down' + */ + private AuditLogType auditLogTypeForDownEvent(VmExitStatus exitStatus, VmExitReason exitReason) { + /* backward compatibility */ + if (exitReason == VmExitReason.Unknown) { + return exitStatus == VmExitStatus.Normal ? AuditLogType.VM_DOWN : AuditLogType.VM_DOWN_ERROR; + } + if (exitStatus == VmExitStatus.Normal) { + return AuditLogType.VM_DOWN; + } + if (exitStatus == VmExitStatus.Error && exitReason == VmExitReason.MigrationFailed) { + /* the VM is still up on the source host, so no need to report it in error */ + return AuditLogType.VM_DOWN; + } + return AuditLogType.VM_DOWN_ERROR; + } + + /** * Generate an error or information event according to the exit status of a VM in status 'down' */ - private void auditVmOnDownEvent(VmExitStatus exitStatus, String exitMessage, Guid vmStatisticsId) { - AuditLogType type = exitStatus == VmExitStatus.Normal ? AuditLogType.VM_DOWN : AuditLogType.VM_DOWN_ERROR; + private void auditVmOnDownEvent(VmExitStatus exitStatus, String exitMessage, VmExitReason exitReason, Guid vmStatisticsId) { + AuditLogType type = auditLogTypeForDownEvent(exitStatus, exitReason); AuditLogableBase logable = new AuditLogableBase(_vds.getId(), vmStatisticsId); if (exitMessage != null) { logable.addCustomValue("ExitMessage", "Exit message: " + exitMessage); -- To view, visit http://gerrit.ovirt.org/25090 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I694dfa739af5edf37ae06b2dea2ad246f17777a2 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Francesco Romani <from...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches