Skip to content

Commit 267a457

Browse files
stephankrugggStephan KrugGaOrtigaDaanHoogland
authored
Externalize KVM HA heartbeat frequency (#6892)
Co-authored-by: Stephan Krug <stephan.krug@scclouds.com.br> Co-authored-by: GaOrtiga <49285692+GaOrtiga@users.noreply.github.com> Co-authored-by: dahn <daan.hoogland@gmail.com>
1 parent be4a648 commit 267a457

File tree

5 files changed

+60
-13
lines changed

5 files changed

+60
-13
lines changed

agent/conf/agent.properties

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,3 +407,15 @@ iscsi.session.cleanup.enabled=false
407407
# The path of an executable file/script for host health check for CloudStack to Auto Disable/Enable the host
408408
# depending on the return value of the file/script
409409
# agent.health.check.script.path=
410+
411+
# Time interval (in milliseconds) between KVM heartbeats.
412+
# kvm.heartbeat.update.frequency=60000
413+
414+
# Number of maximum tries to KVM heartbeats.
415+
# kvm.heartbeat.update.max.tries=5
416+
417+
# Time amount (in milliseconds) for the KVM heartbeat retry sleep.
418+
# kvm.heartbeat.update.retry.sleep=10000
419+
420+
# Timeout (in milliseconds) of the KVM heartbeat checker.
421+
# kvm.heartbeat.checker.timeout=360000

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

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -539,10 +539,10 @@ public class AgentProperties{
539539
/**
540540
* Heartbeat update timeout (in ms).<br>
541541
* Depending on the use case, this timeout might need increasing/decreasing.<br>
542-
* Data type: Integer.<br>
543-
* Default value: <code>60000</code>
542+
* Data type: Long.<br>
543+
* Default value: <code>60000L</code>
544544
*/
545-
public static final Property<Integer> HEARTBEAT_UPDATE_TIMEOUT = new Property<>("heartbeat.update.timeout", 60000);
545+
public static final Property<Long> HEARTBEAT_UPDATE_TIMEOUT = new Property<>("heartbeat.update.timeout", 60000L);
546546

547547
/**
548548
* The timeout (in seconds) to retrieve the target's domain ID when migrating a VM with KVM. <br>
@@ -740,6 +740,38 @@ public Property<Integer> getWorkers() {
740740
*/
741741
public static final Property<String> CONTROL_CIDR = new Property<>("control.cidr", "169.254.0.0/16");
742742

743+
/**
744+
* Time interval (in milliseconds) between KVM heartbeats. <br>
745+
* This property is for KVM only.
746+
* Data type: Long.<br>
747+
* Default value: <code>60000l</code>
748+
*/
749+
public static final Property<Long> KVM_HEARTBEAT_UPDATE_FREQUENCY = new Property<>("kvm.heartbeat.update.frequency", 60000L);
750+
751+
/**
752+
* Number of maximum tries to KVM heartbeats. <br>
753+
* This property is for KVM only.
754+
* Data type: Long.<br>
755+
* Default value: <code>5l</code>
756+
*/
757+
public static final Property<Long> KVM_HEARTBEAT_UPDATE_MAX_TRIES = new Property<>("kvm.heartbeat.update.max.tries", 5L);
758+
759+
/**
760+
* Time amount (in milliseconds) for the KVM heartbeat retry sleep. <br>
761+
* This property is for KVM only.
762+
* Data type: Long.<br>
763+
* Default value: <code>10000l</code>
764+
*/
765+
public static final Property<Long> KVM_HEARTBEAT_UPDATE_RETRY_SLEEP = new Property<>("kvm.heartbeat.update.retry.sleep", 10000L);
766+
767+
/**
768+
* Timeout (in milliseconds) of the KVM heartbeat checker. <br>
769+
* This property is for KVM only.
770+
* Data type: Long.<br>
771+
* Default value: <code>360000l</code>
772+
*/
773+
public static final Property<Long> KVM_HEARTBEAT_CHECKER_TIMEOUT = new Property<>("kvm.heartbeat.checker.timeout", 360000L);
774+
743775
public static class Property <T>{
744776
private String name;
745777
private T defaultValue;

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,17 @@
2828
import com.cloud.utils.script.OutputInterpreter;
2929
import com.cloud.utils.script.OutputInterpreter.AllLinesParser;
3030
import com.cloud.utils.script.Script;
31+
import com.cloud.agent.properties.AgentProperties;
32+
import com.cloud.agent.properties.AgentPropertiesFileHandler;
3133

3234
public class KVMHABase {
3335
private static final Logger s_logger = Logger.getLogger(KVMHABase.class);
3436
private long _timeout = 60000; /* 1 minutes */
3537
protected static String s_heartBeatPath;
36-
protected long _heartBeatUpdateTimeout = 60000;
37-
protected long _heartBeatUpdateFreq = 60000;
38-
protected long _heartBeatUpdateMaxTries = 5;
39-
protected long _heartBeatUpdateRetrySleep = 10000;
38+
protected long _heartBeatUpdateTimeout = AgentPropertiesFileHandler.getPropertyValue(AgentProperties.HEARTBEAT_UPDATE_TIMEOUT);
39+
protected long _heartBeatUpdateFreq = AgentPropertiesFileHandler.getPropertyValue(AgentProperties.KVM_HEARTBEAT_UPDATE_FREQUENCY);
40+
protected long _heartBeatUpdateMaxTries = AgentPropertiesFileHandler.getPropertyValue(AgentProperties.KVM_HEARTBEAT_UPDATE_MAX_TRIES);
41+
protected long _heartBeatUpdateRetrySleep = AgentPropertiesFileHandler.getPropertyValue(AgentProperties.KVM_HEARTBEAT_UPDATE_RETRY_SLEEP);
4042

4143
public static enum PoolType {
4244
PrimaryStorage, SecondaryStorage

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ public KVMHAMonitor(HAStoragePool pool, String host, String scriptPath) {
4848
hostPrivateIp = host;
4949
configureHeartBeatPath(scriptPath);
5050

51-
_heartBeatUpdateTimeout = AgentPropertiesFileHandler.getPropertyValue(AgentProperties.HEARTBEAT_UPDATE_TIMEOUT);
5251
rebootHostAndAlertManagementOnHeartbeatTimeout = AgentPropertiesFileHandler.getPropertyValue(AgentProperties.REBOOT_HOST_AND_ALERT_MANAGEMENT_ON_HEARTBEAT_TIMEOUT);
5352
}
5453

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/KVMStoragePool.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import java.util.List;
2020
import java.util.Map;
2121

22+
import com.cloud.agent.properties.AgentProperties;
23+
import com.cloud.agent.properties.AgentPropertiesFileHandler;
2224
import org.apache.cloudstack.utils.qemu.QemuImg.PhysicalDiskFormat;
2325
import org.joda.time.Duration;
2426

@@ -29,11 +31,11 @@
2931

3032
public interface KVMStoragePool {
3133

32-
public static final long HeartBeatUpdateTimeout = 60000;
33-
public static final long HeartBeatUpdateFreq = 60000;
34-
public static final long HeartBeatUpdateMaxTries = 5;
35-
public static final long HeartBeatUpdateRetrySleep = 10000;
36-
public static final long HeartBeatCheckerTimeout = 360000; // 6 minutes
34+
public static final long HeartBeatUpdateTimeout = AgentPropertiesFileHandler.getPropertyValue(AgentProperties.HEARTBEAT_UPDATE_TIMEOUT);
35+
public static final long HeartBeatUpdateFreq = AgentPropertiesFileHandler.getPropertyValue(AgentProperties.KVM_HEARTBEAT_UPDATE_FREQUENCY);
36+
public static final long HeartBeatUpdateMaxTries = AgentPropertiesFileHandler.getPropertyValue(AgentProperties.KVM_HEARTBEAT_UPDATE_MAX_TRIES);
37+
public static final long HeartBeatUpdateRetrySleep = AgentPropertiesFileHandler.getPropertyValue(AgentProperties.KVM_HEARTBEAT_UPDATE_RETRY_SLEEP);
38+
public static final long HeartBeatCheckerTimeout = AgentPropertiesFileHandler.getPropertyValue(AgentProperties.KVM_HEARTBEAT_CHECKER_TIMEOUT);
3739

3840

3941
public KVMPhysicalDisk createPhysicalDisk(String volumeUuid, PhysicalDiskFormat format, Storage.ProvisioningType provisioningType, long size, byte[] passphrase);

0 commit comments

Comments
 (0)