This is an automated email from the ASF dual-hosted git repository.
dahn pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/master by this push:
new e1dd07a Ability to put a server in Down state to maintenance (#4363)
e1dd07a is described below
commit e1dd07a30c0d67da356b59f3491b2c7c1eef2221
Author: Rakesh <[email protected]>
AuthorDate: Wed Oct 28 09:59:43 2020 +0100
Ability to put a server in Down state to maintenance (#4363)
---
.../com/cloud/configuration/ConfigurationManagerImpl.java | 6 ++++--
.../main/java/com/cloud/resource/ResourceManagerImpl.java | 14 ++++++++++++++
2 files changed, 18 insertions(+), 2 deletions(-)
diff --git
a/server/src/main/java/com/cloud/configuration/ConfigurationManagerImpl.java
b/server/src/main/java/com/cloud/configuration/ConfigurationManagerImpl.java
index 9d1cffc..698f280 100755
--- a/server/src/main/java/com/cloud/configuration/ConfigurationManagerImpl.java
+++ b/server/src/main/java/com/cloud/configuration/ConfigurationManagerImpl.java
@@ -415,10 +415,12 @@ public class ConfigurationManagerImpl extends ManagerBase
implements Configurati
"Maximum IOPS read burst duration (seconds). If '0' (zero) then
does not check for maximum burst length.", true, ConfigKey.Scope.Global, null);
public final static ConfigKey<Long> IOPS_MAX_WRITE_LENGTH = new
ConfigKey<Long>(Long.class, "vm.disk.iops.maximum.write.length", "Advanced",
"0",
"Maximum IOPS write burst duration (seconds). If '0' (zero) then
does not check for maximum burst length.", true, ConfigKey.Scope.Global, null);
-
public static final ConfigKey<Boolean> ADD_HOST_ON_SERVICE_RESTART_KVM =
new ConfigKey<Boolean>(Boolean.class, "add.host.on.service.restart.kvm",
"Advanced", "true",
"Indicates whether the host will be added back to cloudstack after
restarting agent service on host. If false it wont be added back even after
service restart",
true, ConfigKey.Scope.Global, null);
+ public static final ConfigKey<Boolean> SET_HOST_DOWN_TO_MAINTENANCE = new
ConfigKey<Boolean>(Boolean.class, "set.host.down.to.maintenance", "Advanced",
"false",
+ "Indicates whether the host in down state can be put
into maintenance state so thats its not enabled after it comes back.",
+ true, ConfigKey.Scope.Zone, null);
private static final String IOPS_READ_RATE = "IOPS Read";
private static final String IOPS_WRITE_RATE = "IOPS Write";
@@ -6437,6 +6439,6 @@ public class ConfigurationManagerImpl extends ManagerBase
implements Configurati
@Override
public ConfigKey<?>[] getConfigKeys() {
return new ConfigKey<?>[] {SystemVMUseLocalStorage,
IOPS_MAX_READ_LENGTH, IOPS_MAX_WRITE_LENGTH,
- BYTES_MAX_READ_LENGTH, BYTES_MAX_WRITE_LENGTH,
ADD_HOST_ON_SERVICE_RESTART_KVM};
+ BYTES_MAX_READ_LENGTH, BYTES_MAX_WRITE_LENGTH,
ADD_HOST_ON_SERVICE_RESTART_KVM, SET_HOST_DOWN_TO_MAINTENANCE};
}
}
diff --git a/server/src/main/java/com/cloud/resource/ResourceManagerImpl.java
b/server/src/main/java/com/cloud/resource/ResourceManagerImpl.java
index 52a1106..267ad2b 100755
--- a/server/src/main/java/com/cloud/resource/ResourceManagerImpl.java
+++ b/server/src/main/java/com/cloud/resource/ResourceManagerImpl.java
@@ -180,6 +180,9 @@ import com.cloud.vm.dao.UserVmDetailsDao;
import com.cloud.vm.dao.VMInstanceDao;
import com.google.gson.Gson;
+
+import static
com.cloud.configuration.ConfigurationManagerImpl.SET_HOST_DOWN_TO_MAINTENANCE;
+
@Component
public class ResourceManagerImpl extends ManagerBase implements
ResourceManager, ResourceService, Manager {
private static final Logger s_logger =
Logger.getLogger(ResourceManagerImpl.class);
@@ -1302,6 +1305,17 @@ public class ResourceManagerImpl extends ManagerBase
implements ResourceManager,
throw new CloudRuntimeException("Host is already in state " +
host.getResourceState() + ". Cannot recall for maintenance until resolved.");
}
+ if (SET_HOST_DOWN_TO_MAINTENANCE.valueIn(host.getDataCenterId()) &&
(host.getStatus() == Status.Down)) {
+ if (host.getResourceState() == ResourceState.Enabled) {
+ _hostDao.updateResourceState(ResourceState.Enabled,
ResourceState.Event.AdminAskMaintenance, ResourceState.PrepareForMaintenance,
host);
+
_hostDao.updateResourceState(ResourceState.PrepareForMaintenance,
ResourceState.Event.InternalEnterMaintenance, ResourceState.Maintenance, host);
+ return _hostDao.findById(hostId);
+ } else if (host.getResourceState() ==
ResourceState.ErrorInMaintenance) {
+ _hostDao.updateResourceState(ResourceState.ErrorInMaintenance,
ResourceState.Event.InternalEnterMaintenance, ResourceState.Maintenance, host);
+ return _hostDao.findById(hostId);
+ }
+ }
+
if (_hostDao.countBy(host.getClusterId(),
ResourceState.PrepareForMaintenance,
ResourceState.ErrorInPrepareForMaintenance) > 0) {
throw new CloudRuntimeException("There are other servers
attempting migrations for maintenance. " +
"Found hosts in PrepareForMaintenance OR
ErrorInPrepareForMaintenance STATUS in cluster " + host.getClusterId());