mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-03 04:12:31 +01:00
Ability to put a server in Down state to maintenance (#4363)
This commit is contained in:
parent
25dd7aad51
commit
e1dd07a30c
@ -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);
|
"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",
|
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);
|
"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",
|
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",
|
"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);
|
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_READ_RATE = "IOPS Read";
|
||||||
private static final String IOPS_WRITE_RATE = "IOPS Write";
|
private static final String IOPS_WRITE_RATE = "IOPS Write";
|
||||||
@ -6437,6 +6439,6 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||||||
@Override
|
@Override
|
||||||
public ConfigKey<?>[] getConfigKeys() {
|
public ConfigKey<?>[] getConfigKeys() {
|
||||||
return new ConfigKey<?>[] {SystemVMUseLocalStorage, IOPS_MAX_READ_LENGTH, IOPS_MAX_WRITE_LENGTH,
|
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};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -180,6 +180,9 @@ import com.cloud.vm.dao.UserVmDetailsDao;
|
|||||||
import com.cloud.vm.dao.VMInstanceDao;
|
import com.cloud.vm.dao.VMInstanceDao;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
|
|
||||||
|
|
||||||
|
import static com.cloud.configuration.ConfigurationManagerImpl.SET_HOST_DOWN_TO_MAINTENANCE;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class ResourceManagerImpl extends ManagerBase implements ResourceManager, ResourceService, Manager {
|
public class ResourceManagerImpl extends ManagerBase implements ResourceManager, ResourceService, Manager {
|
||||||
private static final Logger s_logger = Logger.getLogger(ResourceManagerImpl.class);
|
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.");
|
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) {
|
if (_hostDao.countBy(host.getClusterId(), ResourceState.PrepareForMaintenance, ResourceState.ErrorInPrepareForMaintenance) > 0) {
|
||||||
throw new CloudRuntimeException("There are other servers attempting migrations for maintenance. " +
|
throw new CloudRuntimeException("There are other servers attempting migrations for maintenance. " +
|
||||||
"Found hosts in PrepareForMaintenance OR ErrorInPrepareForMaintenance STATUS in cluster " + host.getClusterId());
|
"Found hosts in PrepareForMaintenance OR ErrorInPrepareForMaintenance STATUS in cluster " + host.getClusterId());
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user