cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From h...@apache.org
Subject [24/50] [abbrv] git commit: updated refs/heads/4.4 to 48f8a95
Date Fri, 14 Mar 2014 13:58:21 GMT
move HA rescheduling operation to HA worker context.


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

Branch: refs/heads/4.4
Commit: 3d5fbe7073d4b7234611e972ca030088bff2f3f2
Parents: 53f306e
Author: Kelven Yang <kelveny@gmail.com>
Authored: Tue Mar 4 15:58:03 2014 -0800
Committer: Kelven Yang <kelveny@gmail.com>
Committed: Thu Mar 13 16:59:56 2014 -0700

----------------------------------------------------------------------
 .../cloud/ha/HighAvailabilityManagerImpl.java   | 22 +++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3d5fbe70/server/src/com/cloud/ha/HighAvailabilityManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/ha/HighAvailabilityManagerImpl.java b/server/src/com/cloud/ha/HighAvailabilityManagerImpl.java
index b7d5be8..3bcaf2e 100755
--- a/server/src/com/cloud/ha/HighAvailabilityManagerImpl.java
+++ b/server/src/com/cloud/ha/HighAvailabilityManagerImpl.java
@@ -267,10 +267,17 @@ public class HighAvailabilityManagerImpl extends ManagerBase implements
HighAvai
             "] is down." +
             ((sb != null) ? sb.toString() : ""));
 
-        for (final VMInstanceVO vm : vms) {
+        for (VMInstanceVO vm : vms) {
             if (s_logger.isDebugEnabled()) {
                 s_logger.debug("Notifying HA Mgr of to restart vm " + vm.getId() + "-" +
vm.getHostName());
             }
+            vm = _instanceDao.findByUuid(vm.getUuid());
+            Long hostId = vm.getHostId();
+            if ( hostId != null && !hostId.equals(host.getId()) ) {
+                s_logger.debug("VM " + vm.getHostName() + " is not on down host " + host.getId()
+ " it is on other host "
+                        + hostId + " VM HA is done");
+                continue;
+            }
             scheduleRestart(vm, investigate);
         }
     }
@@ -951,10 +958,19 @@ public class HighAvailabilityManagerImpl extends ManagerBase implements
HighAvai
     @Override
     public boolean postStateTransitionEvent(State oldState, VirtualMachine.Event event, State
newState, VirtualMachine vo, boolean status, Object opaque) {
         if (oldState == State.Running && event == VirtualMachine.Event.FollowAgentPowerOffReport
&& newState == State.Stopped) {
-            VMInstanceVO vm = _instanceDao.findById(vo.getId());
+            final VMInstanceVO vm = _instanceDao.findById(vo.getId());
             if (vm.isHaEnabled()) {
                 s_logger.info("Detected out-of-band stop of a HA enabled VM " + vm.getInstanceName()
+ ", will schedule restart");
-                scheduleRestart(vm, true);
+                _executor.submit(new ManagedContextRunnable() {
+                    @Override
+                    protected void runInContext() {
+                        try {
+                            scheduleRestart(vm, true);
+                        } catch (Exception e) {
+                            s_logger.warn("Unexpected exception when scheduling a HA restart",
e);
+                        }
+                    }
+                });
             }
         }
         return true;


Mime
View raw message