Arik Hadas has uploaded a new change for review.

Change subject: core: refactor failure to run vm flow - part 2
......................................................................

core: refactor failure to run vm flow - part 2

When migration fails and the VM get back to UP state in the source host,
we do not want to treat the VM as VM that failed to run. Thus,
MigrateVmCommand overrides RunVmCommandBase#failedToRunVm method and do
not do anything in that case.

Instead of override the whole RunVmCommandBase#failedToRunVm method, it
is better to override just the RunVmCommandBase#processVmPoolOnStopVm
method so the rest of the things that failedToRunVm do would be
executed.

In addition, the code in RunVmCommandBase#reportCompleted was
simplified a bit.

Change-Id: I6dc8e13f1ab932283557b3cbf16a34e72b9b3a69
Signed-off-by: Arik Hadas <[email protected]>
---
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/RunVmCommandBase.java
2 files changed, 16 insertions(+), 19 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/17/28117/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 863d959..7ff8d62 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
@@ -79,16 +79,11 @@
     }
 
     @Override
-    protected void failedToRunVm() {
-        try {
-            // 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();
-            }
-        }
-        finally {
-            freeLock();
+    protected void processVmPoolOnStopVm() {
+        // 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.processVmPoolOnStopVm();
         }
     }
 
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommandBase.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommandBase.java
index da57403..7bd20fc 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommandBase.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommandBase.java
@@ -11,7 +11,6 @@
 
 import org.apache.commons.lang.StringUtils;
 import org.ovirt.engine.core.bll.job.ExecutionContext;
-import org.ovirt.engine.core.bll.job.ExecutionContext.ExecutionMethod;
 import org.ovirt.engine.core.bll.job.ExecutionHandler;
 import org.ovirt.engine.core.bll.job.JobRepositoryFactory;
 import org.ovirt.engine.core.bll.scheduling.RunVmDelayer;
@@ -138,7 +137,7 @@
         ExecutionHandler.endJob(getExecutionContext(), false);
     }
 
-    private void processVmPoolOnStopVm() {
+    protected void processVmPoolOnStopVm() {
         ThreadPoolUtil.execute(new Runnable() {
             @Override
             public void run() {
@@ -223,13 +222,16 @@
     @Override
     public void reportCompleted() {
         ExecutionContext executionContext = getExecutionContext();
-        if (executionContext != null && executionContext.isMonitored()) {
-            if (!executionContext.isCompleted()) {
-                if (executionContext.getExecutionMethod() == 
ExecutionMethod.AsJob) {
-                    ExecutionHandler.endJob(executionContext, false);
-                } else if (executionContext.getExecutionMethod() == 
ExecutionMethod.AsStep) {
-                    ExecutionHandler.endStep(executionContext, 
executionContext.getStep(), false);
-                }
+        if (executionContext != null && executionContext.isMonitored()
+                && !executionContext.isCompleted()) {
+            switch (executionContext.getExecutionMethod()) {
+            case AsJob:
+                ExecutionHandler.endJob(executionContext, false);
+                break;
+            case AsStep:
+                ExecutionHandler.endStep(executionContext, 
executionContext.getStep(), false);
+                break;
+            default:
             }
         }
     }


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6dc8e13f1ab932283557b3cbf16a34e72b9b3a69
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: ovirt-engine-3.4
Gerrit-Owner: Arik Hadas <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to