incubator-cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aprat...@apache.org
Subject git commit: When a VM is force deleted and the host is not available then CS simply marks the state in db as "Destroyed/Expunging". The VM is still running on the host and once it becomes available again there is a discrepancy in state of the VM. In this
Date Thu, 13 Sep 2012 11:06:05 GMT
Updated Branches:
  refs/heads/master 5532f58bb -> a9559cbb6


When a VM is force deleted and the host is not available then CS simply marks the state in
db as "Destroyed/Expunging". The VM is still running on the host and once it becomes available
again there is a discrepancy in state of the VM. In this scenario the VM is removed from the
host when the next full cluster sync happens.


Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/a9559cbb
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/a9559cbb
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/a9559cbb

Branch: refs/heads/master
Commit: a9559cbb67c9d27519256b53f073b5afdcc7bd8c
Parents: 5532f58
Author: Koushik Das <koushik.das@citrix.com>
Authored: Thu Sep 13 16:34:53 2012 +0530
Committer: Abhinandan Prateek <agneya2001@yahoo.com>
Committed: Thu Sep 13 16:34:53 2012 +0530

----------------------------------------------------------------------
 .../com/cloud/vm/VirtualMachineManagerImpl.java    |   40 ++++++++-------
 1 files changed, 21 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a9559cbb/server/src/com/cloud/vm/VirtualMachineManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java
index 605ce57..b208177 100755
--- a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java
+++ b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java
@@ -1745,7 +1745,6 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager,
Listene
         set_vms.addAll(_vmDao.listLHByClusterId(clusterId));
 
         for (VMInstanceVO vm : set_vms) {
-            if (vm.isRemoved() || vm.getState() == State.Destroyed  || vm.getState() == State.Expunging)
continue;
             AgentVmInfo info =  infos.remove(vm.getId());
             VMInstanceVO castedVm = null;
             if ((info == null && (vm.getState() == State.Running || vm.getState()
== State.Starting))  
@@ -1789,23 +1788,26 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager,
Listene
                     e.printStackTrace();
                 }
             }
-            else if (info != null && (vm.getState() == State.Stopped || vm.getState()
== State.Stopping)) {
-            	 Host host = _hostDao.findByGuid(info.getHostUuid());
-                 if (host != null){
-                    s_logger.warn("Stopping a VM which is stopped/stopping " + info.name);
-                    vm.setState(State.Stopped); // set it as stop and clear it from host
-                    vm.setHostId(null);
-                    _vmDao.persist(vm);
-                     try {
-	                     Answer answer = _agentMgr.send(host.getId(), cleanup(info.name));
-	                     if (!answer.getResult()) {
-	                         s_logger.warn("Unable to stop a VM due to " + answer.getDetails());
-	                     }
-                     }
-                     catch (Exception e) {
-                         s_logger.warn("Unable to stop a VM due to " + e.getMessage());
-                     }
-                 }
+            else if (info != null && (vm.getState() == State.Stopped || vm.getState()
== State.Stopping
+                    || vm.isRemoved() || vm.getState() == State.Destroyed || vm.getState()
== State.Expunging)) {
+                Host host = _hostDao.findByGuid(info.getHostUuid());
+                if (host != null){
+                    s_logger.warn("Stopping a VM which is stopped/stopping/destroyed/expunging
" + info.name);
+                    if (vm.getState() == State.Stopped || vm.getState() == State.Stopping)
{
+                        vm.setState(State.Stopped); // set it as stop and clear it from host
+                        vm.setHostId(null);
+                        _vmDao.persist(vm);
+                    }
+                    try {
+                        Answer answer = _agentMgr.send(host.getId(), cleanup(info.name));
+                        if (!answer.getResult()) {
+                            s_logger.warn("Unable to stop a VM due to " + answer.getDetails());
+                        }
+                    }
+                    catch (Exception e) {
+                        s_logger.warn("Unable to stop a VM due to " + e.getMessage());
+                    }
+                }
             }
             else
             // host id can change
@@ -1831,7 +1833,7 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager,
Listene
         }
 
         for (final AgentVmInfo left : infos.values()) {
-        	if (VirtualMachineName.isValidVmName(left.name)) continue;  // if the vm follows
cloudstack naming ignore it for stopping
+            if (!VirtualMachineName.isValidVmName(left.name)) continue;  // if the vm doesn't
follow CS naming ignore it for stopping
             try {
                 Host host = _hostDao.findByGuid(left.getHostUuid());
                 if (host != null){


Mime
View raw message