anuragaw commented on a change in pull request #3425: [WIP DO NOT MERGE] Better
tracking host maintanence success and failure
URL: https://github.com/apache/cloudstack/pull/3425#discussion_r350017763
##########
File path: server/src/main/java/com/cloud/resource/ResourceManagerImpl.java
##########
@@ -1286,12 +1288,31 @@ public Host maintain(final PrepareForMaintenanceCmd
cmd) {
throw new InvalidParameterValueException("Unable to find host with
ID: " + hostId + ". Please specify a valid host ID.");
}
- if (_hostDao.countBy(host.getClusterId(),
ResourceState.PrepareForMaintenance, ResourceState.ErrorInMaintenance) > 0) {
- throw new InvalidParameterValueException("There are other servers
in PrepareForMaintenance OR ErrorInMaintenance STATUS in cluster " +
host.getClusterId());
+ final ResourceState hostState = host.getResourceState();
+ if (hostState == ResourceState.Maintenance || hostState ==
ResourceState.PrepareForMaintenance ||
+ hostState == ResourceState.ErrorInPrepareForMaintenance) {
+ throw new CloudRuntimeException("Host is already in state " +
hostState + ". Cannot recall for maintenance until resolved.");
+ }
+
+ 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());
}
if (_storageMgr.isLocalStorageActiveOnHost(host.getId())) {
- throw new InvalidParameterValueException("There are active VMs
using the host's local storage pool. Please stop all VMs on this host that use
local storage.");
+ throw new CloudRuntimeException("There are active VMs using the
host's local storage pool. Please stop all VMs on this host that use local
storage.");
+ }
+ List<VMInstanceVO> migratingInVMs = _vmDao.findByHostInStates(hostId,
State.Migrating);
Review comment:
It covers all VMs.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services