Skip to content

Commit 97089e1

Browse files
author
John Burwell
committed
Merge pull request #10 from shapeblue/kvm-ha
CLOUDSTACK-9350: KVM-HA- Fix CheckOnHost for Local storage
2 parents fe03b91 + 894fb54 commit 97089e1

File tree

8 files changed

+606
-1
lines changed

8 files changed

+606
-1
lines changed

plugins/hypervisors/kvm/src/com/cloud/ha/KVMInvestigator.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@
2727
import com.cloud.host.dao.HostDao;
2828
import com.cloud.hypervisor.Hypervisor;
2929
import com.cloud.resource.ResourceManager;
30+
import com.cloud.storage.Storage.StoragePoolType;
3031
import com.cloud.utils.component.AdapterBase;
32+
33+
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
34+
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
3135
import org.apache.log4j.Logger;
3236

3337
import javax.ejb.Local;
@@ -43,6 +47,8 @@ public class KVMInvestigator extends AdapterBase implements Investigator {
4347
AgentManager _agentMgr;
4448
@Inject
4549
ResourceManager _resourceMgr;
50+
@Inject
51+
PrimaryDataStoreDao _storagePoolDao;
4652

4753
@Override
4854
public Boolean isVmAlive(com.cloud.vm.VirtualMachine vm, Host host) {
@@ -58,6 +64,20 @@ public Status isAgentAlive(Host agent) {
5864
if (agent.getHypervisorType() != Hypervisor.HypervisorType.KVM && agent.getHypervisorType() != Hypervisor.HypervisorType.LXC) {
5965
return null;
6066
}
67+
68+
List<StoragePoolVO> clusterPools = _storagePoolDao.listPoolsByCluster(agent.getClusterId());
69+
boolean hasNfs = false;
70+
for (StoragePoolVO pool : clusterPools) {
71+
if (pool.getPoolType() == StoragePoolType.NetworkFilesystem) {
72+
hasNfs = true;
73+
break;
74+
}
75+
}
76+
if (!hasNfs) {
77+
s_logger.warn("Agent investigation was requested on host " + agent + ", but host does not support investigation because it has no NFS storage. Skipping investigation.");
78+
return Status.Disconnected;
79+
}
80+
6181
Status hostStatus = null;
6282
Status neighbourStatus = null;
6383
CheckOnHostCommand cmd = new CheckOnHostCommand(agent);

plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1744,6 +1744,7 @@ protected Answer execute(CheckOnHostCommand cmd) {
17441744
if (result) {
17451745
return new Answer(cmd, false, "Heart is still beating...");
17461746
} else {
1747+
s_logger.warn("Heartbeat failed for : " + cmd.getHost().getPrivateNetwork().getIp().toString());
17471748
return new Answer(cmd);
17481749
}
17491750
} catch (InterruptedException e) {

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -828,6 +828,7 @@
828828
<exclude>tools/ngui/static/js/lib/*</exclude>
829829
<exclude>**/.checkstyle</exclude>
830830
<exclude>scripts/installer/windows/acs_license.rtf</exclude>
831+
<exclude>test/integration/component/test_host_ha.sh</exclude>
831832
</excludes>
832833
</configuration>
833834
</plugin>

server/src/com/cloud/ha/HighAvailabilityManagerImpl.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
import com.cloud.resource.ResourceManager;
6565
import com.cloud.server.ManagementServer;
6666
import com.cloud.service.dao.ServiceOfferingDao;
67+
import com.cloud.service.ServiceOfferingVO;
6768
import com.cloud.storage.StorageManager;
6869
import com.cloud.storage.dao.GuestOSCategoryDao;
6970
import com.cloud.storage.dao.GuestOSDao;
@@ -267,6 +268,13 @@ public void scheduleRestartForVmsOnHost(final HostVO host, boolean investigate)
267268

268269
if (vms != null) {
269270
for (VMInstanceVO vm : vms) {
271+
ServiceOfferingVO vmOffering = _serviceOfferingDao.findById(vm.getServiceOfferingId());
272+
if (vmOffering.getUseLocalStorage()) {
273+
if (s_logger.isDebugEnabled()){
274+
s_logger.debug("Skipping HA on vm " + vm + ", because it uses local storage. Its fate is tied to the host.");
275+
}
276+
continue;
277+
}
270278
if (s_logger.isDebugEnabled()) {
271279
s_logger.debug("Notifying HA Mgr of to restart vm " + vm.getId() + "-" + vm.getInstanceName());
272280
}

0 commit comments

Comments
 (0)