server: Dedicated hosts should be 'Not Suitable' while find hosts for vm migration (#4001)

While migrate a vm, in the popup, the host dedicated to other accounts/domains are also 'Suitable" for migration, which is obviously wrong.

The same issue happens with api findHostsForMigration
This commit is contained in:
Wei Zhou 2020-07-04 07:31:41 +02:00 committed by GitHub
parent 5526342f4a
commit 4da374b6b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 4 deletions

View File

@ -16,6 +16,7 @@
// under the License.
package com.cloud.deploy;
import com.cloud.dc.DataCenter;
import com.cloud.deploy.DeploymentPlanner.ExcludeList;
import com.cloud.exception.AffinityConflictException;
import com.cloud.exception.InsufficientServerCapacityException;
@ -49,4 +50,6 @@ public interface DeploymentPlanningManager extends Manager {
void cleanupVMReservations();
DeploymentPlanner getDeploymentPlannerByName(String plannerName);
void checkForNonDedicatedResources(VirtualMachineProfile vmProfile, DataCenter dc, ExcludeList avoids);
}

View File

@ -351,9 +351,6 @@ StateListener<State, VirtualMachine.Event, VirtualMachine> {
}
}
if (vm.getType() == VirtualMachine.Type.User) {
checkForNonDedicatedResources(vmProfile, dc, avoids);
}
if (s_logger.isDebugEnabled()) {
s_logger.debug("Deploy avoids pods: " + avoids.getPodsToAvoid() + ", clusters: " + avoids.getClustersToAvoid() + ", hosts: " + avoids.getHostsToAvoid());
}
@ -561,7 +558,8 @@ StateListener<State, VirtualMachine.Event, VirtualMachine> {
return null;
}
private void checkForNonDedicatedResources(VirtualMachineProfile vmProfile, DataCenter dc, ExcludeList avoids) {
@Override
public void checkForNonDedicatedResources(VirtualMachineProfile vmProfile, DataCenter dc, ExcludeList avoids) {
boolean isExplicit = false;
VirtualMachine vm = vmProfile.getVirtualMachine();

View File

@ -1321,6 +1321,11 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
}
}
if (vm.getType() == VirtualMachine.Type.User || vm.getType() == VirtualMachine.Type.DomainRouter) {
final DataCenterVO dc = _dcDao.findById(srcHost.getDataCenterId());
_dpMgr.checkForNonDedicatedResources(vmProfile, dc, excludes);
}
for (final HostAllocator allocator : hostAllocators) {
if (canMigrateWithStorage) {
suitableHosts = allocator.allocateTo(vmProfile, plan, Host.Type.Routing, excludes, allHosts, HostAllocator.RETURN_UPTO_ALL, false);