Skip to content

Commit c3bb1bb

Browse files
committed
externalise timeouts
1 parent 380c3fb commit c3bb1bb

6 files changed

Lines changed: 34 additions & 5 deletions

File tree

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,14 @@ public class AgentProperties{
659659
*/
660660
public static final Property<Integer> STOP_SCRIPT_TIMEOUT = new Property<>("stop.script.timeout", 120);
661661

662+
/**
663+
* Time (in seconds) to wait for libvirt script to check host uefi status.<br>
664+
* If the time is exceeded, uefi will be disabled on the host.<br>
665+
* Data type: Integer.<br>
666+
* Default value: <code>60</code>
667+
*/
668+
public static final Property<Integer> LIBVIRT_HOST_UEFI_SCRIPT_TIMEOUT = new Property<>("libvirt.host.uefi.script.timeout", 60);
669+
662670
/**
663671
* Definition of VMs video model type.<br>
664672
* Data type: String.<br>

engine/api/src/main/java/org/apache/cloudstack/engine/subsystem/api/storage/HypervisorHostListener.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import com.cloud.exception.StorageConflictException;
2222

2323
public interface HypervisorHostListener {
24+
2425
boolean hostAdded(long hostId);
2526

2627
boolean hostConnect(long hostId, long poolId) throws StorageConflictException;

engine/components-api/src/main/java/com/cloud/agent/AgentManager.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ public interface AgentManager {
4747
"according to the hosts health check results",
4848
true, ConfigKey.Scope.Cluster, null);
4949

50+
ConfigKey<Integer> ReadyCommandWait = new ConfigKey<Integer>("Advanced", Integer.class, "ready.command.wait",
51+
"60", "Time in seconds to wait for Ready command to return", true);
52+
5053
public enum TapAgentsAction {
5154
Add, Del, Contains,
5255
}

engine/orchestration/src/main/java/com/cloud/agent/manager/AgentManagerImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ protected AgentAttache notifyMonitorsOfConnection(final AgentAttache attache, fi
596596

597597
final Long dcId = host.getDataCenterId();
598598
final ReadyCommand ready = new ReadyCommand(dcId, host.getId(), NumbersUtil.enableHumanReadableSizes);
599-
ready.setWait(60);
599+
ready.setWait(ReadyCommandWait.value());
600600
final Answer answer = easySend(hostId, ready);
601601
if (answer == null || !answer.getResult()) {
602602
// this is tricky part for secondary storage
@@ -1838,7 +1838,7 @@ public String getConfigComponentName() {
18381838
@Override
18391839
public ConfigKey<?>[] getConfigKeys() {
18401840
return new ConfigKey<?>[] { CheckTxnBeforeSending, Workers, Port, Wait, AlertWait, DirectAgentLoadSize,
1841-
DirectAgentPoolSize, DirectAgentThreadCap, EnableKVMAutoEnableDisable };
1841+
DirectAgentPoolSize, DirectAgentThreadCap, EnableKVMAutoEnableDisable, ReadyCommandWait };
18421842
}
18431843

18441844
protected class SetHostParamsListener implements Listener {

engine/storage/volume/src/main/java/org/apache/cloudstack/storage/datastore/provider/DefaultHostListener.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
import com.cloud.utils.exception.CloudRuntimeException;
4646
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
4747
import org.apache.cloudstack.engine.subsystem.api.storage.HypervisorHostListener;
48+
import org.apache.cloudstack.framework.config.ConfigKey;
49+
import org.apache.cloudstack.framework.config.Configurable;
4850
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
4951
import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailVO;
5052
import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailsDao;
@@ -55,8 +57,12 @@
5557
import javax.inject.Inject;
5658
import java.util.List;
5759

58-
public class DefaultHostListener implements HypervisorHostListener {
60+
public class DefaultHostListener implements HypervisorHostListener, Configurable {
5961
private static final Logger s_logger = Logger.getLogger(DefaultHostListener.class);
62+
ConfigKey<Integer> ModifyStoragePoolCommandWait = new ConfigKey<Integer>("Advanced", Integer.class,
63+
"modify.storage.pool.command.wait", "60",
64+
"Time in seconds to wait for ModifyStoragePoolCommand command to return", true);
65+
6066
@Inject
6167
AgentManager agentMgr;
6268
@Inject
@@ -84,6 +90,14 @@ public class DefaultHostListener implements HypervisorHostListener {
8490
@Inject
8591
NetworkDao networkDao;
8692

93+
@Override
94+
public String getConfigComponentName() {
95+
return DefaultHostListener.class.getSimpleName();
96+
}
97+
@Override
98+
public ConfigKey<?>[] getConfigKeys() {
99+
return new ConfigKey<?>[] {ModifyStoragePoolCommandWait};
100+
}
87101

88102
@Override
89103
public boolean hostAdded(long hostId) {
@@ -121,7 +135,7 @@ private NicTO createNicTOFromNetworkAndOffering(NetworkVO networkVO, NetworkOffe
121135
public boolean hostConnect(long hostId, long poolId) throws StorageConflictException {
122136
StoragePool pool = (StoragePool) this.dataStoreMgr.getDataStore(poolId, DataStoreRole.Primary);
123137
ModifyStoragePoolCommand cmd = new ModifyStoragePoolCommand(true, pool);
124-
cmd.setWait(60);
138+
cmd.setWait(ModifyStoragePoolCommandWait.value());
125139
final Answer answer = agentMgr.easySend(hostId, cmd);
126140

127141
if (answer == null) {

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
import com.cloud.agent.api.Answer;
2626
import com.cloud.agent.api.ReadyAnswer;
2727
import com.cloud.agent.api.ReadyCommand;
28+
import com.cloud.agent.properties.AgentProperties;
29+
import com.cloud.agent.properties.AgentPropertiesFileHandler;
2830
import com.cloud.host.Host;
2931
import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource;
3032
import com.cloud.resource.CommandWrapper;
@@ -51,11 +53,12 @@ public Answer execute(final ReadyCommand command, final LibvirtComputingResource
5153

5254
private boolean hostSupportsUefi(boolean isUbuntuHost) {
5355
String cmd = "rpm -qa | grep -i ovmf";
56+
int timeout = AgentPropertiesFileHandler.getPropertyValue(AgentProperties.LIBVIRT_HOST_UEFI_SCRIPT_TIMEOUT) * 1000; // Get property value & convert to milliseconds
5457
if (isUbuntuHost) {
5558
cmd = "dpkg -l ovmf";
5659
}
5760
s_logger.debug("Running command : " + cmd);
58-
int result = Script.runSimpleBashScriptForExitValue(cmd, 60 * 1000, false);
61+
int result = Script.runSimpleBashScriptForExitValue(cmd, timeout, false);
5962
s_logger.debug("Got result : " + result);
6063
return result == 0;
6164
}

0 commit comments

Comments
 (0)