From 83c0b61ab20236592181ca9f6786274c0d335c90 Mon Sep 17 00:00:00 2001 From: Daniel Augusto Veronezi Salvador <38945620+GutoVeronezi@users.noreply.github.com> Date: Tue, 24 Aug 2021 01:06:00 -0300 Subject: [PATCH] Externalize KVM Agent storage's reboot configuration (#4586) Co-authored-by: GutoVeronezi --- agent/conf/agent.properties | 3 +++ .../java/com/cloud/agent/properties/AgentProperties.java | 8 ++++++++ .../com/cloud/hypervisor/kvm/resource/KVMHAMonitor.java | 4 +++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/agent/conf/agent.properties b/agent/conf/agent.properties index 25863276c09..784abf799d1 100644 --- a/agent/conf/agent.properties +++ b/agent/conf/agent.properties @@ -271,5 +271,8 @@ iscsi.session.cleanup.enabled=false # Depending on the use case, this timeout might need increasing/decreasing. # heartbeat.update.timeout=60000 +# This parameter specifies if the host must be rebooted when something goes wrong with the heartbeat. +# reboot.host.and.alert.management.on.heartbeat.timeout=true + # Enable manually setting CPU's topology on KVM's VM. # enable.manually.setting.cpu.topology.on.kvm.vm=true diff --git a/agent/src/main/java/com/cloud/agent/properties/AgentProperties.java b/agent/src/main/java/com/cloud/agent/properties/AgentProperties.java index d04e98fb704..9e5f167cc4e 100644 --- a/agent/src/main/java/com/cloud/agent/properties/AgentProperties.java +++ b/agent/src/main/java/com/cloud/agent/properties/AgentProperties.java @@ -32,6 +32,14 @@ public class AgentProperties{ */ public static final Property HEARTBEAT_UPDATE_TIMEOUT = new Property("heartbeat.update.timeout", 60000); + /** + * Reboot host and alert management on heartbeat timeout.
+ * Data type: boolean.
+ * Default value: true. + */ + public static final Property REBOOT_HOST_AND_ALERT_MANAGEMENT_ON_HEARTBEAT_TIMEOUT + = new Property("reboot.host.and.alert.management.on.heartbeat.timeout", true); + /** * Enable manually setting CPU's topology on KVM's VM.
* Data type: boolean.
diff --git a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/KVMHAMonitor.java b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/KVMHAMonitor.java index a939abe3bbe..022b48c929f 100644 --- a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/KVMHAMonitor.java +++ b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/KVMHAMonitor.java @@ -36,6 +36,7 @@ public class KVMHAMonitor extends KVMHABase implements Runnable { private static final Logger s_logger = Logger.getLogger(KVMHAMonitor.class); private final Map storagePool = new ConcurrentHashMap<>(); + private final boolean rebootHostAndAlertManagementOnHeartbeatTimeout; private final String hostPrivateIp; @@ -47,6 +48,7 @@ public class KVMHAMonitor extends KVMHABase implements Runnable { configureHeartBeatPath(scriptPath); _heartBeatUpdateTimeout = AgentPropertiesFileHandler.getPropertyValue(AgentProperties.HEARTBEAT_UPDATE_TIMEOUT); + rebootHostAndAlertManagementOnHeartbeatTimeout = AgentPropertiesFileHandler.getPropertyValue(AgentProperties.REBOOT_HOST_AND_ALERT_MANAGEMENT_ON_HEARTBEAT_TIMEOUT); } private static synchronized void configureHeartBeatPath(String scriptPath) { @@ -134,7 +136,7 @@ public class KVMHAMonitor extends KVMHABase implements Runnable { } - if (result != null) { + if (result != null && rebootHostAndAlertManagementOnHeartbeatTimeout) { s_logger.warn(String.format("Write heartbeat for pool [%s] failed: %s; stopping cloudstack-agent.", uuid, result)); Script cmd = createHeartBeatCommand(primaryStoragePool, null, false); result = cmd.execute();