Github user alexandrelimassantana commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/1454#discussion_r57714466 --- Diff: server/src/com/cloud/resource/ResourceManagerImpl.java --- @@ -2112,11 +2112,13 @@ private boolean doCancelMaintenance(final long hostId) { /* TODO: move to listener */ _haMgr.cancelScheduledMigrations(host); + + boolean vms_migrating = false; final List<VMInstanceVO> vms = _haMgr.findTakenMigrationWork(); for (final VMInstanceVO vm : vms) { if (vm != null && vm.getHostId() != null && vm.getHostId() == hostId) { s_logger.info("Unable to cancel migration because the vm is being migrated: " + vm); --- End diff -- Can you turn the if on line 2119 to a method call like _isVmMigrating(vm, hostId)_? Or even _vm.isMigrating(hostId)_ I think that it will improve the readability of this segment you are working. Also... is there a need to check all VMs ? Once you find one that is migrating do you still need to keep checking if they are migrating? If there is not a need, try changing the loop for a while, or issuing a break.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---