mirror of
https://github.com/apache/cloudstack.git
synced 2025-12-16 18:43:26 +01:00
Fix bug CS-15679 Max guest limit of hypervisor capabilities does not work properly
This commit is contained in:
parent
bd2a130251
commit
a74687128e
@ -77,7 +77,6 @@ public class FirstFitAllocator implements HostAllocator {
|
||||
@Inject ConfigurationDao _configDao = null;
|
||||
@Inject GuestOSDao _guestOSDao = null;
|
||||
@Inject GuestOSCategoryDao _guestOSCategoryDao = null;
|
||||
@Inject HypervisorCapabilitiesDao _hypervisorCapabilitiesDao = null;
|
||||
@Inject VMInstanceDao _vmInstanceDao = null;
|
||||
@Inject ResourceManager _resourceMgr;
|
||||
float _factor = 1;
|
||||
@ -206,11 +205,9 @@ public class FirstFitAllocator implements HostAllocator {
|
||||
}
|
||||
|
||||
//find number of guest VMs occupying capacity on this host.
|
||||
Long vmCount = _vmInstanceDao.countRunningByHostId(host.getId());
|
||||
Long maxGuestLimit = getHostMaxGuestLimit(host);
|
||||
if (vmCount.longValue() == maxGuestLimit.longValue()){
|
||||
if (_capacityMgr.checkIfHostReachMaxGuestLimit(host)){
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Host name: " + host.getName() + ", hostId: "+ host.getId() +" already has max Running VMs(count includes system VMs), limit is: " + maxGuestLimit + " , skipping this and trying other available hosts");
|
||||
s_logger.debug("Host name: " + host.getName() + ", hostId: "+ host.getId() +" already has max Running VMs(count includes system VMs), skipping this and trying other available hosts");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@ -393,15 +390,7 @@ public class FirstFitAllocator implements HostAllocator {
|
||||
GuestOSCategoryVO guestOSCategory = _guestOSCategoryDao.findById(guestOSCategoryId);
|
||||
return guestOSCategory.getName();
|
||||
}
|
||||
|
||||
protected Long getHostMaxGuestLimit(HostVO host) {
|
||||
HypervisorType hypervisorType = host.getHypervisorType();
|
||||
String hypervisorVersion = host.getHypervisorVersion();
|
||||
|
||||
Long maxGuestLimit = _hypervisorCapabilitiesDao.getMaxGuestsLimit(hypervisorType, hypervisorVersion);
|
||||
return maxGuestLimit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
|
||||
_name = name;
|
||||
|
||||
@ -48,4 +48,11 @@ public interface CapacityManager extends Manager {
|
||||
* @return total allocated capacity for the storage pool
|
||||
*/
|
||||
long getAllocatedPoolCapacity(StoragePoolVO pool, VMTemplateVO templateForVmCreation);
|
||||
|
||||
/**
|
||||
* Check if specified host's running VM count has reach hypervisor limit
|
||||
* @param host the host to be checked
|
||||
* @return true if the count of host's running VMs >= hypervisor limit
|
||||
*/
|
||||
boolean checkIfHostReachMaxGuestLimit(HostVO host);
|
||||
}
|
||||
|
||||
@ -45,6 +45,8 @@ import com.cloud.exception.ConnectionException;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.Status;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.hypervisor.dao.HypervisorCapabilitiesDao;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
import com.cloud.org.Grouping.AllocationState;
|
||||
import com.cloud.resource.ResourceListener;
|
||||
@ -104,6 +106,8 @@ public class CapacityManagerImpl implements CapacityManager, StateListener<State
|
||||
SwiftManager _swiftMgr;
|
||||
@Inject
|
||||
ConfigurationManager _configMgr;
|
||||
@Inject
|
||||
HypervisorCapabilitiesDao _hypervisorCapabilitiesDao;
|
||||
|
||||
private int _vmCapacityReleaseInterval;
|
||||
private ScheduledExecutorService _executor;
|
||||
@ -827,4 +831,19 @@ public class CapacityManagerImpl implements CapacityManager, StateListener<State
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkIfHostReachMaxGuestLimit(HostVO host) {
|
||||
Long vmCount = _vmDao.countRunningByHostId(host.getId());
|
||||
HypervisorType hypervisorType = host.getHypervisorType();
|
||||
String hypervisorVersion = host.getHypervisorVersion();
|
||||
Long maxGuestLimit = _hypervisorCapabilitiesDao.getMaxGuestsLimit(hypervisorType, hypervisorVersion);
|
||||
if(vmCount.longValue() >= maxGuestLimit.longValue()){
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Host name: " + host.getName() + ", hostId: "+ host.getId() +
|
||||
" already reached max Running VMs(count includes system VMs), limit is: " + maxGuestLimit + ",Running VM counts is: "+vmCount.longValue());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -196,6 +196,8 @@ public class FirstFitPlanner extends PlannerBase implements DeploymentPlanner {
|
||||
s_logger.debug("The last host of this VM cannot be found");
|
||||
}else if(avoid.shouldAvoid(host)){
|
||||
s_logger.debug("The last host of this VM is in avoid set");
|
||||
}else if(_capacityMgr.checkIfHostReachMaxGuestLimit(host)){
|
||||
s_logger.debug("The last Host, hostId: "+ host.getId() +" already has max Running VMs(count includes system VMs), skipping this and trying other available hosts");
|
||||
}else{
|
||||
if (host.getStatus() == Status.Up && host.getResourceState() == ResourceState.Enabled) {
|
||||
if(_capacityMgr.checkIfHostHasCapacity(host.getId(), cpu_requested, ram_requested, true, cpuOverprovisioningFactor, true)){
|
||||
|
||||
@ -78,6 +78,7 @@ import com.cloud.async.AsyncJobExecutor;
|
||||
import com.cloud.async.AsyncJobManager;
|
||||
import com.cloud.async.AsyncJobVO;
|
||||
import com.cloud.async.BaseAsyncJobExecutor;
|
||||
import com.cloud.capacity.CapacityManager;
|
||||
import com.cloud.configuration.Config;
|
||||
import com.cloud.configuration.ConfigurationManager;
|
||||
import com.cloud.configuration.Resource.ResourceType;
|
||||
@ -326,9 +327,11 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
||||
@Inject
|
||||
protected UserVmDetailsDao _vmDetailsDao;
|
||||
@Inject
|
||||
protected HypervisorCapabilitiesDao _hypervisorCapabilitiesDao;
|
||||
@Inject
|
||||
protected SecurityGroupDao _securityGroupDao;
|
||||
@Inject
|
||||
protected HypervisorCapabilitiesDao _hypervisorCapabilitiesDao;
|
||||
protected CapacityManager _capacityMgr;;
|
||||
@Inject
|
||||
protected VMInstanceDao _vmInstanceDao;
|
||||
@Inject
|
||||
@ -3268,15 +3271,12 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
||||
DeployDestination dest = new DeployDestination(dcVO, pod, cluster, destinationHost);
|
||||
|
||||
//check max guest vm limit for the destinationHost
|
||||
HypervisorType hypervisorType = destinationHost.getHypervisorType();
|
||||
String hypervisorVersion = destinationHost.getHypervisorVersion();
|
||||
Long maxGuestLimit = _hypervisorCapabilitiesDao.getMaxGuestsLimit(hypervisorType, hypervisorVersion);
|
||||
Long vmCount = _vmInstanceDao.countRunningByHostId(destinationHost.getId());
|
||||
if (vmCount.longValue() == maxGuestLimit.longValue()){
|
||||
HostVO destinationHostVO = _hostDao.findById(destinationHost.getId());
|
||||
if(_capacityMgr.checkIfHostReachMaxGuestLimit(destinationHostVO)){
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Host name: " + destinationHost.getName() + ", hostId: "+ destinationHost.getId() +" already has max Running VMs(count includes system VMs), limit is: " + maxGuestLimit + " , cannot migrate to this host");
|
||||
s_logger.debug("Host name: " + destinationHost.getName() + ", hostId: "+ destinationHost.getId() +" already has max Running VMs(count includes system VMs), cannot migrate to this host");
|
||||
}
|
||||
throw new VirtualMachineMigrationException("Destination host, hostId: "+ destinationHost.getId() +" already has max Running VMs(count includes system VMs), limit is: " + maxGuestLimit + " , cannot migrate to this host");
|
||||
throw new VirtualMachineMigrationException("Destination host, hostId: "+ destinationHost.getId() +" already has max Running VMs(count includes system VMs), cannot migrate to this host");
|
||||
}
|
||||
|
||||
VMInstanceVO migratedVm = _itMgr.migrate(vm, srcHostId, dest);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user