From 4f116fb24f148c4ee64a74515d61a6323ae03e4c Mon Sep 17 00:00:00 2001 From: prachi Date: Wed, 11 Apr 2012 16:15:19 -0700 Subject: [PATCH] Bug 14646 - Enabling Host into maintenance mode is stopping the VMs instead of live migrating them to other hosts in the cluster. Changes: - While listing UP hosts in the cluster of the host, the query has changed and now also considers the Host 'resourceState' field and picks only those hosts that have value 'enabled'. This query result does not include the host being put in maintainance; unlike the earlier query that used to include it. - But the logic to find out if this is the last host in the Cluster is not updated and has a bug when it compares the list size. - Fixed this. --- server/src/com/cloud/resource/ResourceManagerImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/com/cloud/resource/ResourceManagerImpl.java b/server/src/com/cloud/resource/ResourceManagerImpl.java index 384f649f1a3..bf9c43f6b5e 100755 --- a/server/src/com/cloud/resource/ResourceManagerImpl.java +++ b/server/src/com/cloud/resource/ResourceManagerImpl.java @@ -1095,7 +1095,7 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma List hosts = listAllUpAndEnabledHosts(Host.Type.Routing, host.getClusterId(), host.getPodId(), host.getDataCenterId()); for (final VMInstanceVO vm : vms) { - if (hosts == null || hosts.size() <= 1 || !answer.getMigrate()) { + if (hosts == null || hosts.isEmpty() || !answer.getMigrate()) { // for the last host in this cluster, stop all the VMs _haMgr.scheduleStop(vm, hostId, WorkType.ForceStop); } else {