Externalize KVM Agent storage's reboot configuration (#4586)

Co-authored-by: GutoVeronezi <daniel@scclouds.com.br>
This commit is contained in:
Daniel Augusto Veronezi Salvador 2021-08-24 01:06:00 -03:00 committed by GitHub
parent 8a16729fcf
commit 83c0b61ab2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 1 deletions

View File

@ -271,5 +271,8 @@ iscsi.session.cleanup.enabled=false
# Depending on the use case, this timeout might need increasing/decreasing. # Depending on the use case, this timeout might need increasing/decreasing.
# heartbeat.update.timeout=60000 # 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's topology on KVM's VM.
# enable.manually.setting.cpu.topology.on.kvm.vm=true # enable.manually.setting.cpu.topology.on.kvm.vm=true

View File

@ -32,6 +32,14 @@ public class AgentProperties{
*/ */
public static final Property<Integer> HEARTBEAT_UPDATE_TIMEOUT = new Property<Integer>("heartbeat.update.timeout", 60000); public static final Property<Integer> HEARTBEAT_UPDATE_TIMEOUT = new Property<Integer>("heartbeat.update.timeout", 60000);
/**
* Reboot host and alert management on heartbeat timeout. <br>
* Data type: boolean.<br>
* Default value: true.
*/
public static final Property<Boolean> REBOOT_HOST_AND_ALERT_MANAGEMENT_ON_HEARTBEAT_TIMEOUT
= new Property<Boolean>("reboot.host.and.alert.management.on.heartbeat.timeout", true);
/** /**
* Enable manually setting CPU's topology on KVM's VM. <br> * Enable manually setting CPU's topology on KVM's VM. <br>
* Data type: boolean.<br> * Data type: boolean.<br>

View File

@ -36,6 +36,7 @@ public class KVMHAMonitor extends KVMHABase implements Runnable {
private static final Logger s_logger = Logger.getLogger(KVMHAMonitor.class); private static final Logger s_logger = Logger.getLogger(KVMHAMonitor.class);
private final Map<String, NfsStoragePool> storagePool = new ConcurrentHashMap<>(); private final Map<String, NfsStoragePool> storagePool = new ConcurrentHashMap<>();
private final boolean rebootHostAndAlertManagementOnHeartbeatTimeout;
private final String hostPrivateIp; private final String hostPrivateIp;
@ -47,6 +48,7 @@ public class KVMHAMonitor extends KVMHABase implements Runnable {
configureHeartBeatPath(scriptPath); configureHeartBeatPath(scriptPath);
_heartBeatUpdateTimeout = AgentPropertiesFileHandler.getPropertyValue(AgentProperties.HEARTBEAT_UPDATE_TIMEOUT); _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) { 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)); s_logger.warn(String.format("Write heartbeat for pool [%s] failed: %s; stopping cloudstack-agent.", uuid, result));
Script cmd = createHeartBeatCommand(primaryStoragePool, null, false); Script cmd = createHeartBeatCommand(primaryStoragePool, null, false);
result = cmd.execute(); result = cmd.execute();