Arik Hadas has uploaded a new change for review. Change subject: core: unlock VM on failure to migrate it to server ......................................................................
core: unlock VM on failure to migrate it to server Recently we changed the MigrateVmCommand to lock the VM for the whole migration process. When the VM was migrated to server and the migration failed, we didn't release that lock and the VM would remain locked. The fact that the handling of failed migrations was spread over the code, made it more error-prone - things that were added for regular migrations could have been missing for migrations to server. This patch extract the code that should be executed when migration fails to separate method, and this method is called when migrations to server fail as well. In particular, the acquired lock is released and therefore the bug that was previously described is solved. Change-Id: I282a1fec8ed3f12a8377b2eca8deadc7985d2f66 Bug-Url: https://bugzilla.redhat.com/1033932 Signed-off-by: Arik Hadas <aha...@redhat.com> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MigrateVmCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MigrateVmToServerCommand.java 2 files changed, 18 insertions(+), 15 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/23/21723/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MigrateVmCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MigrateVmCommand.java index 0e71249..4ffb3f4 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MigrateVmCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MigrateVmCommand.java @@ -77,10 +77,21 @@ @Override protected void failedToRunVm() { + // In case the migration failed and the VM turned back to Up in the + // source, we don't need to handle it as a VM that failed to run + if (getVm().getStatus() != VMStatus.Up) { + super.failedToRunVm(); + } + } + + protected void failedToMigrate() { try { - if (getVm().getStatus() != VMStatus.Up) { - super.failedToRunVm(); - } + determineMigrationFailureForAuditLog(); + decreasePendingVms(getDestinationVds().getId()); + _isRerun = false; + setSucceeded(false); + log(); + failedToRunVm(); } finally { freeLock(); @@ -350,18 +361,15 @@ public void rerun() { // make Vm property to null in order to refresh it from db setVm(null); - determineMigrationFailureForAuditLog(); + // if vm is up and rerun is called then it got up on the source, try to rerun if (getVm() != null && getVm().getStatus() == VMStatus.Up) { + determineMigrationFailureForAuditLog(); setVdsDestinationId(null); super.rerun(); } else { // vm went down on the destination and source, migration failed. - decreasePendingVms(getDestinationVds().getId()); - _isRerun = false; - setSucceeded(false); - log(); - failedToRunVm(); + failedToMigrate(); // signal the caller that a rerun was made so that it won't log // the failure message again _isRerun = true; diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MigrateVmToServerCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MigrateVmToServerCommand.java index 680e7a1..d5e3601 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MigrateVmToServerCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MigrateVmToServerCommand.java @@ -47,12 +47,7 @@ */ @Override public void rerun() { - decreasePendingVms(getDestinationVds().getId()); - _isRerun = false; - setSucceeded(false); - - determineMigrationFailureForAuditLog(); - log(); + failedToMigrate(); } @Override -- To view, visit http://gerrit.ovirt.org/21723 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I282a1fec8ed3f12a8377b2eca8deadc7985d2f66 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Arik Hadas <aha...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches