Repository: cloudstack Updated Branches: refs/heads/hotfix/4.4/CLOUDSTACK-7184 f497fceab -> b0641a7d2
CLOUDSTACK-7184 timeout configuration value for host check Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/b0641a7d Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/b0641a7d Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/b0641a7d Branch: refs/heads/hotfix/4.4/CLOUDSTACK-7184 Commit: b0641a7d279734970577a3a87940abd030a6a8c2 Parents: f497fce Author: Daan Hoogland <dhoogl...@schubergphilis.com> Authored: Mon Sep 15 17:41:01 2014 +0200 Committer: Daan Hoogland <d...@onecht.net> Committed: Mon Sep 15 17:41:01 2014 +0200 ---------------------------------------------------------------------- api/src/com/cloud/ha/Investigator.java | 5 +++-- core/src/com/cloud/agent/api/CheckOnHostCommand.java | 8 ++++++-- .../cloudstack/api/agent/test/CheckOnHostCommandTest.java | 2 +- .../hyperv/src/com/cloud/ha/HypervInvestigator.java | 8 ++++---- .../hypervisors/kvm/src/com/cloud/ha/KVMInvestigator.java | 8 ++++---- .../simulator/src/com/cloud/ha/SimulatorInvestigator.java | 6 +++--- .../vmware/src/com/cloud/ha/VmwareInvestigator.java | 4 ++-- server/src/com/cloud/configuration/Config.java | 1 + server/src/com/cloud/ha/CheckOnAgentInvestigator.java | 4 ++-- server/src/com/cloud/ha/HighAvailabilityManagerImpl.java | 8 ++++++-- .../src/com/cloud/ha/ManagementIPSystemVMInvestigator.java | 4 ++-- server/src/com/cloud/ha/UserVmDomRInvestigator.java | 4 ++-- server/src/com/cloud/ha/XenServerInvestigator.java | 8 ++++---- 13 files changed, 40 insertions(+), 30 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b0641a7d/api/src/com/cloud/ha/Investigator.java ---------------------------------------------------------------------- diff --git a/api/src/com/cloud/ha/Investigator.java b/api/src/com/cloud/ha/Investigator.java index 7dd8b3f..e5b8609 100644 --- a/api/src/com/cloud/ha/Investigator.java +++ b/api/src/com/cloud/ha/Investigator.java @@ -26,8 +26,9 @@ public interface Investigator extends Adapter { * Returns if the vm is still alive. * * @param vm to work on. + * @param wait TODO */ - public Boolean isVmAlive(VirtualMachine vm, Host host); + public Boolean isVmAlive(VirtualMachine vm, Host host, int wait); - public Status isAgentAlive(Host agent); + public Status isAgentAlive(Host agent, int wait); } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b0641a7d/core/src/com/cloud/agent/api/CheckOnHostCommand.java ---------------------------------------------------------------------- diff --git a/core/src/com/cloud/agent/api/CheckOnHostCommand.java b/core/src/com/cloud/agent/api/CheckOnHostCommand.java index be05bd4..8229bc3 100644 --- a/core/src/com/cloud/agent/api/CheckOnHostCommand.java +++ b/core/src/com/cloud/agent/api/CheckOnHostCommand.java @@ -25,9 +25,13 @@ public class CheckOnHostCommand extends Command { protected CheckOnHostCommand() { } - public CheckOnHostCommand(Host host) { + protected CheckOnHostCommand(Host host) { + this(host,20); + } + + public CheckOnHostCommand(Host host, int wait) { this.host = new HostTO(host); - setWait(20); + setWait(wait); } public HostTO getHost() { http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b0641a7d/core/test/org/apache/cloudstack/api/agent/test/CheckOnHostCommandTest.java ---------------------------------------------------------------------- diff --git a/core/test/org/apache/cloudstack/api/agent/test/CheckOnHostCommandTest.java b/core/test/org/apache/cloudstack/api/agent/test/CheckOnHostCommandTest.java index 9edbf10..c220268 100644 --- a/core/test/org/apache/cloudstack/api/agent/test/CheckOnHostCommandTest.java +++ b/core/test/org/apache/cloudstack/api/agent/test/CheckOnHostCommandTest.java @@ -257,7 +257,7 @@ public class CheckOnHostCommandTest { }; }; - CheckOnHostCommand cohc = new CheckOnHostCommand(host); + CheckOnHostCommand cohc = new CheckOnHostCommand(host,20); @Test public void testGetHost() { http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b0641a7d/plugins/hypervisors/hyperv/src/com/cloud/ha/HypervInvestigator.java ---------------------------------------------------------------------- diff --git a/plugins/hypervisors/hyperv/src/com/cloud/ha/HypervInvestigator.java b/plugins/hypervisors/hyperv/src/com/cloud/ha/HypervInvestigator.java index 01d75fa..3ff2aba 100644 --- a/plugins/hypervisors/hyperv/src/com/cloud/ha/HypervInvestigator.java +++ b/plugins/hypervisors/hyperv/src/com/cloud/ha/HypervInvestigator.java @@ -42,8 +42,8 @@ public class HypervInvestigator extends AdapterBase implements Investigator { @Inject ResourceManager _resourceMgr; @Override - public Boolean isVmAlive(com.cloud.vm.VirtualMachine vm, Host host) { - Status status = isAgentAlive(host); + public Boolean isVmAlive(com.cloud.vm.VirtualMachine vm, Host host, int wait) { + Status status = isAgentAlive(host, wait); if (status == null) { return false; } @@ -51,11 +51,11 @@ public class HypervInvestigator extends AdapterBase implements Investigator { } @Override - public Status isAgentAlive(Host agent) { + public Status isAgentAlive(Host agent, int wait) { if (agent.getHypervisorType() != Hypervisor.HypervisorType.Hyperv) { return null; } - CheckOnHostCommand cmd = new CheckOnHostCommand(agent); + CheckOnHostCommand cmd = new CheckOnHostCommand(agent, wait); List<HostVO> neighbors = _resourceMgr.listHostsInClusterByStatus(agent.getClusterId(), Status.Up); for (HostVO neighbor : neighbors) { if (neighbor.getId() == agent.getId() || neighbor.getHypervisorType() != Hypervisor.HypervisorType.Hyperv) { http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b0641a7d/plugins/hypervisors/kvm/src/com/cloud/ha/KVMInvestigator.java ---------------------------------------------------------------------- diff --git a/plugins/hypervisors/kvm/src/com/cloud/ha/KVMInvestigator.java b/plugins/hypervisors/kvm/src/com/cloud/ha/KVMInvestigator.java index 184053b..c21bad9 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/ha/KVMInvestigator.java +++ b/plugins/hypervisors/kvm/src/com/cloud/ha/KVMInvestigator.java @@ -47,8 +47,8 @@ public class KVMInvestigator extends AdapterBase implements Investigator { ResourceManager _resourceMgr; @Override - public Boolean isVmAlive(com.cloud.vm.VirtualMachine vm, Host host) { - Status status = isAgentAlive(host); + public Boolean isVmAlive(com.cloud.vm.VirtualMachine vm, Host host, int wait) { + Status status = isAgentAlive(host, wait); if (status == null) { return null; } @@ -56,11 +56,11 @@ public class KVMInvestigator extends AdapterBase implements Investigator { } @Override - public Status isAgentAlive(Host agent) { + public Status isAgentAlive(Host agent, int wait) { if (agent.getHypervisorType() != Hypervisor.HypervisorType.KVM) { return null; } - CheckOnHostCommand cmd = new CheckOnHostCommand(agent); + CheckOnHostCommand cmd = new CheckOnHostCommand(agent, wait); List<HostVO> neighbors = _resourceMgr.listHostsInClusterByStatus(agent.getClusterId(), Status.Up); for (HostVO neighbor : neighbors) { if (neighbor.getId() == agent.getId() || neighbor.getHypervisorType() != Hypervisor.HypervisorType.KVM) { http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b0641a7d/plugins/hypervisors/simulator/src/com/cloud/ha/SimulatorInvestigator.java ---------------------------------------------------------------------- diff --git a/plugins/hypervisors/simulator/src/com/cloud/ha/SimulatorInvestigator.java b/plugins/hypervisors/simulator/src/com/cloud/ha/SimulatorInvestigator.java index 448d7ed..af13f82 100644 --- a/plugins/hypervisors/simulator/src/com/cloud/ha/SimulatorInvestigator.java +++ b/plugins/hypervisors/simulator/src/com/cloud/ha/SimulatorInvestigator.java @@ -55,12 +55,12 @@ public class SimulatorInvestigator extends AdapterBase implements Investigator { } @Override - public Status isAgentAlive(Host agent) { + public Status isAgentAlive(Host agent, int wait) { if (agent.getHypervisorType() != HypervisorType.Simulator) { return null; } - CheckOnHostCommand cmd = new CheckOnHostCommand(agent); + CheckOnHostCommand cmd = new CheckOnHostCommand(agent, wait); List<HostVO> neighbors = _resourceMgr.listHostsInClusterByStatus(agent.getClusterId(), Status.Up); for (HostVO neighbor : neighbors) { if (neighbor.getId() == agent.getId() || neighbor.getHypervisorType() != Hypervisor.HypervisorType.Simulator) { @@ -80,7 +80,7 @@ public class SimulatorInvestigator extends AdapterBase implements Investigator { } @Override - public Boolean isVmAlive(VirtualMachine vm, Host host) { + public Boolean isVmAlive(VirtualMachine vm, Host host, int wait) { CheckVirtualMachineCommand cmd = new CheckVirtualMachineCommand(vm.getInstanceName()); try { Answer answer = _agentMgr.send(vm.getHostId(), cmd); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b0641a7d/plugins/hypervisors/vmware/src/com/cloud/ha/VmwareInvestigator.java ---------------------------------------------------------------------- diff --git a/plugins/hypervisors/vmware/src/com/cloud/ha/VmwareInvestigator.java b/plugins/hypervisors/vmware/src/com/cloud/ha/VmwareInvestigator.java index 7042d53..c04d431 100644 --- a/plugins/hypervisors/vmware/src/com/cloud/ha/VmwareInvestigator.java +++ b/plugins/hypervisors/vmware/src/com/cloud/ha/VmwareInvestigator.java @@ -30,7 +30,7 @@ public class VmwareInvestigator extends AdapterBase implements Investigator { } @Override - public Status isAgentAlive(Host agent) { + public Status isAgentAlive(Host agent, int wait) { if (agent.getHypervisorType() == HypervisorType.VMware) return Status.Disconnected; @@ -38,7 +38,7 @@ public class VmwareInvestigator extends AdapterBase implements Investigator { } @Override - public Boolean isVmAlive(VirtualMachine vm, Host host) { + public Boolean isVmAlive(VirtualMachine vm, Host host, int wait) { if (vm.getHypervisorType() == HypervisorType.VMware) return true; http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b0641a7d/server/src/com/cloud/configuration/Config.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/configuration/Config.java b/server/src/com/cloud/configuration/Config.java index 56ae5f9..d202e61 100755 --- a/server/src/com/cloud/configuration/Config.java +++ b/server/src/com/cloud/configuration/Config.java @@ -597,6 +597,7 @@ public enum Config { "The interval (in milliseconds) when host stats are retrieved from agents.", null), HostRetry("Advanced", AgentManager.class, Integer.class, "host.retry", "2", "Number of times to retry hosts for creating a volume", null), + HostPingTimeout("Advanced", HighAvailabilityManager.class, Integer.class, "host.ping.timeout", "60", "Interval to wait untill a host is considdered down while waiting for check results", null), IntegrationAPIPort("Advanced", ManagementServer.class, Integer.class, "integration.api.port", null, "Default API port", null), InvestigateRetryInterval( "Advanced", http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b0641a7d/server/src/com/cloud/ha/CheckOnAgentInvestigator.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/ha/CheckOnAgentInvestigator.java b/server/src/com/cloud/ha/CheckOnAgentInvestigator.java index 1dfe8c0..27fed59 100644 --- a/server/src/com/cloud/ha/CheckOnAgentInvestigator.java +++ b/server/src/com/cloud/ha/CheckOnAgentInvestigator.java @@ -42,12 +42,12 @@ public class CheckOnAgentInvestigator extends AdapterBase implements Investigato } @Override - public Status isAgentAlive(Host agent) { + public Status isAgentAlive(Host agent, int wait) { return null; } @Override - public Boolean isVmAlive(VirtualMachine vm, Host host) { + public Boolean isVmAlive(VirtualMachine vm, Host host, int wait) { CheckVirtualMachineCommand cmd = new CheckVirtualMachineCommand(vm.getInstanceName()); try { CheckVirtualMachineAnswer answer = (CheckVirtualMachineAnswer)_agentMgr.send(vm.getHostId(), cmd); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b0641a7d/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 1318d9b..12caae2 100755 --- a/server/src/com/cloud/ha/HighAvailabilityManagerImpl.java +++ b/server/src/com/cloud/ha/HighAvailabilityManagerImpl.java @@ -187,6 +187,7 @@ public class HighAvailabilityManagerImpl extends ManagerBase implements HighAvai int _stopRetryInterval; int _investigateRetryInterval; int _migrateRetryInterval; + int _waitTimeout; int _restartRetryInterval; int _maxRetries; @@ -207,7 +208,7 @@ public class HighAvailabilityManagerImpl extends ManagerBase implements HighAvai Status hostState = null; for (Investigator investigator : investigators) { - hostState = investigator.isAgentAlive(host); + hostState = investigator.isAgentAlive(host, _waitTimeout); if (hostState != null) { if (s_logger.isDebugEnabled()) { s_logger.debug(investigator.getName() + " was able to determine host " + hostId + " is in " + hostState.toString()); @@ -479,7 +480,7 @@ public class HighAvailabilityManagerImpl extends ManagerBase implements HighAvai Investigator investigator = null; for (Investigator it : investigators) { investigator = it; - alive = investigator.isVmAlive(vm, host); + alive = investigator.isVmAlive(vm, host, 20); s_logger.info(investigator.getName() + " found " + vm + "to be alive? " + alive); if (alive != null) { break; @@ -792,6 +793,9 @@ public class HighAvailabilityManagerImpl extends ManagerBase implements HighAvai value = params.get("migrate.retry.interval"); _migrateRetryInterval = NumbersUtil.parseInt(value, 2 * 60); + value = params.get("host.ping.timeout"); + _waitTimeout = NumbersUtil.parseInt(value, 60); + _instance = params.get("instance"); if (_instance == null) { _instance = "VMOPS"; http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b0641a7d/server/src/com/cloud/ha/ManagementIPSystemVMInvestigator.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/ha/ManagementIPSystemVMInvestigator.java b/server/src/com/cloud/ha/ManagementIPSystemVMInvestigator.java index 95e803f..53ff4e6 100644 --- a/server/src/com/cloud/ha/ManagementIPSystemVMInvestigator.java +++ b/server/src/com/cloud/ha/ManagementIPSystemVMInvestigator.java @@ -42,7 +42,7 @@ public class ManagementIPSystemVMInvestigator extends AbstractInvestigatorImpl { private final NetworkModel _networkMgr = null; @Override - public Boolean isVmAlive(VirtualMachine vm, Host host) { + public Boolean isVmAlive(VirtualMachine vm, Host host, int wait) { if (!vm.getType().isUsedBySystem()) { s_logger.debug("Not a System Vm, unable to determine state of " + vm + " returning null"); } @@ -109,7 +109,7 @@ public class ManagementIPSystemVMInvestigator extends AbstractInvestigatorImpl { } @Override - public Status isAgentAlive(Host agent) { + public Status isAgentAlive(Host agent, int wait) { return null; } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b0641a7d/server/src/com/cloud/ha/UserVmDomRInvestigator.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/ha/UserVmDomRInvestigator.java b/server/src/com/cloud/ha/UserVmDomRInvestigator.java index d6f7279..6fea432 100644 --- a/server/src/com/cloud/ha/UserVmDomRInvestigator.java +++ b/server/src/com/cloud/ha/UserVmDomRInvestigator.java @@ -53,7 +53,7 @@ public class UserVmDomRInvestigator extends AbstractInvestigatorImpl { private final VpcVirtualNetworkApplianceManager _vnaMgr = null; @Override - public Boolean isVmAlive(VirtualMachine vm, Host host) { + public Boolean isVmAlive(VirtualMachine vm, Host host, int wait) { if (vm.getType() != VirtualMachine.Type.User) { if (s_logger.isDebugEnabled()) { s_logger.debug("Not a User Vm, unable to determine state of " + vm + " returning null"); @@ -104,7 +104,7 @@ public class UserVmDomRInvestigator extends AbstractInvestigatorImpl { } @Override - public Status isAgentAlive(Host agent) { + public Status isAgentAlive(Host agent, int wait) { if (s_logger.isDebugEnabled()) { s_logger.debug("checking if agent (" + agent.getId() + ") is alive"); } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b0641a7d/server/src/com/cloud/ha/XenServerInvestigator.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/ha/XenServerInvestigator.java b/server/src/com/cloud/ha/XenServerInvestigator.java index 8ea27dc..09b7905 100755 --- a/server/src/com/cloud/ha/XenServerInvestigator.java +++ b/server/src/com/cloud/ha/XenServerInvestigator.java @@ -50,12 +50,12 @@ public class XenServerInvestigator extends AdapterBase implements Investigator { } @Override - public Status isAgentAlive(Host agent) { + public Status isAgentAlive(Host agent, int wait) { if (agent.getHypervisorType() != HypervisorType.XenServer) { return null; } - CheckOnHostCommand cmd = new CheckOnHostCommand(agent); + CheckOnHostCommand cmd = new CheckOnHostCommand(agent, wait); List<HostVO> neighbors = _resourceMgr.listAllHostsInCluster(agent.getClusterId()); for (HostVO neighbor : neighbors) { if (neighbor.getId() == agent.getId() || neighbor.getHypervisorType() != HypervisorType.XenServer) { @@ -76,8 +76,8 @@ public class XenServerInvestigator extends AdapterBase implements Investigator { } @Override - public Boolean isVmAlive(VirtualMachine vm, Host host) { - Status status = isAgentAlive(host); + public Boolean isVmAlive(VirtualMachine vm, Host host, int wait) { + Status status = isAgentAlive(host, wait); if (status == null) { return null; }