Martin Sivák has uploaded a new change for review.

Change subject: core: Decrement pending memory/cpus after finished migration
......................................................................

core: Decrement pending memory/cpus after finished migration

The engine leaved pending memory in DB after successfull and
some unsuccessfull migrations and this caused hosts to reject
more VMs after some time.

Change-Id: Ic5ce2756d17a7bc3b0a5be56a44936a70aa227c5
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1039900
Signed-off-by: Martin Sivak <msi...@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/RunVmCommandBase.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsEventListener.java
3 files changed, 16 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/38/22338/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 1a79033..a9ff1f0 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
@@ -87,7 +87,6 @@
     protected void failedToMigrate() {
         try {
             determineMigrationFailureForAuditLog();
-            decreasePendingVms(getDestinationVds().getId());
             _isRerun = false;
             setSucceeded(false);
             log();
@@ -131,14 +130,7 @@
     protected void executeVmCommand() {
         initVdss();
         perform();
-        processVm();
         setSucceeded(true);
-    }
-
-    private void processVm() {
-        if (getVm().getStatus() != VMStatus.Up) {
-            decreasePendingVms(getVds().getId());
-        }
     }
 
     private void perform() {
@@ -378,6 +370,12 @@
             super.reportCompleted();
         }
         finally {
+            /*
+             * Decrement the pending counters here as this is the only place 
which
+             * is called consistently regardless of the migration result.
+             */
+            decreasePendingVms(getVdsDestinationId());
+
             freeLock();
         }
     }
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 ea74927..e9bc17e 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
@@ -342,6 +342,10 @@
      * to fetch the VM using {@link #getVm()}, as the thread that invokes 
{@link #rerun()},
      * which runs in parallel, is doing setVm(null) to refresh the VM, and 
because of this
      * race we might end up with null VM. so we fetch the static part of the 
VM from the DB.
+     *
+     * XXX: This is never executed when part of MigrateVmCommand and the 
decreasePendingVms
+     *      is called from runningSucceeded as a workaround.
+     *      See VdsEventListener.processOnVmPoweringUp for more information.
      */
     @Override
     public void onPowerringUp() {
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsEventListener.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsEventListener.java
index 4f7ccff..a3787cc 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsEventListener.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsEventListener.java
@@ -216,6 +216,12 @@
     public void processOnVmPoweringUp(Guid vds_id, Guid vmid, String 
display_ip, int display_port) {
         IVdsAsyncCommand command = 
Backend.getInstance().getResourceManager().GetAsyncCommandForVm(vmid);
 
+        /*
+         * XXX: command is null after successful migration, because 
runningSucceeded removes the
+         *      MigrateVmCommand instance from the async cache too early.
+         *      See the order of succeededToRunVm and processOnVmPoweringUp
+         *      in VdsUpdateRunTimeInfo.afterRefreshTreatment
+         */
         if (command != null) {
             command.onPowerringUp();
             if (command.getAutoStart() && command.getAutoStartVdsId() != null) 
{


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic5ce2756d17a7bc3b0a5be56a44936a70aa227c5
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: ovirt-engine-3.3
Gerrit-Owner: Martin Sivák <msi...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to