This is an automated email from the ASF dual-hosted git repository.

dahn pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudstack.git


The following commit(s) were added to refs/heads/main by this push:
     new 267a457efc5 Externalize KVM HA heartbeat frequency (#6892)
267a457efc5 is described below

commit 267a457efc55755583dd441c340a1ec1914615f2
Author: Stephan Krug <[email protected]>
AuthorDate: Thu Nov 16 05:17:17 2023 -0300

    Externalize KVM HA heartbeat frequency (#6892)
    
    Co-authored-by: Stephan Krug <[email protected]>
    Co-authored-by: GaOrtiga <[email protected]>
    Co-authored-by: dahn <[email protected]>
---
 agent/conf/agent.properties                        | 12 +++++++
 .../cloud/agent/properties/AgentProperties.java    | 38 ++++++++++++++++++++--
 .../cloud/hypervisor/kvm/resource/KVMHABase.java   | 10 +++---
 .../hypervisor/kvm/resource/KVMHAMonitor.java      |  1 -
 .../hypervisor/kvm/storage/KVMStoragePool.java     | 12 ++++---
 5 files changed, 60 insertions(+), 13 deletions(-)

diff --git a/agent/conf/agent.properties b/agent/conf/agent.properties
index b88da3621cd..3f07ba16237 100644
--- a/agent/conf/agent.properties
+++ b/agent/conf/agent.properties
@@ -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
 # depending on the return value of the file/script
 # 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
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 610c5be759f..8f51d470f07 100644
--- a/agent/src/main/java/com/cloud/agent/properties/AgentProperties.java
+++ b/agent/src/main/java/com/cloud/agent/properties/AgentProperties.java
@@ -539,10 +539,10 @@ public class AgentProperties{
     /**
      * Heartbeat update timeout (in ms).<br>
      * Depending on the use case, this timeout might need 
increasing/decreasing.<br>
-     * Data type: Integer.<br>
-     * Default value: <code>60000</code>
+     * Data type: Long.<br>
+     * 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>
@@ -740,6 +740,38 @@ public class AgentProperties{
      */
     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>{
         private String name;
         private T defaultValue;
diff --git 
a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/KVMHABase.java
 
b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/KVMHABase.java
index 093070fddd6..b9abea4f0bc 100644
--- 
a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/KVMHABase.java
+++ 
b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/KVMHABase.java
@@ -28,15 +28,17 @@ import com.cloud.hypervisor.kvm.storage.KVMStoragePool;
 import com.cloud.utils.script.OutputInterpreter;
 import com.cloud.utils.script.OutputInterpreter.AllLinesParser;
 import com.cloud.utils.script.Script;
+import com.cloud.agent.properties.AgentProperties;
+import com.cloud.agent.properties.AgentPropertiesFileHandler;
 
 public class KVMHABase {
     private static final Logger s_logger = Logger.getLogger(KVMHABase.class);
     private long _timeout = 60000; /* 1 minutes */
     protected static String s_heartBeatPath;
-    protected long _heartBeatUpdateTimeout = 60000;
-    protected long _heartBeatUpdateFreq = 60000;
-    protected long _heartBeatUpdateMaxTries = 5;
-    protected long _heartBeatUpdateRetrySleep = 10000;
+    protected long _heartBeatUpdateTimeout = 
AgentPropertiesFileHandler.getPropertyValue(AgentProperties.HEARTBEAT_UPDATE_TIMEOUT);
+    protected long _heartBeatUpdateFreq = 
AgentPropertiesFileHandler.getPropertyValue(AgentProperties.KVM_HEARTBEAT_UPDATE_FREQUENCY);
+    protected long _heartBeatUpdateMaxTries = 
AgentPropertiesFileHandler.getPropertyValue(AgentProperties.KVM_HEARTBEAT_UPDATE_MAX_TRIES);
+    protected long _heartBeatUpdateRetrySleep = 
AgentPropertiesFileHandler.getPropertyValue(AgentProperties.KVM_HEARTBEAT_UPDATE_RETRY_SLEEP);
 
     public static enum PoolType {
         PrimaryStorage, SecondaryStorage
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 72944b54e92..eb09408c14e 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
@@ -48,7 +48,6 @@ public class KVMHAMonitor extends KVMHABase implements 
Runnable {
         hostPrivateIp = host;
         configureHeartBeatPath(scriptPath);
 
-        _heartBeatUpdateTimeout = 
AgentPropertiesFileHandler.getPropertyValue(AgentProperties.HEARTBEAT_UPDATE_TIMEOUT);
         rebootHostAndAlertManagementOnHeartbeatTimeout = 
AgentPropertiesFileHandler.getPropertyValue(AgentProperties.REBOOT_HOST_AND_ALERT_MANAGEMENT_ON_HEARTBEAT_TIMEOUT);
     }
 
diff --git 
a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/KVMStoragePool.java
 
b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/KVMStoragePool.java
index 98e779253cc..43a09ccf2bf 100644
--- 
a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/KVMStoragePool.java
+++ 
b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/KVMStoragePool.java
@@ -19,6 +19,8 @@ package com.cloud.hypervisor.kvm.storage;
 import java.util.List;
 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.joda.time.Duration;
 
@@ -29,11 +31,11 @@ import com.cloud.storage.Storage.StoragePoolType;
 
 public interface KVMStoragePool {
 
-    public static final long HeartBeatUpdateTimeout = 60000;
-    public static final long HeartBeatUpdateFreq = 60000;
-    public static final long HeartBeatUpdateMaxTries = 5;
-    public static final long HeartBeatUpdateRetrySleep = 10000;
-    public static final long HeartBeatCheckerTimeout = 360000; // 6 minutes
+    public static final long HeartBeatUpdateTimeout = 
AgentPropertiesFileHandler.getPropertyValue(AgentProperties.HEARTBEAT_UPDATE_TIMEOUT);
+    public static final long HeartBeatUpdateFreq = 
AgentPropertiesFileHandler.getPropertyValue(AgentProperties.KVM_HEARTBEAT_UPDATE_FREQUENCY);
+    public static final long HeartBeatUpdateMaxTries = 
AgentPropertiesFileHandler.getPropertyValue(AgentProperties.KVM_HEARTBEAT_UPDATE_MAX_TRIES);
+    public static final long HeartBeatUpdateRetrySleep = 
AgentPropertiesFileHandler.getPropertyValue(AgentProperties.KVM_HEARTBEAT_UPDATE_RETRY_SLEEP);
+    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);

Reply via email to