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_r349743170
 
 

 ##########
 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) {
 
 Review comment:
   I've checked that in the if above. Also > 1 is a good point but that would 
break the existing behaviour which shuts VMs for single host. We have created 
an open github issue to discuss and change that.

----------------------------------------------------------------
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

Reply via email to