From bd175f7911a2e745d6aef7e500ee2dae3bb68f71 Mon Sep 17 00:00:00 2001 From: Daniel Augusto Veronezi Salvador Date: Fri, 2 Feb 2024 20:47:23 -0300 Subject: [PATCH 01/23] Create migration path structure --- .../cloud/upgrade/DatabaseUpgradeChecker.java | 2 + .../upgrade/dao/Upgrade41900to41910.java | 68 +++++++++++++++++++ .../db/schema-41900to41910-cleanup.sql | 20 ++++++ .../META-INF/db/schema-41900to41910.sql | 22 ++++++ 4 files changed, 112 insertions(+) create mode 100644 engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade41900to41910.java create mode 100644 engine/schema/src/main/resources/META-INF/db/schema-41900to41910-cleanup.sql create mode 100644 engine/schema/src/main/resources/META-INF/db/schema-41900to41910.sql diff --git a/engine/schema/src/main/java/com/cloud/upgrade/DatabaseUpgradeChecker.java b/engine/schema/src/main/java/com/cloud/upgrade/DatabaseUpgradeChecker.java index 697782dc1db0..23721b96512e 100644 --- a/engine/schema/src/main/java/com/cloud/upgrade/DatabaseUpgradeChecker.java +++ b/engine/schema/src/main/java/com/cloud/upgrade/DatabaseUpgradeChecker.java @@ -33,6 +33,7 @@ import javax.inject.Inject; +import com.cloud.upgrade.dao.Upgrade41900to41910; import com.cloud.utils.FileUtil; import org.apache.cloudstack.utils.CloudStackVersion; import org.apache.commons.lang3.StringUtils; @@ -224,6 +225,7 @@ public DatabaseUpgradeChecker() { .next("4.17.2.0", new Upgrade41720to41800()) .next("4.18.0.0", new Upgrade41800to41810()) .next("4.18.1.0", new Upgrade41810to41900()) + .next("4.19.0.0", new Upgrade41900to41910()) .build(); } diff --git a/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade41900to41910.java b/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade41900to41910.java new file mode 100644 index 000000000000..846fb430dca9 --- /dev/null +++ b/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade41900to41910.java @@ -0,0 +1,68 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +package com.cloud.upgrade.dao; + +import com.cloud.utils.exception.CloudRuntimeException; + +import java.io.InputStream; +import java.sql.Connection; + +public class Upgrade41900to41910 implements DbUpgrade { + + @Override + public String[] getUpgradableVersionRange() { + return new String[] {"4.19.0.0", "4.19.1.0"}; + } + + @Override + public String getUpgradedVersion() { + return "4.19.1.0"; + } + + @Override + public boolean supportsRollingUpgrade() { + return false; + } + + @Override + public InputStream[] getPrepareScripts() { + final String scriptFile = "META-INF/db/schema-41900to41910.sql"; + final InputStream script = Thread.currentThread().getContextClassLoader().getResourceAsStream(scriptFile); + if (script == null) { + throw new CloudRuntimeException("Unable to find " + scriptFile); + } + + return new InputStream[] {script}; + } + + @Override + public void performDataMigration(Connection conn) { + } + + @Override + public InputStream[] getCleanupScripts() { + final String scriptFile = "META-INF/db/schema-41900to41910-cleanup.sql"; + final InputStream script = Thread.currentThread().getContextClassLoader().getResourceAsStream(scriptFile); + if (script == null) { + throw new CloudRuntimeException("Unable to find " + scriptFile); + } + + return new InputStream[] {script}; + } + + +} diff --git a/engine/schema/src/main/resources/META-INF/db/schema-41900to41910-cleanup.sql b/engine/schema/src/main/resources/META-INF/db/schema-41900to41910-cleanup.sql new file mode 100644 index 000000000000..b580d42686f0 --- /dev/null +++ b/engine/schema/src/main/resources/META-INF/db/schema-41900to41910-cleanup.sql @@ -0,0 +1,20 @@ +-- Licensed to the Apache Software Foundation (ASF) under one +-- or more contributor license agreements. See the NOTICE file +-- distributed with this work for additional information +-- regarding copyright ownership. The ASF licenses this file +-- to you under the Apache License, Version 2.0 (the +-- "License"); you may not use this file except in compliance +-- with the License. You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, +-- software distributed under the License is distributed on an +-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +-- KIND, either express or implied. See the License for the +-- specific language governing permissions and limitations +-- under the License. + +--; +-- Schema upgrade cleanup from 4.19.0.0 to 4.19.1.0 +--; diff --git a/engine/schema/src/main/resources/META-INF/db/schema-41900to41910.sql b/engine/schema/src/main/resources/META-INF/db/schema-41900to41910.sql new file mode 100644 index 000000000000..b4494c432ae2 --- /dev/null +++ b/engine/schema/src/main/resources/META-INF/db/schema-41900to41910.sql @@ -0,0 +1,22 @@ +-- Licensed to the Apache Software Foundation (ASF) under one +-- or more contributor license agreements. See the NOTICE file +-- distributed with this work for additional information +-- regarding copyright ownership. The ASF licenses this file +-- to you under the Apache License, Version 2.0 (the +-- "License"); you may not use this file except in compliance +-- with the License. You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, +-- software distributed under the License is distributed on an +-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +-- KIND, either express or implied. See the License for the +-- specific language governing permissions and limitations +-- under the License. + +--; +-- Schema upgrade from 4.19.0.0 to 4.19.1.0 +--; + + From 687daf9de1e8fbbeb5ba5b3c65a949ec3a0ba7ee Mon Sep 17 00:00:00 2001 From: Daniel Augusto Veronezi Salvador Date: Fri, 2 Feb 2024 20:48:01 -0300 Subject: [PATCH 02/23] Create table, model and DAO --- .../META-INF/db/schema-41900to41910.sql | 7 ++- .../config/dao/CommandTimeoutDao.java | 25 +++++++++ .../config/impl/CommandTimeoutVO.java | 52 +++++++++++++++++++ 3 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 framework/config/src/main/java/org/apache/cloudstack/framework/config/dao/CommandTimeoutDao.java create mode 100644 framework/config/src/main/java/org/apache/cloudstack/framework/config/impl/CommandTimeoutVO.java diff --git a/engine/schema/src/main/resources/META-INF/db/schema-41900to41910.sql b/engine/schema/src/main/resources/META-INF/db/schema-41900to41910.sql index b4494c432ae2..2180cb401315 100644 --- a/engine/schema/src/main/resources/META-INF/db/schema-41900to41910.sql +++ b/engine/schema/src/main/resources/META-INF/db/schema-41900to41910.sql @@ -19,4 +19,9 @@ -- Schema upgrade from 4.19.0.0 to 4.19.1.0 --; - +CREATE TABLE IF NOT EXISTS `cloud`.`command_timeout` ( + command_classpath text primary key, + timeout int not null, + created datetime not null, + updated datetime not null +) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/framework/config/src/main/java/org/apache/cloudstack/framework/config/dao/CommandTimeoutDao.java b/framework/config/src/main/java/org/apache/cloudstack/framework/config/dao/CommandTimeoutDao.java new file mode 100644 index 000000000000..92ddf80c4a2c --- /dev/null +++ b/framework/config/src/main/java/org/apache/cloudstack/framework/config/dao/CommandTimeoutDao.java @@ -0,0 +1,25 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +package org.apache.cloudstack.framework.config.dao; + +import com.cloud.utils.db.GenericDao; +import org.apache.cloudstack.framework.config.impl.CommandTimeoutVO; + +public interface CommandTimeoutDao extends GenericDao { + + +} diff --git a/framework/config/src/main/java/org/apache/cloudstack/framework/config/impl/CommandTimeoutVO.java b/framework/config/src/main/java/org/apache/cloudstack/framework/config/impl/CommandTimeoutVO.java new file mode 100644 index 000000000000..ecebdabd9d82 --- /dev/null +++ b/framework/config/src/main/java/org/apache/cloudstack/framework/config/impl/CommandTimeoutVO.java @@ -0,0 +1,52 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +package org.apache.cloudstack.framework.config.impl; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import java.util.Date; + +@Entity +@Table(name = "command_timeout") +public class CommandTimeoutVO { + @Id + @Column(name = "command_classpath", length = 65535) + private String commandClasspath; + + @Column(name = "timeout") + private int timeout; + + @Column(name = "created") + @Temporal(value = TemporalType.TIMESTAMP) + private Date created; + + @Column(name = "updated") + @Temporal(value = TemporalType.TIMESTAMP) + private Date updated; + + public int getTimeout() { + return timeout; + } + + public String getCommandClasspath() { + return commandClasspath; + } +} From 1eb167253b75f160394edbfce1941c80ec9f835e Mon Sep 17 00:00:00 2001 From: Daniel Augusto Veronezi Salvador Date: Fri, 2 Feb 2024 20:48:59 -0300 Subject: [PATCH 03/23] Create method to return command timeout by classpath --- .../config/dao/CommandTimeoutDao.java | 3 +- .../config/dao/CommandTimeoutDaoImpl.java | 41 +++++++++++++++++++ ...spring-framework-config-system-context.xml | 3 ++ 3 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 framework/config/src/main/java/org/apache/cloudstack/framework/config/dao/CommandTimeoutDaoImpl.java diff --git a/framework/config/src/main/java/org/apache/cloudstack/framework/config/dao/CommandTimeoutDao.java b/framework/config/src/main/java/org/apache/cloudstack/framework/config/dao/CommandTimeoutDao.java index 92ddf80c4a2c..eab258fb9cc9 100644 --- a/framework/config/src/main/java/org/apache/cloudstack/framework/config/dao/CommandTimeoutDao.java +++ b/framework/config/src/main/java/org/apache/cloudstack/framework/config/dao/CommandTimeoutDao.java @@ -21,5 +21,6 @@ public interface CommandTimeoutDao extends GenericDao { - + CommandTimeoutVO findByCommandClasspath(String commandClasspath); + } diff --git a/framework/config/src/main/java/org/apache/cloudstack/framework/config/dao/CommandTimeoutDaoImpl.java b/framework/config/src/main/java/org/apache/cloudstack/framework/config/dao/CommandTimeoutDaoImpl.java new file mode 100644 index 000000000000..da6735a5d757 --- /dev/null +++ b/framework/config/src/main/java/org/apache/cloudstack/framework/config/dao/CommandTimeoutDaoImpl.java @@ -0,0 +1,41 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +package org.apache.cloudstack.framework.config.dao; + +import com.cloud.utils.db.GenericDaoBase; +import com.cloud.utils.db.SearchBuilder; +import com.cloud.utils.db.SearchCriteria; +import org.apache.cloudstack.framework.config.impl.CommandTimeoutVO; + +public class CommandTimeoutDaoImpl extends GenericDaoBase implements CommandTimeoutDao { + + private SearchBuilder commandTimeoutVoSearchBuilder; + + public CommandTimeoutDaoImpl() { + super(); + + commandTimeoutVoSearchBuilder = createSearchBuilder(); + commandTimeoutVoSearchBuilder.and("command_classpath", commandTimeoutVoSearchBuilder.entity().getCommandClasspath(), SearchCriteria.Op.EQ); + } + + @Override + public CommandTimeoutVO findByCommandClasspath(String commandClasspath) { + SearchCriteria searchCriteria = commandTimeoutVoSearchBuilder.create(); + searchCriteria.setParameters("command_classpath", commandClasspath); + return findOneBy(searchCriteria); + } +} diff --git a/framework/config/src/main/resources/META-INF/cloudstack/system/spring-framework-config-system-context.xml b/framework/config/src/main/resources/META-INF/cloudstack/system/spring-framework-config-system-context.xml index 1a3bcf441e47..54efffd581c4 100644 --- a/framework/config/src/main/resources/META-INF/cloudstack/system/spring-framework-config-system-context.xml +++ b/framework/config/src/main/resources/META-INF/cloudstack/system/spring-framework-config-system-context.xml @@ -48,6 +48,9 @@ + + From 21aa879c19e55dd94db993e97e7d2a795d7c200e Mon Sep 17 00:00:00 2001 From: Daniel Augusto Veronezi Salvador Date: Fri, 2 Feb 2024 20:49:25 -0300 Subject: [PATCH 04/23] Retrieve command timeout on fallback --- .../cloud/agent/manager/AgentManagerImpl.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/engine/orchestration/src/main/java/com/cloud/agent/manager/AgentManagerImpl.java b/engine/orchestration/src/main/java/com/cloud/agent/manager/AgentManagerImpl.java index 606a902dce7c..717b2d1177f1 100644 --- a/engine/orchestration/src/main/java/com/cloud/agent/manager/AgentManagerImpl.java +++ b/engine/orchestration/src/main/java/com/cloud/agent/manager/AgentManagerImpl.java @@ -46,7 +46,9 @@ import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService; import org.apache.cloudstack.framework.config.ConfigKey; import org.apache.cloudstack.framework.config.Configurable; +import org.apache.cloudstack.framework.config.dao.CommandTimeoutDao; import org.apache.cloudstack.framework.config.dao.ConfigurationDao; +import org.apache.cloudstack.framework.config.impl.CommandTimeoutVO; import org.apache.cloudstack.framework.jobs.AsyncJob; import org.apache.cloudstack.framework.jobs.AsyncJobExecutionContext; import org.apache.cloudstack.managed.context.ManagedContextRunnable; @@ -159,6 +161,10 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl protected HostPodDao _podDao = null; @Inject protected ConfigurationDao _configDao = null; + + @Inject + protected CommandTimeoutDao commandTimeoutDao; + @Inject protected ClusterDao _clusterDao = null; @@ -439,7 +445,18 @@ public Answer[] send(final Long hostId, final Commands commands, int timeout) th } if (timeout <= 0) { - timeout = Wait.value(); + + for (Command command : commands) { + CommandTimeoutVO commandTimeoutVo = commandTimeoutDao.findByCommandClasspath(command.getClass().getName()); + + if (commandTimeoutVo != null && commandTimeoutVo.getTimeout() > timeout) { + timeout = commandTimeoutVo.getTimeout(); + } + } + + if (timeout <= 0) { + timeout = Wait.value(); + } } if (CheckTxnBeforeSending.value()) { From 96d6cd95ca9e93818d2960ab340ad1240d3576ea Mon Sep 17 00:00:00 2001 From: Daniel Augusto Veronezi Salvador Date: Tue, 6 Feb 2024 22:10:29 -0300 Subject: [PATCH 05/23] Move changes to 4.20 --- .../upgrade/dao/Upgrade41900to41910.java | 68 ------------------- .../db/schema-41900to41910-cleanup.sql | 20 ------ .../META-INF/db/schema-41900to41910.sql | 27 -------- .../META-INF/db/schema-41900to42000.sql | 7 ++ 4 files changed, 7 insertions(+), 115 deletions(-) delete mode 100644 engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade41900to41910.java delete mode 100644 engine/schema/src/main/resources/META-INF/db/schema-41900to41910-cleanup.sql delete mode 100644 engine/schema/src/main/resources/META-INF/db/schema-41900to41910.sql diff --git a/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade41900to41910.java b/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade41900to41910.java deleted file mode 100644 index 846fb430dca9..000000000000 --- a/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade41900to41910.java +++ /dev/null @@ -1,68 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -package com.cloud.upgrade.dao; - -import com.cloud.utils.exception.CloudRuntimeException; - -import java.io.InputStream; -import java.sql.Connection; - -public class Upgrade41900to41910 implements DbUpgrade { - - @Override - public String[] getUpgradableVersionRange() { - return new String[] {"4.19.0.0", "4.19.1.0"}; - } - - @Override - public String getUpgradedVersion() { - return "4.19.1.0"; - } - - @Override - public boolean supportsRollingUpgrade() { - return false; - } - - @Override - public InputStream[] getPrepareScripts() { - final String scriptFile = "META-INF/db/schema-41900to41910.sql"; - final InputStream script = Thread.currentThread().getContextClassLoader().getResourceAsStream(scriptFile); - if (script == null) { - throw new CloudRuntimeException("Unable to find " + scriptFile); - } - - return new InputStream[] {script}; - } - - @Override - public void performDataMigration(Connection conn) { - } - - @Override - public InputStream[] getCleanupScripts() { - final String scriptFile = "META-INF/db/schema-41900to41910-cleanup.sql"; - final InputStream script = Thread.currentThread().getContextClassLoader().getResourceAsStream(scriptFile); - if (script == null) { - throw new CloudRuntimeException("Unable to find " + scriptFile); - } - - return new InputStream[] {script}; - } - - -} diff --git a/engine/schema/src/main/resources/META-INF/db/schema-41900to41910-cleanup.sql b/engine/schema/src/main/resources/META-INF/db/schema-41900to41910-cleanup.sql deleted file mode 100644 index b580d42686f0..000000000000 --- a/engine/schema/src/main/resources/META-INF/db/schema-41900to41910-cleanup.sql +++ /dev/null @@ -1,20 +0,0 @@ --- Licensed to the Apache Software Foundation (ASF) under one --- or more contributor license agreements. See the NOTICE file --- distributed with this work for additional information --- regarding copyright ownership. The ASF licenses this file --- to you under the Apache License, Version 2.0 (the --- "License"); you may not use this file except in compliance --- with the License. You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, --- software distributed under the License is distributed on an --- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY --- KIND, either express or implied. See the License for the --- specific language governing permissions and limitations --- under the License. - ---; --- Schema upgrade cleanup from 4.19.0.0 to 4.19.1.0 ---; diff --git a/engine/schema/src/main/resources/META-INF/db/schema-41900to41910.sql b/engine/schema/src/main/resources/META-INF/db/schema-41900to41910.sql deleted file mode 100644 index 2180cb401315..000000000000 --- a/engine/schema/src/main/resources/META-INF/db/schema-41900to41910.sql +++ /dev/null @@ -1,27 +0,0 @@ --- Licensed to the Apache Software Foundation (ASF) under one --- or more contributor license agreements. See the NOTICE file --- distributed with this work for additional information --- regarding copyright ownership. The ASF licenses this file --- to you under the Apache License, Version 2.0 (the --- "License"); you may not use this file except in compliance --- with the License. You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, --- software distributed under the License is distributed on an --- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY --- KIND, either express or implied. See the License for the --- specific language governing permissions and limitations --- under the License. - ---; --- Schema upgrade from 4.19.0.0 to 4.19.1.0 ---; - -CREATE TABLE IF NOT EXISTS `cloud`.`command_timeout` ( - command_classpath text primary key, - timeout int not null, - created datetime not null, - updated datetime not null -) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/engine/schema/src/main/resources/META-INF/db/schema-41900to42000.sql b/engine/schema/src/main/resources/META-INF/db/schema-41900to42000.sql index 1c368a2fbee2..71203f704cda 100644 --- a/engine/schema/src/main/resources/META-INF/db/schema-41900to42000.sql +++ b/engine/schema/src/main/resources/META-INF/db/schema-41900to42000.sql @@ -18,3 +18,10 @@ --; -- Schema upgrade from 4.19.0.0 to 4.20.0.0 --; + +CREATE TABLE IF NOT EXISTS `cloud`.`command_timeout` ( + command_classpath text primary key, + timeout int not null, + created datetime not null, + updated datetime not null +) ENGINE=InnoDB DEFAULT CHARSET=utf8; \ No newline at end of file From a058028b4789e874abd74a5b513c0ac96a5535b0 Mon Sep 17 00:00:00 2001 From: Daniel Augusto Veronezi Salvador Date: Tue, 6 Feb 2024 22:19:19 -0300 Subject: [PATCH 06/23] Add new line to the end of file --- .../src/main/resources/META-INF/db/schema-41900to42000.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engine/schema/src/main/resources/META-INF/db/schema-41900to42000.sql b/engine/schema/src/main/resources/META-INF/db/schema-41900to42000.sql index 71203f704cda..8fb4bab85b74 100644 --- a/engine/schema/src/main/resources/META-INF/db/schema-41900to42000.sql +++ b/engine/schema/src/main/resources/META-INF/db/schema-41900to42000.sql @@ -24,4 +24,4 @@ CREATE TABLE IF NOT EXISTS `cloud`.`command_timeout` ( timeout int not null, created datetime not null, updated datetime not null -) ENGINE=InnoDB DEFAULT CHARSET=utf8; \ No newline at end of file +) ENGINE=InnoDB DEFAULT CHARSET=utf8; From a067ebbdba0f10e38deb4569c3eb151ed6bb569e Mon Sep 17 00:00:00 2001 From: Daniel Augusto Veronezi Salvador Date: Tue, 6 Feb 2024 23:05:05 -0300 Subject: [PATCH 07/23] Use max to optimize process, extract block to method and add logs --- .../cloud/agent/manager/AgentManagerImpl.java | 42 ++++++++++++------- .../config/dao/CommandTimeoutDao.java | 4 +- .../config/dao/CommandTimeoutDaoImpl.java | 22 ++++++---- .../config/impl/CommandTimeoutVO.java | 4 +- .../com/cloud/agent/manager/Commands.java | 4 ++ 5 files changed, 52 insertions(+), 24 deletions(-) diff --git a/engine/orchestration/src/main/java/com/cloud/agent/manager/AgentManagerImpl.java b/engine/orchestration/src/main/java/com/cloud/agent/manager/AgentManagerImpl.java index 717b2d1177f1..235ecd9c28a3 100644 --- a/engine/orchestration/src/main/java/com/cloud/agent/manager/AgentManagerImpl.java +++ b/engine/orchestration/src/main/java/com/cloud/agent/manager/AgentManagerImpl.java @@ -25,6 +25,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ExecutorService; import java.util.concurrent.LinkedBlockingQueue; @@ -34,6 +35,7 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; +import java.util.stream.Collectors; import javax.inject.Inject; import javax.naming.ConfigurationException; @@ -444,20 +446,7 @@ public Answer[] send(final Long hostId, final Commands commands, int timeout) th throw new AgentUnavailableException(-1); } - if (timeout <= 0) { - - for (Command command : commands) { - CommandTimeoutVO commandTimeoutVo = commandTimeoutDao.findByCommandClasspath(command.getClass().getName()); - - if (commandTimeoutVo != null && commandTimeoutVo.getTimeout() > timeout) { - timeout = commandTimeoutVo.getTimeout(); - } - } - - if (timeout <= 0) { - timeout = Wait.value(); - } - } + timeout = getTimeoutForCommands(commands, timeout); if (CheckTxnBeforeSending.value()) { if (!noDbTxn()) { @@ -484,6 +473,31 @@ public Answer[] send(final Long hostId, final Commands commands, int timeout) th return answers; } + protected int getTimeoutForCommands(Commands commands, int timeout) { + Set commandsClassPath = commands.getCommands().stream().map(command -> command.getClass().getName()).collect(Collectors.toSet()); + + if (timeout > 0) { + s_logger.trace(String.format("The timeout [%s] was already defined for commands %s; therefore, we will use it instead of searching for the max value in table " + + "[%s].", timeout, commandsClassPath, CommandTimeoutVO.TABLE_NAME)); + return timeout; + } + + s_logger.trace(String.format("The timeout for commands %s was not defined yet; therefore, we will search for the max value between the commands in table " + + "[%s].", commandsClassPath, CommandTimeoutVO.TABLE_NAME)); + timeout = commandTimeoutDao.findMaxTimeoutBetweenCommands(commandsClassPath); + + if (timeout > 0) { + s_logger.trace(String.format("We found [%s] as the max timeout between commands %s in table [%s]; using it.", timeout, commandsClassPath, + CommandTimeoutVO.TABLE_NAME)); + } else { + timeout = Wait.value(); + s_logger.trace(String.format("We did not find a max timeout between commands %s in table [%s]; therefore, we will fallback to the value of " + + "configuration [%s]: [%s].", commandsClassPath, CommandTimeoutVO.TABLE_NAME, Wait.key(), timeout)); + } + + return timeout; + } + protected Status investigate(final AgentAttache agent) { final Long hostId = agent.getId(); final HostVO host = _hostDao.findById(hostId); diff --git a/framework/config/src/main/java/org/apache/cloudstack/framework/config/dao/CommandTimeoutDao.java b/framework/config/src/main/java/org/apache/cloudstack/framework/config/dao/CommandTimeoutDao.java index eab258fb9cc9..699862419001 100644 --- a/framework/config/src/main/java/org/apache/cloudstack/framework/config/dao/CommandTimeoutDao.java +++ b/framework/config/src/main/java/org/apache/cloudstack/framework/config/dao/CommandTimeoutDao.java @@ -19,8 +19,10 @@ import com.cloud.utils.db.GenericDao; import org.apache.cloudstack.framework.config.impl.CommandTimeoutVO; +import java.util.Set; + public interface CommandTimeoutDao extends GenericDao { - CommandTimeoutVO findByCommandClasspath(String commandClasspath); + int findMaxTimeoutBetweenCommands(Set commandsClassPath); } diff --git a/framework/config/src/main/java/org/apache/cloudstack/framework/config/dao/CommandTimeoutDaoImpl.java b/framework/config/src/main/java/org/apache/cloudstack/framework/config/dao/CommandTimeoutDaoImpl.java index da6735a5d757..e47eb3e53185 100644 --- a/framework/config/src/main/java/org/apache/cloudstack/framework/config/dao/CommandTimeoutDaoImpl.java +++ b/framework/config/src/main/java/org/apache/cloudstack/framework/config/dao/CommandTimeoutDaoImpl.java @@ -17,25 +17,31 @@ package org.apache.cloudstack.framework.config.dao; import com.cloud.utils.db.GenericDaoBase; -import com.cloud.utils.db.SearchBuilder; +import com.cloud.utils.db.GenericSearchBuilder; import com.cloud.utils.db.SearchCriteria; import org.apache.cloudstack.framework.config.impl.CommandTimeoutVO; +import org.apache.commons.lang3.ObjectUtils; + +import java.util.Set; public class CommandTimeoutDaoImpl extends GenericDaoBase implements CommandTimeoutDao { - private SearchBuilder commandTimeoutVoSearchBuilder; + private GenericSearchBuilder maxCommandTimeoutSearchBuilder; public CommandTimeoutDaoImpl() { super(); - commandTimeoutVoSearchBuilder = createSearchBuilder(); - commandTimeoutVoSearchBuilder.and("command_classpath", commandTimeoutVoSearchBuilder.entity().getCommandClasspath(), SearchCriteria.Op.EQ); + maxCommandTimeoutSearchBuilder = createSearchBuilder(Integer.class); + maxCommandTimeoutSearchBuilder.select(null, SearchCriteria.Func.MAX, maxCommandTimeoutSearchBuilder.entity().getTimeout()); + maxCommandTimeoutSearchBuilder.and("command_classpath", maxCommandTimeoutSearchBuilder.entity().getCommandClasspath(), SearchCriteria.Op.EQ); + maxCommandTimeoutSearchBuilder.done(); } @Override - public CommandTimeoutVO findByCommandClasspath(String commandClasspath) { - SearchCriteria searchCriteria = commandTimeoutVoSearchBuilder.create(); - searchCriteria.setParameters("command_classpath", commandClasspath); - return findOneBy(searchCriteria); + public int findMaxTimeoutBetweenCommands(Set commandsClassPath) { + SearchCriteria searchCriteria = maxCommandTimeoutSearchBuilder.create(); + searchCriteria.setParameters("command_classpath", commandsClassPath.toArray()); + Integer max = customSearch(searchCriteria, null).get(0); + return ObjectUtils.defaultIfNull(max, 0); } } diff --git a/framework/config/src/main/java/org/apache/cloudstack/framework/config/impl/CommandTimeoutVO.java b/framework/config/src/main/java/org/apache/cloudstack/framework/config/impl/CommandTimeoutVO.java index ecebdabd9d82..2d05c9a842e5 100644 --- a/framework/config/src/main/java/org/apache/cloudstack/framework/config/impl/CommandTimeoutVO.java +++ b/framework/config/src/main/java/org/apache/cloudstack/framework/config/impl/CommandTimeoutVO.java @@ -25,8 +25,10 @@ import java.util.Date; @Entity -@Table(name = "command_timeout") +@Table(name = CommandTimeoutVO.TABLE_NAME) public class CommandTimeoutVO { + public static final String TABLE_NAME = "command_timeout"; + @Id @Column(name = "command_classpath", length = 65535) private String commandClasspath; diff --git a/framework/ipc/src/main/java/com/cloud/agent/manager/Commands.java b/framework/ipc/src/main/java/com/cloud/agent/manager/Commands.java index 208512b5306e..24bc629ace4a 100644 --- a/framework/ipc/src/main/java/com/cloud/agent/manager/Commands.java +++ b/framework/ipc/src/main/java/com/cloud/agent/manager/Commands.java @@ -100,6 +100,10 @@ public Command[] toCommands() { return _cmds.toArray(new Command[_cmds.size()]); } + public ArrayList getCommands() { + return _cmds; + } + public void setAnswers(Answer[] answers) { _answers = answers; } From a9147b38d17f4fcd6c54f8186b7b1f11a4954cd2 Mon Sep 17 00:00:00 2001 From: Daniel Augusto Veronezi Salvador Date: Tue, 6 Feb 2024 23:29:13 -0300 Subject: [PATCH 08/23] Refactor test class structure --- .../agent/manager/AgentManagerImplTest.java | 55 +++++++++++-------- 1 file changed, 31 insertions(+), 24 deletions(-) diff --git a/engine/orchestration/src/test/java/com/cloud/agent/manager/AgentManagerImplTest.java b/engine/orchestration/src/test/java/com/cloud/agent/manager/AgentManagerImplTest.java index 376e189d8751..7bd657a147ef 100644 --- a/engine/orchestration/src/test/java/com/cloud/agent/manager/AgentManagerImplTest.java +++ b/engine/orchestration/src/test/java/com/cloud/agent/manager/AgentManagerImplTest.java @@ -29,58 +29,65 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; import org.mockito.Mockito; +import org.mockito.Spy; +import org.mockito.junit.MockitoJUnitRunner; -import java.util.ArrayList; +import java.util.List; +@RunWith(MockitoJUnitRunner.class) public class AgentManagerImplTest { - private HostDao hostDao; + @Mock + private HostDao hostDaoMock; + + @Mock private Listener storagePoolMonitor; - private AgentAttache attache; - private AgentManagerImpl mgr = Mockito.spy(new AgentManagerImpl()); - private HostVO host; - private StartupCommand[] cmds; + @InjectMocks + @Spy + private AgentManagerImpl agentManagerImplSpy; + + private HostVO host; + private StartupCommand[] cmds = new StartupCommand[]{ new StartupRoutingCommand() }; + private AgentAttache attache = new ConnectedAgentAttache(null, 1L, "kvm-attache", null, false); + @Before - public void setUp() throws Exception { + public void setUp() { host = new HostVO("some-Uuid"); host.setDataCenterId(1L); - cmds = new StartupCommand[]{new StartupRoutingCommand()}; - attache = new ConnectedAgentAttache(null, 1L, "kvm-attache", null, false); - - hostDao = Mockito.mock(HostDao.class); - storagePoolMonitor = Mockito.mock(Listener.class); - mgr._hostDao = hostDao; - mgr._hostMonitors = new ArrayList<>(); - mgr._hostMonitors.add(new Pair<>(0, storagePoolMonitor)); + agentManagerImplSpy._hostMonitors = List.of(new Pair<>(0, storagePoolMonitor)); } @Test public void testNotifyMonitorsOfConnectionNormal() throws ConnectionException { - Mockito.when(hostDao.findById(Mockito.anyLong())).thenReturn(host); + Mockito.when(hostDaoMock.findById(Mockito.anyLong())).thenReturn(host); Mockito.doNothing().when(storagePoolMonitor).processConnect(Mockito.eq(host), Mockito.eq(cmds[0]), Mockito.eq(false)); - Mockito.doReturn(true).when(mgr).handleDisconnectWithoutInvestigation(Mockito.any(attache.getClass()), Mockito.any(Status.Event.class), Mockito.anyBoolean(), Mockito.anyBoolean()); - Mockito.doReturn(Mockito.mock(Answer.class)).when(mgr).easySend(Mockito.anyLong(), Mockito.any(ReadyCommand.class)); - Mockito.doReturn(true).when(mgr).agentStatusTransitTo(Mockito.eq(host), Mockito.eq(Status.Event.Ready), Mockito.anyLong()); + Mockito.doReturn(true).when(agentManagerImplSpy).handleDisconnectWithoutInvestigation(Mockito.any(attache.getClass()), Mockito.any(Status.Event.class), Mockito.anyBoolean(), Mockito.anyBoolean()); + Mockito.doReturn(Mockito.mock(Answer.class)).when(agentManagerImplSpy).easySend(Mockito.anyLong(), Mockito.any(ReadyCommand.class)); + Mockito.doReturn(true).when(agentManagerImplSpy).agentStatusTransitTo(Mockito.eq(host), Mockito.eq(Status.Event.Ready), Mockito.anyLong()); - final AgentAttache agentAttache = mgr.notifyMonitorsOfConnection(attache, cmds, false); + final AgentAttache agentAttache = agentManagerImplSpy.notifyMonitorsOfConnection(attache, cmds, false); Assert.assertTrue(agentAttache.isReady()); // Agent is in UP state } @Test public void testNotifyMonitorsOfConnectionWhenStoragePoolConnectionHostFailure() throws ConnectionException { ConnectionException connectionException = new ConnectionException(true, "storage pool could not be connected on host"); - Mockito.when(hostDao.findById(Mockito.anyLong())).thenReturn(host); + Mockito.when(hostDaoMock.findById(Mockito.anyLong())).thenReturn(host); Mockito.doThrow(connectionException).when(storagePoolMonitor).processConnect(Mockito.eq(host), Mockito.eq(cmds[0]), Mockito.eq(false)); - Mockito.doReturn(true).when(mgr).handleDisconnectWithoutInvestigation(Mockito.any(attache.getClass()), Mockito.any(Status.Event.class), Mockito.anyBoolean(), Mockito.anyBoolean()); + Mockito.doReturn(true).when(agentManagerImplSpy).handleDisconnectWithoutInvestigation(Mockito.any(attache.getClass()), Mockito.any(Status.Event.class), Mockito.anyBoolean(), Mockito.anyBoolean()); try { - mgr.notifyMonitorsOfConnection(attache, cmds, false); + agentManagerImplSpy.notifyMonitorsOfConnection(attache, cmds, false); Assert.fail("Connection Exception was expected"); } catch (ConnectionException e) { Assert.assertEquals(e.getMessage(), connectionException.getMessage()); } - Mockito.verify(mgr, Mockito.times(1)).handleDisconnectWithoutInvestigation(Mockito.any(attache.getClass()), Mockito.eq(Status.Event.AgentDisconnected), Mockito.eq(true), Mockito.eq(true)); + Mockito.verify(agentManagerImplSpy, Mockito.times(1)).handleDisconnectWithoutInvestigation(Mockito.any(attache.getClass()), Mockito.eq(Status.Event.AgentDisconnected), Mockito.eq(true), Mockito.eq(true)); } + } From 1dd3da4d0041fee134e128f295a5340f146b17f2 Mon Sep 17 00:00:00 2001 From: Daniel Augusto Veronezi Salvador Date: Tue, 6 Feb 2024 23:44:27 -0300 Subject: [PATCH 09/23] Create unit tests --- .../cloud/agent/manager/AgentManagerImpl.java | 6 ++- .../agent/manager/AgentManagerImplTest.java | 37 ++++++++++++++++++- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/engine/orchestration/src/main/java/com/cloud/agent/manager/AgentManagerImpl.java b/engine/orchestration/src/main/java/com/cloud/agent/manager/AgentManagerImpl.java index 235ecd9c28a3..37a5bfa8c395 100644 --- a/engine/orchestration/src/main/java/com/cloud/agent/manager/AgentManagerImpl.java +++ b/engine/orchestration/src/main/java/com/cloud/agent/manager/AgentManagerImpl.java @@ -490,7 +490,7 @@ protected int getTimeoutForCommands(Commands commands, int timeout) { s_logger.trace(String.format("We found [%s] as the max timeout between commands %s in table [%s]; using it.", timeout, commandsClassPath, CommandTimeoutVO.TABLE_NAME)); } else { - timeout = Wait.value(); + timeout = getWaitValue(); s_logger.trace(String.format("We did not find a max timeout between commands %s in table [%s]; therefore, we will fallback to the value of " + "configuration [%s]: [%s].", commandsClassPath, CommandTimeoutVO.TABLE_NAME, Wait.key(), timeout)); } @@ -498,6 +498,10 @@ protected int getTimeoutForCommands(Commands commands, int timeout) { return timeout; } + protected Integer getWaitValue() { + return Wait.value(); + } + protected Status investigate(final AgentAttache agent) { final Long hostId = agent.getId(); final HostVO host = _hostDao.findById(hostId); diff --git a/engine/orchestration/src/test/java/com/cloud/agent/manager/AgentManagerImplTest.java b/engine/orchestration/src/test/java/com/cloud/agent/manager/AgentManagerImplTest.java index 7bd657a147ef..99a8904307b4 100644 --- a/engine/orchestration/src/test/java/com/cloud/agent/manager/AgentManagerImplTest.java +++ b/engine/orchestration/src/test/java/com/cloud/agent/manager/AgentManagerImplTest.java @@ -26,6 +26,7 @@ import com.cloud.host.Status; import com.cloud.host.dao.HostDao; import com.cloud.utils.Pair; +import org.apache.cloudstack.framework.config.dao.CommandTimeoutDao; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -47,6 +48,12 @@ public class AgentManagerImplTest { @Mock private Listener storagePoolMonitor; + @Mock + private Commands commandsMock; + + @Mock + private CommandTimeoutDao commandTimeoutDaoMock; + @InjectMocks @Spy private AgentManagerImpl agentManagerImplSpy; @@ -54,7 +61,7 @@ public class AgentManagerImplTest { private HostVO host; private StartupCommand[] cmds = new StartupCommand[]{ new StartupRoutingCommand() }; private AgentAttache attache = new ConnectedAgentAttache(null, 1L, "kvm-attache", null, false); - + @Before public void setUp() { host = new HostVO("some-Uuid"); @@ -90,4 +97,32 @@ public void testNotifyMonitorsOfConnectionWhenStoragePoolConnectionHostFailure() Mockito.verify(agentManagerImplSpy, Mockito.times(1)).handleDisconnectWithoutInvestigation(Mockito.any(attache.getClass()), Mockito.eq(Status.Event.AgentDisconnected), Mockito.eq(true), Mockito.eq(true)); } + @Test + public void getTimeoutForCommandsTestReturnPassedTimeout() { + int expected = 42; + int result = agentManagerImplSpy.getTimeoutForCommands(commandsMock, expected); + + Assert.assertEquals(expected, result); + } + + @Test + public void getTimeoutForCommandsTestReturnTimeoutFromTable() { + int expected = 42; + + Mockito.doReturn(expected).when(commandTimeoutDaoMock).findMaxTimeoutBetweenCommands(Mockito.any()); + int result = agentManagerImplSpy.getTimeoutForCommands(commandsMock, 0); + + Assert.assertEquals(expected, result); + } + + @Test + public void getTimeoutForCommandsTestFallbackToConfiguration() { + int expected = 42; + + Mockito.doReturn(0).when(commandTimeoutDaoMock).findMaxTimeoutBetweenCommands(Mockito.any()); + Mockito.doReturn(expected).when(agentManagerImplSpy).getWaitValue(); + int result = agentManagerImplSpy.getTimeoutForCommands(commandsMock, 0); + + Assert.assertEquals(expected, result); + } } From f8560d768294ed4c0717abb7d3f9a6b58cb7775d Mon Sep 17 00:00:00 2001 From: Daniel Augusto Veronezi Salvador Date: Wed, 7 Feb 2024 00:01:53 -0300 Subject: [PATCH 10/23] Fix table creation --- .../src/main/resources/META-INF/db/schema-41900to42000.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/engine/schema/src/main/resources/META-INF/db/schema-41900to42000.sql b/engine/schema/src/main/resources/META-INF/db/schema-41900to42000.sql index 8fb4bab85b74..af42393529b8 100644 --- a/engine/schema/src/main/resources/META-INF/db/schema-41900to42000.sql +++ b/engine/schema/src/main/resources/META-INF/db/schema-41900to42000.sql @@ -20,7 +20,8 @@ --; CREATE TABLE IF NOT EXISTS `cloud`.`command_timeout` ( - command_classpath text primary key, + id bigint(20) unsigned not null auto_increment primary key, + command_classpath text unique key, timeout int not null, created datetime not null, updated datetime not null From 0620c460ea0a66e6cb51a35847d7e5bd937c9712 Mon Sep 17 00:00:00 2001 From: Daniel Augusto Veronezi Salvador Date: Wed, 7 Feb 2024 00:08:54 -0300 Subject: [PATCH 11/23] Convert SetupCertificateCommand hardcoded timeout to table entry --- .../java/org/apache/cloudstack/ca/SetupCertificateCommand.java | 2 +- .../src/main/resources/META-INF/db/schema-41900to42000.sql | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/org/apache/cloudstack/ca/SetupCertificateCommand.java b/core/src/main/java/org/apache/cloudstack/ca/SetupCertificateCommand.java index 7727282bcee4..f385910b54f9 100644 --- a/core/src/main/java/org/apache/cloudstack/ca/SetupCertificateCommand.java +++ b/core/src/main/java/org/apache/cloudstack/ca/SetupCertificateCommand.java @@ -45,7 +45,7 @@ public SetupCertificateCommand(final Certificate certificate) { if (certificate == null) { throw new CloudRuntimeException("A null certificate was provided to setup"); } - setWait(60); + try { this.certificate = CertUtils.x509CertificateToPem(certificate.getClientCertificate()); this.caCertificates = CertUtils.x509CertificatesToPem(certificate.getCaCertificates()); diff --git a/engine/schema/src/main/resources/META-INF/db/schema-41900to42000.sql b/engine/schema/src/main/resources/META-INF/db/schema-41900to42000.sql index af42393529b8..2084c3eb96d2 100644 --- a/engine/schema/src/main/resources/META-INF/db/schema-41900to42000.sql +++ b/engine/schema/src/main/resources/META-INF/db/schema-41900to42000.sql @@ -26,3 +26,6 @@ CREATE TABLE IF NOT EXISTS `cloud`.`command_timeout` ( created datetime not null, updated datetime not null ) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +INSERT INTO `cloud`.`command_timeout` (command_classpath, timeout, created, updated) +VALUES ('org.apache.cloudstack.ca.SetupCertificateCommand', 60, now(), now()); From e5f732e46d3483b782991dbb2ec52bef37c0cd9e Mon Sep 17 00:00:00 2001 From: Daniel Augusto Veronezi Salvador Date: Wed, 7 Feb 2024 00:11:58 -0300 Subject: [PATCH 12/23] Convert CheckS2SVpnConnectionsCommand hardcoded timeout to table entry --- .../src/main/resources/META-INF/db/schema-41900to42000.sql | 6 ++++-- .../network/router/VirtualNetworkApplianceManagerImpl.java | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/engine/schema/src/main/resources/META-INF/db/schema-41900to42000.sql b/engine/schema/src/main/resources/META-INF/db/schema-41900to42000.sql index 2084c3eb96d2..da9e3d0a58ba 100644 --- a/engine/schema/src/main/resources/META-INF/db/schema-41900to42000.sql +++ b/engine/schema/src/main/resources/META-INF/db/schema-41900to42000.sql @@ -27,5 +27,7 @@ CREATE TABLE IF NOT EXISTS `cloud`.`command_timeout` ( updated datetime not null ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -INSERT INTO `cloud`.`command_timeout` (command_classpath, timeout, created, updated) -VALUES ('org.apache.cloudstack.ca.SetupCertificateCommand', 60, now(), now()); +INSERT INTO `cloud`.`command_timeout` (command_classpath, timeout, created, updated) +VALUES + ('org.apache.cloudstack.ca.SetupCertificateCommand', 60, now(), now()), + ('com.cloud.agent.api.CheckS2SVpnConnectionsCommand', 30, now(), now()); diff --git a/server/src/main/java/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java b/server/src/main/java/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java index d49322bde60c..1ee30aede431 100644 --- a/server/src/main/java/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java +++ b/server/src/main/java/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java @@ -854,7 +854,7 @@ protected void updateSite2SiteVpnConnectionState(final List rout final CheckS2SVpnConnectionsCommand command = new CheckS2SVpnConnectionsCommand(ipList); command.setAccessDetail(NetworkElementCommand.ROUTER_IP, _routerControlHelper.getRouterControlIp(router.getId())); command.setAccessDetail(NetworkElementCommand.ROUTER_NAME, router.getInstanceName()); - command.setWait(30); + final Answer origAnswer = _agentMgr.easySend(router.getHostId(), command); CheckS2SVpnConnectionsAnswer answer = null; if (origAnswer instanceof CheckS2SVpnConnectionsAnswer) { From 14d454d1c907f0171a7b354837131d16b47293df Mon Sep 17 00:00:00 2001 From: Daniel Augusto Veronezi Salvador Date: Wed, 7 Feb 2024 00:15:10 -0300 Subject: [PATCH 13/23] Convert CheckOnHostCommand hardcoded timeout to table entry --- core/src/main/java/com/cloud/agent/api/CheckOnHostCommand.java | 1 - .../src/main/resources/META-INF/db/schema-41900to42000.sql | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/com/cloud/agent/api/CheckOnHostCommand.java b/core/src/main/java/com/cloud/agent/api/CheckOnHostCommand.java index 982e10cf2ebe..ef41d610cbeb 100644 --- a/core/src/main/java/com/cloud/agent/api/CheckOnHostCommand.java +++ b/core/src/main/java/com/cloud/agent/api/CheckOnHostCommand.java @@ -31,7 +31,6 @@ protected CheckOnHostCommand() { public CheckOnHostCommand(Host host) { this.host = new HostTO(host); - setWait(20); } public CheckOnHostCommand(Host host, boolean reportCheckFailureIfOneStorageIsDown) { diff --git a/engine/schema/src/main/resources/META-INF/db/schema-41900to42000.sql b/engine/schema/src/main/resources/META-INF/db/schema-41900to42000.sql index da9e3d0a58ba..f172e18d6d66 100644 --- a/engine/schema/src/main/resources/META-INF/db/schema-41900to42000.sql +++ b/engine/schema/src/main/resources/META-INF/db/schema-41900to42000.sql @@ -30,4 +30,5 @@ CREATE TABLE IF NOT EXISTS `cloud`.`command_timeout` ( INSERT INTO `cloud`.`command_timeout` (command_classpath, timeout, created, updated) VALUES ('org.apache.cloudstack.ca.SetupCertificateCommand', 60, now(), now()), - ('com.cloud.agent.api.CheckS2SVpnConnectionsCommand', 30, now(), now()); + ('com.cloud.agent.api.CheckS2SVpnConnectionsCommand', 30, now(), now()), + ('com.cloud.agent.api.CheckOnHostCommand', 20, now(), now()); From fbc9685d0ae74ebe05af5b6151a4ce8683a5ac78 Mon Sep 17 00:00:00 2001 From: Daniel Augusto Veronezi Salvador Date: Wed, 7 Feb 2024 00:16:49 -0300 Subject: [PATCH 14/23] Convert CheckVirtualMachineCommand hardcoded timeout to table entry --- .../java/com/cloud/agent/api/CheckVirtualMachineCommand.java | 1 - .../src/main/resources/META-INF/db/schema-41900to42000.sql | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/com/cloud/agent/api/CheckVirtualMachineCommand.java b/core/src/main/java/com/cloud/agent/api/CheckVirtualMachineCommand.java index 17549503b83e..2960f2542852 100644 --- a/core/src/main/java/com/cloud/agent/api/CheckVirtualMachineCommand.java +++ b/core/src/main/java/com/cloud/agent/api/CheckVirtualMachineCommand.java @@ -29,7 +29,6 @@ protected CheckVirtualMachineCommand() { public CheckVirtualMachineCommand(String vmName) { this.vmName = vmName; - setWait(20); } public String getVmName() { diff --git a/engine/schema/src/main/resources/META-INF/db/schema-41900to42000.sql b/engine/schema/src/main/resources/META-INF/db/schema-41900to42000.sql index f172e18d6d66..445eabf66c70 100644 --- a/engine/schema/src/main/resources/META-INF/db/schema-41900to42000.sql +++ b/engine/schema/src/main/resources/META-INF/db/schema-41900to42000.sql @@ -31,4 +31,5 @@ INSERT INTO `cloud`.`command_timeout` (command_classpath, timeout, created, upda VALUES ('org.apache.cloudstack.ca.SetupCertificateCommand', 60, now(), now()), ('com.cloud.agent.api.CheckS2SVpnConnectionsCommand', 30, now(), now()), - ('com.cloud.agent.api.CheckOnHostCommand', 20, now(), now()); + ('com.cloud.agent.api.CheckOnHostCommand', 20, now(), now()), + ('com.cloud.agent.api.CheckVirtualMachineCommand', 20, now(), now()); From 06f07ae5578d20886acc1047ce485ea49827019f Mon Sep 17 00:00:00 2001 From: Daniel Augusto Veronezi Salvador Date: Wed, 7 Feb 2024 00:18:26 -0300 Subject: [PATCH 15/23] Convert CheckRouterCommand hardcoded timeout to table entry --- .../src/main/resources/META-INF/db/schema-41900to42000.sql | 3 ++- .../network/router/VirtualNetworkApplianceManagerImpl.java | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/engine/schema/src/main/resources/META-INF/db/schema-41900to42000.sql b/engine/schema/src/main/resources/META-INF/db/schema-41900to42000.sql index 445eabf66c70..9549a9eed723 100644 --- a/engine/schema/src/main/resources/META-INF/db/schema-41900to42000.sql +++ b/engine/schema/src/main/resources/META-INF/db/schema-41900to42000.sql @@ -32,4 +32,5 @@ VALUES ('org.apache.cloudstack.ca.SetupCertificateCommand', 60, now(), now()), ('com.cloud.agent.api.CheckS2SVpnConnectionsCommand', 30, now(), now()), ('com.cloud.agent.api.CheckOnHostCommand', 20, now(), now()), - ('com.cloud.agent.api.CheckVirtualMachineCommand', 20, now(), now()); + ('com.cloud.agent.api.CheckVirtualMachineCommand', 20, now(), now()), + ('com.cloud.agent.api.CheckRouterCommand', 30, now(), now()); diff --git a/server/src/main/java/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java b/server/src/main/java/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java index 1ee30aede431..e47f4a5e7592 100644 --- a/server/src/main/java/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java +++ b/server/src/main/java/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java @@ -924,7 +924,7 @@ protected void updateRoutersRedundantState(final List routers) { final CheckRouterCommand command = new CheckRouterCommand(); command.setAccessDetail(NetworkElementCommand.ROUTER_IP, _routerControlHelper.getRouterControlIp(router.getId())); command.setAccessDetail(NetworkElementCommand.ROUTER_NAME, router.getInstanceName()); - command.setWait(30); + final Answer origAnswer = _agentMgr.easySend(router.getHostId(), command); CheckRouterAnswer answer = null; if (origAnswer instanceof CheckRouterAnswer) { From 10c46afc89fc87ae17b9116ee28bfcf4ec10bf7d Mon Sep 17 00:00:00 2001 From: Daniel Augusto Veronezi Salvador Date: Wed, 7 Feb 2024 00:19:40 -0300 Subject: [PATCH 16/23] Convert CheckHealthCommand hardcoded timeout to table entry --- .../src/main/java/com/cloud/agent/api/CheckHealthCommand.java | 4 ---- .../src/main/resources/META-INF/db/schema-41900to42000.sql | 3 ++- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/core/src/main/java/com/cloud/agent/api/CheckHealthCommand.java b/core/src/main/java/com/cloud/agent/api/CheckHealthCommand.java index 129281183111..c151e2fb91fd 100644 --- a/core/src/main/java/com/cloud/agent/api/CheckHealthCommand.java +++ b/core/src/main/java/com/cloud/agent/api/CheckHealthCommand.java @@ -21,10 +21,6 @@ public class CheckHealthCommand extends Command { - public CheckHealthCommand() { - setWait(50); - } - @Override public boolean executeInSequence() { return false; diff --git a/engine/schema/src/main/resources/META-INF/db/schema-41900to42000.sql b/engine/schema/src/main/resources/META-INF/db/schema-41900to42000.sql index 9549a9eed723..23b356e967c2 100644 --- a/engine/schema/src/main/resources/META-INF/db/schema-41900to42000.sql +++ b/engine/schema/src/main/resources/META-INF/db/schema-41900to42000.sql @@ -33,4 +33,5 @@ VALUES ('com.cloud.agent.api.CheckS2SVpnConnectionsCommand', 30, now(), now()), ('com.cloud.agent.api.CheckOnHostCommand', 20, now(), now()), ('com.cloud.agent.api.CheckVirtualMachineCommand', 20, now(), now()), - ('com.cloud.agent.api.CheckRouterCommand', 30, now(), now()); + ('com.cloud.agent.api.CheckRouterCommand', 30, now(), now()), + ('com.cloud.agent.api.CheckHealthCommand', 50, now(), now()); From 6d33fdc1b86ff97102bc60d8095d2dbda3b5de47 Mon Sep 17 00:00:00 2001 From: Daniel Augusto Veronezi Salvador Date: Wed, 7 Feb 2024 00:21:39 -0300 Subject: [PATCH 17/23] Convert GetAutoScaleMetricsCommand hardcoded timeout to table entry --- .../src/main/resources/META-INF/db/schema-41900to42000.sql | 3 ++- .../main/java/com/cloud/network/as/AutoScaleManagerImpl.java | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/engine/schema/src/main/resources/META-INF/db/schema-41900to42000.sql b/engine/schema/src/main/resources/META-INF/db/schema-41900to42000.sql index 23b356e967c2..473ed8e117ab 100644 --- a/engine/schema/src/main/resources/META-INF/db/schema-41900to42000.sql +++ b/engine/schema/src/main/resources/META-INF/db/schema-41900to42000.sql @@ -34,4 +34,5 @@ VALUES ('com.cloud.agent.api.CheckOnHostCommand', 20, now(), now()), ('com.cloud.agent.api.CheckVirtualMachineCommand', 20, now(), now()), ('com.cloud.agent.api.CheckRouterCommand', 30, now(), now()), - ('com.cloud.agent.api.CheckHealthCommand', 50, now(), now()); + ('com.cloud.agent.api.CheckHealthCommand', 50, now(), now()), + ('com.cloud.agent.api.routing.GetAutoScaleMetricsCommand', 30, now(), now()); diff --git a/server/src/main/java/com/cloud/network/as/AutoScaleManagerImpl.java b/server/src/main/java/com/cloud/network/as/AutoScaleManagerImpl.java index c10ff89fa3d5..361203fa11f3 100644 --- a/server/src/main/java/com/cloud/network/as/AutoScaleManagerImpl.java +++ b/server/src/main/java/com/cloud/network/as/AutoScaleManagerImpl.java @@ -2765,7 +2765,7 @@ protected void getNetworkStatsFromVirtualRouter(AutoScaleVmGroupTO groupTO) { for (DomainRouterVO router : routers) { if (VirtualMachine.State.Running.equals(router.getState())) { final GetAutoScaleMetricsCommand command = new GetAutoScaleMetricsCommand(router.getPrivateIpAddress(), network.getVpcId() != null, publicIpAddr.first(), publicIpAddr.second(), metrics); - command.setWait(30); + GetAutoScaleMetricsAnswer answer = (GetAutoScaleMetricsAnswer) agentMgr.easySend(router.getHostId(), command); if (answer == null || !answer.getResult()) { s_logger.error("Failed to get autoscale metrics from virtual router " + router.getName()); From 03de190ff743191ccd8b3c74eff478694e6719dd Mon Sep 17 00:00:00 2001 From: Daniel Augusto Veronezi Salvador Date: Wed, 7 Feb 2024 00:23:27 -0300 Subject: [PATCH 18/23] Convert SetupKeyStoreCommand hardcoded timeout to table entry --- .../java/org/apache/cloudstack/ca/SetupKeyStoreCommand.java | 2 +- .../src/main/resources/META-INF/db/schema-41900to42000.sql | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/org/apache/cloudstack/ca/SetupKeyStoreCommand.java b/core/src/main/java/org/apache/cloudstack/ca/SetupKeyStoreCommand.java index 7cd5cbee20fc..6e9f0efcb764 100644 --- a/core/src/main/java/org/apache/cloudstack/ca/SetupKeyStoreCommand.java +++ b/core/src/main/java/org/apache/cloudstack/ca/SetupKeyStoreCommand.java @@ -35,7 +35,7 @@ public class SetupKeyStoreCommand extends NetworkElementCommand { public SetupKeyStoreCommand(final int validityDays) { super(); - setWait(60); + this.validityDays = validityDays; if (this.validityDays < 1) { this.validityDays = 1; diff --git a/engine/schema/src/main/resources/META-INF/db/schema-41900to42000.sql b/engine/schema/src/main/resources/META-INF/db/schema-41900to42000.sql index 473ed8e117ab..7fdb8bfa270b 100644 --- a/engine/schema/src/main/resources/META-INF/db/schema-41900to42000.sql +++ b/engine/schema/src/main/resources/META-INF/db/schema-41900to42000.sql @@ -35,4 +35,5 @@ VALUES ('com.cloud.agent.api.CheckVirtualMachineCommand', 20, now(), now()), ('com.cloud.agent.api.CheckRouterCommand', 30, now(), now()), ('com.cloud.agent.api.CheckHealthCommand', 50, now(), now()), - ('com.cloud.agent.api.routing.GetAutoScaleMetricsCommand', 30, now(), now()); + ('com.cloud.agent.api.routing.GetAutoScaleMetricsCommand', 30, now(), now()), + ('org.apache.cloudstack.ca.SetupKeyStoreCommand', 30, now(), now()); From ad759e0b9113c6bf3a88342fdf5a0764a7417934 Mon Sep 17 00:00:00 2001 From: Daniel Augusto Veronezi Salvador Date: Wed, 7 Feb 2024 00:24:34 -0300 Subject: [PATCH 19/23] Convert ListDataStoreObjectsCommand hardcoded timeout to table entry --- .../src/main/resources/META-INF/db/schema-41900to42000.sql | 3 ++- .../apache/cloudstack/storage/browser/StorageBrowserImpl.java | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/engine/schema/src/main/resources/META-INF/db/schema-41900to42000.sql b/engine/schema/src/main/resources/META-INF/db/schema-41900to42000.sql index 7fdb8bfa270b..88da8c87150b 100644 --- a/engine/schema/src/main/resources/META-INF/db/schema-41900to42000.sql +++ b/engine/schema/src/main/resources/META-INF/db/schema-41900to42000.sql @@ -36,4 +36,5 @@ VALUES ('com.cloud.agent.api.CheckRouterCommand', 30, now(), now()), ('com.cloud.agent.api.CheckHealthCommand', 50, now(), now()), ('com.cloud.agent.api.routing.GetAutoScaleMetricsCommand', 30, now(), now()), - ('org.apache.cloudstack.ca.SetupKeyStoreCommand', 30, now(), now()); + ('org.apache.cloudstack.ca.SetupKeyStoreCommand', 30, now(), now()), + ('org.apache.cloudstack.storage.command.browser.ListDataStoreObjectsCommand', 15, now(), now()); diff --git a/server/src/main/java/org/apache/cloudstack/storage/browser/StorageBrowserImpl.java b/server/src/main/java/org/apache/cloudstack/storage/browser/StorageBrowserImpl.java index 8828ac486f5d..10bcc319e576 100644 --- a/server/src/main/java/org/apache/cloudstack/storage/browser/StorageBrowserImpl.java +++ b/server/src/main/java/org/apache/cloudstack/storage/browser/StorageBrowserImpl.java @@ -184,7 +184,7 @@ ListDataStoreObjectsAnswer listObjectsInStore(DataStore dataStore, String path, } ListDataStoreObjectsCommand listDSCmd = new ListDataStoreObjectsCommand(dataStore.getTO(), path, startIndex, pageSize); - listDSCmd.setWait(15); + Answer answer = null; try { answer = ep.sendMessage(listDSCmd); From 557cb9ddf61b319adfb1526a9437300d902fa094 Mon Sep 17 00:00:00 2001 From: Daniel Augusto Veronezi Salvador Date: Wed, 7 Feb 2024 13:15:16 -0300 Subject: [PATCH 20/23] Fix query operator --- .../cloudstack/framework/config/dao/CommandTimeoutDaoImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/config/src/main/java/org/apache/cloudstack/framework/config/dao/CommandTimeoutDaoImpl.java b/framework/config/src/main/java/org/apache/cloudstack/framework/config/dao/CommandTimeoutDaoImpl.java index e47eb3e53185..e0c7d30baaa4 100644 --- a/framework/config/src/main/java/org/apache/cloudstack/framework/config/dao/CommandTimeoutDaoImpl.java +++ b/framework/config/src/main/java/org/apache/cloudstack/framework/config/dao/CommandTimeoutDaoImpl.java @@ -33,7 +33,7 @@ public CommandTimeoutDaoImpl() { maxCommandTimeoutSearchBuilder = createSearchBuilder(Integer.class); maxCommandTimeoutSearchBuilder.select(null, SearchCriteria.Func.MAX, maxCommandTimeoutSearchBuilder.entity().getTimeout()); - maxCommandTimeoutSearchBuilder.and("command_classpath", maxCommandTimeoutSearchBuilder.entity().getCommandClasspath(), SearchCriteria.Op.EQ); + maxCommandTimeoutSearchBuilder.and("command_classpath", maxCommandTimeoutSearchBuilder.entity().getCommandClasspath(), SearchCriteria.Op.IN); maxCommandTimeoutSearchBuilder.done(); } From b0c5501e3d6c510b670c8051c8f01bedf7000fb8 Mon Sep 17 00:00:00 2001 From: Daniel Augusto Veronezi Salvador Date: Thu, 8 Feb 2024 10:18:08 -0300 Subject: [PATCH 21/23] Fix log --- .../cloud/agent/manager/AgentManagerImpl.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/engine/orchestration/src/main/java/com/cloud/agent/manager/AgentManagerImpl.java b/engine/orchestration/src/main/java/com/cloud/agent/manager/AgentManagerImpl.java index 1d6ab9da4078..c09f20853900 100644 --- a/engine/orchestration/src/main/java/com/cloud/agent/manager/AgentManagerImpl.java +++ b/engine/orchestration/src/main/java/com/cloud/agent/manager/AgentManagerImpl.java @@ -475,22 +475,22 @@ protected int getTimeoutForCommands(Commands commands, int timeout) { Set commandsClassPath = commands.getCommands().stream().map(command -> command.getClass().getName()).collect(Collectors.toSet()); if (timeout > 0) { - s_logger.trace(String.format("The timeout [%s] was already defined for commands %s; therefore, we will use it instead of searching for the max value in table " + - "[%s].", timeout, commandsClassPath, CommandTimeoutVO.TABLE_NAME)); + logger.trace("The timeout [{}] was already defined for commands {}; therefore, we will use it instead of searching for the max value in table " + + "[{}].", timeout, commandsClassPath, CommandTimeoutVO.TABLE_NAME); return timeout; } - s_logger.trace(String.format("The timeout for commands %s was not defined yet; therefore, we will search for the max value between the commands in table " + - "[%s].", commandsClassPath, CommandTimeoutVO.TABLE_NAME)); + logger.trace("The timeout for commands {} was not defined yet; therefore, we will search for the max value between the commands in table " + + "[{}].", commandsClassPath, CommandTimeoutVO.TABLE_NAME); timeout = commandTimeoutDao.findMaxTimeoutBetweenCommands(commandsClassPath); if (timeout > 0) { - s_logger.trace(String.format("We found [%s] as the max timeout between commands %s in table [%s]; using it.", timeout, commandsClassPath, - CommandTimeoutVO.TABLE_NAME)); + logger.trace("We found [{}] as the max timeout between commands {} in table [{}]; using it.", timeout, commandsClassPath, + CommandTimeoutVO.TABLE_NAME); } else { timeout = getWaitValue(); - s_logger.trace(String.format("We did not find a max timeout between commands %s in table [%s]; therefore, we will fallback to the value of " + - "configuration [%s]: [%s].", commandsClassPath, CommandTimeoutVO.TABLE_NAME, Wait.key(), timeout)); + logger.trace("We did not find a max timeout between commands %s in table [{}]; therefore, we will fallback to the value of " + + "configuration [{}]: [{}].", commandsClassPath, CommandTimeoutVO.TABLE_NAME, Wait.key(), timeout); } return timeout; From cacb2189d2bcfc97e1a68d4d2a04b05bffeb4439 Mon Sep 17 00:00:00 2001 From: Daniel Augusto Veronezi Salvador Date: Fri, 9 Feb 2024 00:52:51 -0300 Subject: [PATCH 22/23] Fix unit tests --- .../cloudstack/api/agent/test/CheckHealthCommandTest.java | 7 ------- .../cloudstack/api/agent/test/CheckOnHostCommandTest.java | 6 ------ 2 files changed, 13 deletions(-) diff --git a/core/src/test/java/org/apache/cloudstack/api/agent/test/CheckHealthCommandTest.java b/core/src/test/java/org/apache/cloudstack/api/agent/test/CheckHealthCommandTest.java index a330eb40fe91..0f29c387a37b 100644 --- a/core/src/test/java/org/apache/cloudstack/api/agent/test/CheckHealthCommandTest.java +++ b/core/src/test/java/org/apache/cloudstack/api/agent/test/CheckHealthCommandTest.java @@ -20,7 +20,6 @@ package org.apache.cloudstack.api.agent.test; import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; import org.junit.Test; @@ -29,12 +28,6 @@ public class CheckHealthCommandTest { CheckHealthCommand chc = new CheckHealthCommand(); - @Test - public void testGetWait() { - int wait = chc.getWait(); - assertTrue(wait == 50); - } - @Test public void testExecuteInSequence() { boolean b = chc.executeInSequence(); diff --git a/core/src/test/java/org/apache/cloudstack/api/agent/test/CheckOnHostCommandTest.java b/core/src/test/java/org/apache/cloudstack/api/agent/test/CheckOnHostCommandTest.java index f7d756268f44..aa84261fca22 100644 --- a/core/src/test/java/org/apache/cloudstack/api/agent/test/CheckOnHostCommandTest.java +++ b/core/src/test/java/org/apache/cloudstack/api/agent/test/CheckOnHostCommandTest.java @@ -532,12 +532,6 @@ public void testGetResourceState() { assertTrue(r == ResourceState.Enabled); } - @Test - public void testGetWait() { - int wait = cohc.getWait(); - assertTrue(20 == wait); - } - @Test public void testExecuteInSequence() { boolean b = cohc.executeInSequence(); From 6d4471997c6d5667734152d8fbeb88cf6c55efb4 Mon Sep 17 00:00:00 2001 From: Daniel Augusto Veronezi Salvador Date: Tue, 4 Jun 2024 18:17:37 -0300 Subject: [PATCH 23/23] Fix table creation --- .../src/main/resources/META-INF/db/schema-41910to42000.sql | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/engine/schema/src/main/resources/META-INF/db/schema-41910to42000.sql b/engine/schema/src/main/resources/META-INF/db/schema-41910to42000.sql index 39b7c5e6a208..2f0604dcfda5 100644 --- a/engine/schema/src/main/resources/META-INF/db/schema-41910to42000.sql +++ b/engine/schema/src/main/resources/META-INF/db/schema-41910to42000.sql @@ -86,10 +86,11 @@ CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.host_tags', 'is_implicit', 'int(1) U -- Create command_timeout table and populate it CREATE TABLE IF NOT EXISTS `cloud`.`command_timeout` ( id bigint(20) unsigned not null auto_increment primary key, - command_classpath text unique key, + command_classpath text not null, timeout int not null, created datetime not null, - updated datetime not null + updated datetime not null, + unique key (command_classpath(50)) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; INSERT INTO `cloud`.`command_timeout` (command_classpath, timeout, created, updated)