[GitHub] [cloudstack] nvazquez commented on a change in pull request #3425: [WIP DO NOT MERGE] Better tracking host maintanence success and failure

2019-06-29 Thread GitBox
nvazquez 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_r298812981
 
 

 ##
 File path: server/src/main/java/com/cloud/resource/ResourceManagerImpl.java
 ##
 @@ -1353,46 +1353,57 @@ 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");
+protected boolean setHostIntoPrepareForMaintenanceWithErrors(HostVO host, 
List errorVms) throws NoTransitionException {
+s_logger.debug("Host " + host.getUuid() + " entering in 
PrepareForMaintenanceWithErrors state");
+configureVncAccessForKVMHostFailedMigrations(host, errorVms);
 resourceStateTransitTo(host, ResourceState.Event.UnableToMigrate, 
_nodeId);
 return true;
 }
 
+protected boolean setHostIntoPrepareForMaintenanceAfterErrorsFixed(HostVO 
host) throws NoTransitionException {
+s_logger.debug("Host " + host.getUuid() + " entering in 
PrepareForMaintenance state as any previous corrections have been fixed");
+resourceStateTransitTo(host, ResourceState.Event.ErrorsCorrected, 
_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 attemptMaintain(HostVO host) throws 
NoTransitionException {
+private 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 allVmsOnHost = _vmDao.listByHostId(hostId);
-final List migratingVms = 
_vmDao.listVmsMigratingFromHost(hostId);
-final List failedMigrations = 
_vmDao.listNonMigratingVmsByHostEqualsLastHost(hostId);
-boolean hasPendingWorkForVMs = false;
+boolean hasPendingMigrationWorks = false;
 for (VMInstanceVO vmInstanceVO : allVmsOnHost) {
-if (_haMgr.hasPendingHaWork(vmInstanceVO.getId())) {
-hasPendingWorkForVMs = true;
+if (_haMgr.hasPendingMigrationsWork(vmInstanceVO.getId())) {
+hasPendingMigrationWorks = true;
 break;
 }
 }
 
-if (!hasPendingWorkForVMs) {
-if ((CollectionUtils.isNotEmpty(_vmDao.findByHostInStates(hostId, 
State.Running)) && CollectionUtils.isEmpty(migratingVms)) ||
-(CollectionUtils.isEmpty(_vmDao.findByHostInStates(hostId, 
State.Running)) &&
-
CollectionUtils.isNotEmpty(_vmDao.findByHostInStates(hostId, State.Unknown, 
State.Error, State.Shutdowned {
-return setHostIntoErrorInMaintenance(host, failedMigrations);
-}
+final List failedMigrations = new 
ArrayList<>(_vmDao.listNonMigratingVmsByHostEqualsLastHost(hostId));
+final List errorVms = new 
ArrayList<>(_vmDao.findByHostInStates(hostId, State.Unknown, State.Error, 
State.Shutdowned));
+final boolean hasMigratingVms = 
CollectionUtils.isNotEmpty(_vmDao.listVmsMigratingFromHost(hostId));
+final boolean hasRunningVms = 
CollectionUtils.isNotEmpty(_vmDao.findByHostInStates(hostId, State.Running));
+final boolean hasFailedMigrations = 
CollectionUtils.isNotEmpty(failedMigrations);
+final boolean hasVmsInFailureStates = 
CollectionUtils.isNotEmpty(errorVms);
+errorVms.addAll(failedMigrations);
+
+if (!hasPendingMigrationWorks && (hasRunningVms || (!hasRunningVms && 
!hasMigratingVms && hasVmsInFailureStates))) {
+return setHostIntoErrorInMaintenance(host, errorVms);
+}
+
+if ((hasVmsInFailureStates || hasFailedMigrations) && 
(hasPendingMigrationWorks || hasMigratingVms || 
CollectionUtils.isNotEmpty(_vmDao.findByHostInStates(hostId, State.Stopping 
{
 
 Review comment:
   Same as above


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


With regards,
Apache Git Services


[GitHub] [cloudstack] nvazquez commented on a change in pull request #3425: [WIP DO NOT MERGE] Better tracking host maintanence success and failure

2019-06-29 Thread GitBox
nvazquez 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_r298812976
 
 

 ##
 File path: server/src/main/java/com/cloud/resource/ResourceManagerImpl.java
 ##
 @@ -1353,46 +1353,57 @@ 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");
+protected boolean setHostIntoPrepareForMaintenanceWithErrors(HostVO host, 
List errorVms) throws NoTransitionException {
+s_logger.debug("Host " + host.getUuid() + " entering in 
PrepareForMaintenanceWithErrors state");
+configureVncAccessForKVMHostFailedMigrations(host, errorVms);
 resourceStateTransitTo(host, ResourceState.Event.UnableToMigrate, 
_nodeId);
 return true;
 }
 
+protected boolean setHostIntoPrepareForMaintenanceAfterErrorsFixed(HostVO 
host) throws NoTransitionException {
+s_logger.debug("Host " + host.getUuid() + " entering in 
PrepareForMaintenance state as any previous corrections have been fixed");
+resourceStateTransitTo(host, ResourceState.Event.ErrorsCorrected, 
_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 attemptMaintain(HostVO host) throws 
NoTransitionException {
+private 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 allVmsOnHost = _vmDao.listByHostId(hostId);
-final List migratingVms = 
_vmDao.listVmsMigratingFromHost(hostId);
-final List failedMigrations = 
_vmDao.listNonMigratingVmsByHostEqualsLastHost(hostId);
-boolean hasPendingWorkForVMs = false;
+boolean hasPendingMigrationWorks = false;
 for (VMInstanceVO vmInstanceVO : allVmsOnHost) {
-if (_haMgr.hasPendingHaWork(vmInstanceVO.getId())) {
-hasPendingWorkForVMs = true;
+if (_haMgr.hasPendingMigrationsWork(vmInstanceVO.getId())) {
+hasPendingMigrationWorks = true;
 break;
 }
 }
 
-if (!hasPendingWorkForVMs) {
-if ((CollectionUtils.isNotEmpty(_vmDao.findByHostInStates(hostId, 
State.Running)) && CollectionUtils.isEmpty(migratingVms)) ||
-(CollectionUtils.isEmpty(_vmDao.findByHostInStates(hostId, 
State.Running)) &&
-
CollectionUtils.isNotEmpty(_vmDao.findByHostInStates(hostId, State.Unknown, 
State.Error, State.Shutdowned {
-return setHostIntoErrorInMaintenance(host, failedMigrations);
-}
+final List failedMigrations = new 
ArrayList<>(_vmDao.listNonMigratingVmsByHostEqualsLastHost(hostId));
+final List errorVms = new 
ArrayList<>(_vmDao.findByHostInStates(hostId, State.Unknown, State.Error, 
State.Shutdowned));
+final boolean hasMigratingVms = 
CollectionUtils.isNotEmpty(_vmDao.listVmsMigratingFromHost(hostId));
+final boolean hasRunningVms = 
CollectionUtils.isNotEmpty(_vmDao.findByHostInStates(hostId, State.Running));
+final boolean hasFailedMigrations = 
CollectionUtils.isNotEmpty(failedMigrations);
+final boolean hasVmsInFailureStates = 
CollectionUtils.isNotEmpty(errorVms);
+errorVms.addAll(failedMigrations);
+
+if (!hasPendingMigrationWorks && (hasRunningVms || (!hasRunningVms && 
!hasMigratingVms && hasVmsInFailureStates))) {
 
 Review comment:
   Maybe this could be a separate method with a javadoc to explain it? To 
improve readability


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


With regards,
Apache Git Services


[GitHub] [cloudstack] nvazquez commented on a change in pull request #3425: [WIP DO NOT MERGE] Better tracking host maintanence success and failure

2019-06-26 Thread GitBox
nvazquez 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_r297650053
 
 

 ##
 File path: server/src/main/java/com/cloud/resource/ResourceManagerImpl.java
 ##
 @@ -2981,6 +2991,6 @@ public String getConfigComponentName() {
 
 @Override
 public ConfigKey[] getConfigKeys() {
-return new ConfigKey[] {HostMaintenanceRetries};
+return new ConfigKey[] {KvmSshToAgentEnabled};
 
 Review comment:
   No need to add this config key as it is already present on DB


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


With regards,
Apache Git Services