cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [cloudstack] anuragaw commented on a change in pull request #3425: [WIP DO NOT MERGE] Better tracking host maintanence success and failure
Date Thu, 27 Jun 2019 09:17:47 GMT
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_r298082407
 
 

 ##########
 File path: server/src/main/java/com/cloud/resource/ResourceManagerImpl.java
 ##########
 @@ -1356,32 +1353,48 @@ protected boolean setHostIntoMaintenance(HostVO host) throws NoTransitionExcepti
         return true;
     }
 
+    protected boolean setHostIntoPrepareForMaintenanceWithErrors(HostVO host) throws NoTransitionException
{
+        s_logger.debug("Host " + host.getUuid() + " entering in PrepareForMaintainenceWithErrors
state");
+        resourceStateTransitTo(host, ResourceState.Event.UnableToMigrate, _nodeId);
+        return true;
+    }
+
     /**
      * Return true if host goes into Maintenance mode, only when:
      * - No Running, Migrating or Failed migrations (host_id = last_host_id) for the host
      */
-    protected boolean isHostInMaintenance(HostVO host, List<VMInstanceVO> runningVms,
List<VMInstanceVO> migratingVms, List<VMInstanceVO> failedMigrations) throws NoTransitionException
{
-        if (CollectionUtils.isEmpty(runningVms) && CollectionUtils.isEmpty(migratingVms))
{
-            return CollectionUtils.isEmpty(failedMigrations) ?
-                    setHostIntoMaintenance(host) :
-                    setHostIntoErrorInMaintenance(host, failedMigrations);
-        } else if (retryHostMaintenance.containsKey(host.getId())) {
-            Integer retriesLeft = retryHostMaintenance.get(host.getId());
-            if (retriesLeft != null) {
-                if (retriesLeft <= 0) {
-                    retryHostMaintenance.remove(host.getId());
-                    s_logger.debug(String.format("No retries left while preparing KVM host
%s (%s) for Maintenance, " +
-                                    "please investigate this connection.",
-                            host.getId(), host.getName()));
-                    return setHostIntoErrorInMaintenance(host, failedMigrations);
-                }
-                retriesLeft--;
-                retryHostMaintenance.put(host.getId(), retriesLeft);
-                s_logger.debug(String.format("Retries left preparing KVM host %s (%s) for
Maintenance: %s",
-                        host.getId(), host.getName(), retriesLeft));
+    protected boolean attemptMaintain(HostVO host) throws NoTransitionException {
+        final long hostId = host.getId();
+
+        if (CollectionUtils.isEmpty(_vmDao.findByHostInStates(hostId, State.Migrating, State.Running,
State.Starting, State.Stopping, State.Error, State.Unknown))) {
+            return setHostIntoMaintenance(host);
+        }
+
+        final List<VMInstanceVO> allVmsOnHost = _vmDao.listByHostId(hostId);
+        final List<VMInstanceVO> migratingVms = _vmDao.listVmsMigratingFromHost(hostId);
+        final List<VMInstanceVO> failedMigrations = _vmDao.listNonMigratingVmsByHostEqualsLastHost(hostId);
+        boolean hasPendingWorkForVMs = false;
+        for (VMInstanceVO vmInstanceVO : allVmsOnHost) {
+            if (_haMgr.hasPendingHaWork(vmInstanceVO.getId())) {
 
 Review comment:
   Done

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message