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>
This commit is contained in:
Stephan Krug 2023-11-16 05:17:17 -03:00 committed by GitHub
parent be4a648f5a
commit 267a457efc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 60 additions and 13 deletions

View File

@ -407,3 +407,15 @@ iscsi.session.cleanup.enabled=false
# The path of an executable file/script for host health check for CloudStack to Auto Disable/Enable the host # The path of an executable file/script for host health check for CloudStack to Auto Disable/Enable the host
# depending on the return value of the file/script # depending on the return value of the file/script
# agent.health.check.script.path= # agent.health.check.script.path=
# Time interval (in milliseconds) between KVM heartbeats.
# kvm.heartbeat.update.frequency=60000
# Number of maximum tries to KVM heartbeats.
# kvm.heartbeat.update.max.tries=5
# Time amount (in milliseconds) for the KVM heartbeat retry sleep.
# kvm.heartbeat.update.retry.sleep=10000
# Timeout (in milliseconds) of the KVM heartbeat checker.
# kvm.heartbeat.checker.timeout=360000

View File

@ -539,10 +539,10 @@ public class AgentProperties{
/** /**
* Heartbeat update timeout (in ms).<br> * Heartbeat update timeout (in ms).<br>
* Depending on the use case, this timeout might need increasing/decreasing.<br> * Depending on the use case, this timeout might need increasing/decreasing.<br>
* Data type: Integer.<br> * Data type: Long.<br>
* Default value: <code>60000</code> * Default value: <code>60000L</code>
*/ */
public static final Property<Integer> HEARTBEAT_UPDATE_TIMEOUT = new Property<>("heartbeat.update.timeout", 60000); public static final Property<Long> HEARTBEAT_UPDATE_TIMEOUT = new Property<>("heartbeat.update.timeout", 60000L);
/** /**
* The timeout (in seconds) to retrieve the target's domain ID when migrating a VM with KVM. <br> * The timeout (in seconds) to retrieve the target's domain ID when migrating a VM with KVM. <br>
@ -740,6 +740,38 @@ public class AgentProperties{
*/ */
public static final Property<String> CONTROL_CIDR = new Property<>("control.cidr", "169.254.0.0/16"); public static final Property<String> CONTROL_CIDR = new Property<>("control.cidr", "169.254.0.0/16");
/**
* Time interval (in milliseconds) between KVM heartbeats. <br>
* This property is for KVM only.
* Data type: Long.<br>
* Default value: <code>60000l</code>
*/
public static final Property<Long> KVM_HEARTBEAT_UPDATE_FREQUENCY = new Property<>("kvm.heartbeat.update.frequency", 60000L);
/**
* Number of maximum tries to KVM heartbeats. <br>
* This property is for KVM only.
* Data type: Long.<br>
* Default value: <code>5l</code>
*/
public static final Property<Long> KVM_HEARTBEAT_UPDATE_MAX_TRIES = new Property<>("kvm.heartbeat.update.max.tries", 5L);
/**
* Time amount (in milliseconds) for the KVM heartbeat retry sleep. <br>
* This property is for KVM only.
* Data type: Long.<br>
* Default value: <code>10000l</code>
*/
public static final Property<Long> KVM_HEARTBEAT_UPDATE_RETRY_SLEEP = new Property<>("kvm.heartbeat.update.retry.sleep", 10000L);
/**
* Timeout (in milliseconds) of the KVM heartbeat checker. <br>
* This property is for KVM only.
* Data type: Long.<br>
* Default value: <code>360000l</code>
*/
public static final Property<Long> KVM_HEARTBEAT_CHECKER_TIMEOUT = new Property<>("kvm.heartbeat.checker.timeout", 360000L);
public static class Property <T>{ public static class Property <T>{
private String name; private String name;
private T defaultValue; private T defaultValue;

View File

@ -28,15 +28,17 @@ import com.cloud.hypervisor.kvm.storage.KVMStoragePool;
import com.cloud.utils.script.OutputInterpreter; import com.cloud.utils.script.OutputInterpreter;
import com.cloud.utils.script.OutputInterpreter.AllLinesParser; import com.cloud.utils.script.OutputInterpreter.AllLinesParser;
import com.cloud.utils.script.Script; import com.cloud.utils.script.Script;
import com.cloud.agent.properties.AgentProperties;
import com.cloud.agent.properties.AgentPropertiesFileHandler;
public class KVMHABase { public class KVMHABase {
private static final Logger s_logger = Logger.getLogger(KVMHABase.class); private static final Logger s_logger = Logger.getLogger(KVMHABase.class);
private long _timeout = 60000; /* 1 minutes */ private long _timeout = 60000; /* 1 minutes */
protected static String s_heartBeatPath; protected static String s_heartBeatPath;
protected long _heartBeatUpdateTimeout = 60000; protected long _heartBeatUpdateTimeout = AgentPropertiesFileHandler.getPropertyValue(AgentProperties.HEARTBEAT_UPDATE_TIMEOUT);
protected long _heartBeatUpdateFreq = 60000; protected long _heartBeatUpdateFreq = AgentPropertiesFileHandler.getPropertyValue(AgentProperties.KVM_HEARTBEAT_UPDATE_FREQUENCY);
protected long _heartBeatUpdateMaxTries = 5; protected long _heartBeatUpdateMaxTries = AgentPropertiesFileHandler.getPropertyValue(AgentProperties.KVM_HEARTBEAT_UPDATE_MAX_TRIES);
protected long _heartBeatUpdateRetrySleep = 10000; protected long _heartBeatUpdateRetrySleep = AgentPropertiesFileHandler.getPropertyValue(AgentProperties.KVM_HEARTBEAT_UPDATE_RETRY_SLEEP);
public static enum PoolType { public static enum PoolType {
PrimaryStorage, SecondaryStorage PrimaryStorage, SecondaryStorage

View File

@ -48,7 +48,6 @@ public class KVMHAMonitor extends KVMHABase implements Runnable {
hostPrivateIp = host; hostPrivateIp = host;
configureHeartBeatPath(scriptPath); configureHeartBeatPath(scriptPath);
_heartBeatUpdateTimeout = AgentPropertiesFileHandler.getPropertyValue(AgentProperties.HEARTBEAT_UPDATE_TIMEOUT);
rebootHostAndAlertManagementOnHeartbeatTimeout = AgentPropertiesFileHandler.getPropertyValue(AgentProperties.REBOOT_HOST_AND_ALERT_MANAGEMENT_ON_HEARTBEAT_TIMEOUT); rebootHostAndAlertManagementOnHeartbeatTimeout = AgentPropertiesFileHandler.getPropertyValue(AgentProperties.REBOOT_HOST_AND_ALERT_MANAGEMENT_ON_HEARTBEAT_TIMEOUT);
} }

View File

@ -19,6 +19,8 @@ package com.cloud.hypervisor.kvm.storage;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import com.cloud.agent.properties.AgentProperties;
import com.cloud.agent.properties.AgentPropertiesFileHandler;
import org.apache.cloudstack.utils.qemu.QemuImg.PhysicalDiskFormat; import org.apache.cloudstack.utils.qemu.QemuImg.PhysicalDiskFormat;
import org.joda.time.Duration; import org.joda.time.Duration;
@ -29,11 +31,11 @@ import com.cloud.storage.Storage.StoragePoolType;
public interface KVMStoragePool { public interface KVMStoragePool {
public static final long HeartBeatUpdateTimeout = 60000; public static final long HeartBeatUpdateTimeout = AgentPropertiesFileHandler.getPropertyValue(AgentProperties.HEARTBEAT_UPDATE_TIMEOUT);
public static final long HeartBeatUpdateFreq = 60000; public static final long HeartBeatUpdateFreq = AgentPropertiesFileHandler.getPropertyValue(AgentProperties.KVM_HEARTBEAT_UPDATE_FREQUENCY);
public static final long HeartBeatUpdateMaxTries = 5; public static final long HeartBeatUpdateMaxTries = AgentPropertiesFileHandler.getPropertyValue(AgentProperties.KVM_HEARTBEAT_UPDATE_MAX_TRIES);
public static final long HeartBeatUpdateRetrySleep = 10000; public static final long HeartBeatUpdateRetrySleep = AgentPropertiesFileHandler.getPropertyValue(AgentProperties.KVM_HEARTBEAT_UPDATE_RETRY_SLEEP);
public static final long HeartBeatCheckerTimeout = 360000; // 6 minutes public static final long HeartBeatCheckerTimeout = AgentPropertiesFileHandler.getPropertyValue(AgentProperties.KVM_HEARTBEAT_CHECKER_TIMEOUT);
public KVMPhysicalDisk createPhysicalDisk(String volumeUuid, PhysicalDiskFormat format, Storage.ProvisioningType provisioningType, long size, byte[] passphrase); public KVMPhysicalDisk createPhysicalDisk(String volumeUuid, PhysicalDiskFormat format, Storage.ProvisioningType provisioningType, long size, byte[] passphrase);