rafaelweingartner commented on a change in pull request #2493:
CLOUDSTACK-10326: Prevent hosts fall into Maintenance when there are running
VMs on it
URL: https://github.com/apache/cloudstack/pull/2493#discussion_r178048428
##########
File path: server/src/com/cloud/resource/ResourceManagerImpl.java
##########
@@ -1296,10 +1296,17 @@ public boolean checkAndMaintain(final long hostId) {
if (host.getType() != Host.Type.Storage) {
final List<VMInstanceVO> vos = _vmDao.listByHostId(hostId);
final List<VMInstanceVO> vosMigrating =
_vmDao.listVmsMigratingFromHost(hostId);
+ final List<VMInstanceVO> failedMigratedVms =
_vmDao.listNonMigratingVmsByHostEqualsLastHost(hostId);
if (vos.isEmpty() && vosMigrating.isEmpty()) {
- resourceStateTransitTo(host,
ResourceState.Event.InternalEnterMaintenance, _nodeId);
- hostInMaintenance = true;
-
ActionEventUtils.onCompletedActionEvent(CallContext.current().getCallingUserId(),
CallContext.current().getCallingAccountId(), EventVO.LEVEL_INFO,
EventTypes.EVENT_MAINTENANCE_PREPARE, "completed maintenance for host " +
hostId, 0);
+ if (!failedMigratedVms.isEmpty()) {
Review comment:
What about extracting the body of this IF to a method?
This allows documentation and unit tests to be easily written.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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