Skip to content

Commit 83c0b61

Browse files
GutoVeroneziGutoVeronezi
andauthored
Externalize KVM Agent storage's reboot configuration (#4586)
Co-authored-by: GutoVeronezi <daniel@scclouds.com.br>
1 parent 8a16729 commit 83c0b61

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

agent/conf/agent.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,5 +271,8 @@ iscsi.session.cleanup.enabled=false
271271
# Depending on the use case, this timeout might need increasing/decreasing.
272272
# heartbeat.update.timeout=60000
273273

274+
# This parameter specifies if the host must be rebooted when something goes wrong with the heartbeat.
275+
# reboot.host.and.alert.management.on.heartbeat.timeout=true
276+
274277
# Enable manually setting CPU's topology on KVM's VM.
275278
# enable.manually.setting.cpu.topology.on.kvm.vm=true

agent/src/main/java/com/cloud/agent/properties/AgentProperties.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@ public class AgentProperties{
3232
*/
3333
public static final Property<Integer> HEARTBEAT_UPDATE_TIMEOUT = new Property<Integer>("heartbeat.update.timeout", 60000);
3434

35+
/**
36+
* Reboot host and alert management on heartbeat timeout. <br>
37+
* Data type: boolean.<br>
38+
* Default value: true.
39+
*/
40+
public static final Property<Boolean> REBOOT_HOST_AND_ALERT_MANAGEMENT_ON_HEARTBEAT_TIMEOUT
41+
= new Property<Boolean>("reboot.host.and.alert.management.on.heartbeat.timeout", true);
42+
3543
/**
3644
* Enable manually setting CPU's topology on KVM's VM. <br>
3745
* Data type: boolean.<br>

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/KVMHAMonitor.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public class KVMHAMonitor extends KVMHABase implements Runnable {
3636

3737
private static final Logger s_logger = Logger.getLogger(KVMHAMonitor.class);
3838
private final Map<String, NfsStoragePool> storagePool = new ConcurrentHashMap<>();
39+
private final boolean rebootHostAndAlertManagementOnHeartbeatTimeout;
3940

4041
private final String hostPrivateIp;
4142

@@ -47,6 +48,7 @@ public KVMHAMonitor(NfsStoragePool pool, String host, String scriptPath) {
4748
configureHeartBeatPath(scriptPath);
4849

4950
_heartBeatUpdateTimeout = AgentPropertiesFileHandler.getPropertyValue(AgentProperties.HEARTBEAT_UPDATE_TIMEOUT);
51+
rebootHostAndAlertManagementOnHeartbeatTimeout = AgentPropertiesFileHandler.getPropertyValue(AgentProperties.REBOOT_HOST_AND_ALERT_MANAGEMENT_ON_HEARTBEAT_TIMEOUT);
5052
}
5153

5254
private static synchronized void configureHeartBeatPath(String scriptPath) {
@@ -134,7 +136,7 @@ protected void runHeartBeat() {
134136

135137
}
136138

137-
if (result != null) {
139+
if (result != null && rebootHostAndAlertManagementOnHeartbeatTimeout) {
138140
s_logger.warn(String.format("Write heartbeat for pool [%s] failed: %s; stopping cloudstack-agent.", uuid, result));
139141
Script cmd = createHeartBeatCommand(primaryStoragePool, null, false);
140142
result = cmd.execute();

0 commit comments

Comments
 (0)