cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chipchild...@apache.org
Subject git commit: updated refs/heads/4.1 to 2aeb460
Date Fri, 26 Apr 2013 16:26:36 GMT
Updated Branches:
  refs/heads/4.1 15c791d7f -> 2aeb46072


CLOUDSTACK-2195: Don't return a UserVM object if we fail to stop vm

pass back null if we fail to connect to agent or stop the vm, rather
than something that looks like success to the stopVirtualMachine api
command.

Testing:

Applied to 4.1 branch, attempted to stop VM with KVM agent disconnected,
finally saw it fail. The logs also showed why, which is good:

2013-04-25 17:37:09,933 ERROR [cloud.vm.VirtualMachineManagerImpl]
(Job-Executor-1:job-44) Unable to stop vm, agent unavailable:
com.cloud.exception.AgentUnavailableException: Resource [Host:1] is
unreachable: Host 1: Host with specified id is not in the right state:
Disconnected

Started the KVM agent, and stopping succeeded.

Signed-off-by: Chip Childers <chip.childers@gmail.com>


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

Branch: refs/heads/4.1
Commit: 2aeb46072c0c0370daef6a1ad1ce2e092a99bb62
Parents: 15c791d
Author: Marcus Sorensen <shadowsor@gmail.com>
Authored: Fri Apr 26 17:25:52 2013 +0100
Committer: Chip Childers <chip.childers@gmail.com>
Committed: Fri Apr 26 17:25:52 2013 +0100

----------------------------------------------------------------------
 server/src/com/cloud/vm/UserVmManagerImpl.java     |    9 +++++++--
 .../com/cloud/vm/VirtualMachineManagerImpl.java    |    2 ++
 2 files changed, 9 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2aeb4607/server/src/com/cloud/vm/UserVmManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java
index 7bf04ec..865a1d3 100755
--- a/server/src/com/cloud/vm/UserVmManagerImpl.java
+++ b/server/src/com/cloud/vm/UserVmManagerImpl.java
@@ -3685,9 +3685,15 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager,
Use
 
         UserVO user = _userDao.findById(userId);
 
+        boolean status = false;
         try {
             VirtualMachineEntity vmEntity = _orchSrvc.getVirtualMachine(vm.getUuid());
-            vmEntity.stop(new Long(userId).toString());            
+            status = vmEntity.stop(new Long(userId).toString());
+            if (status) {
+               return _vmDao.findById(vmId);
+            } else {
+               return null;
+            }
         } catch (ResourceUnavailableException e) {
             throw new CloudRuntimeException(
                     "Unable to contact the agent to stop the virtual machine "
@@ -3698,7 +3704,6 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager,
Use
                             + vm, e);
         }
 
-        return _vmDao.findById(vmId);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2aeb4607/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 2c2986f..f620c87 100755
--- a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java
+++ b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java
@@ -1083,7 +1083,9 @@ public class VirtualMachineManagerImpl extends ManagerBase implements
VirtualMac
             vmGuru.finalizeStop(profile, answer);
 
         } catch (AgentUnavailableException e) {
+            s_logger.warn("Unable to stop vm, agent unavailable: " + e.toString());
         } catch (OperationTimedoutException e) {
+            s_logger.warn("Unable to stop vm, operation timed out: " + e.toString());
         } finally {
             if (!stopped) {
                 if (!forced) {


Mime
View raw message