mirror of
https://github.com/apache/cloudstack.git
synced 2025-12-18 03:23:45 +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 ConfigurationDao _configDao = null;
|
||||||
@Inject GuestOSDao _guestOSDao = null;
|
@Inject GuestOSDao _guestOSDao = null;
|
||||||
@Inject GuestOSCategoryDao _guestOSCategoryDao = null;
|
@Inject GuestOSCategoryDao _guestOSCategoryDao = null;
|
||||||
@Inject HypervisorCapabilitiesDao _hypervisorCapabilitiesDao = null;
|
|
||||||
@Inject VMInstanceDao _vmInstanceDao = null;
|
@Inject VMInstanceDao _vmInstanceDao = null;
|
||||||
@Inject ResourceManager _resourceMgr;
|
@Inject ResourceManager _resourceMgr;
|
||||||
float _factor = 1;
|
float _factor = 1;
|
||||||
@ -206,11 +205,9 @@ public class FirstFitAllocator implements HostAllocator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//find number of guest VMs occupying capacity on this host.
|
//find number of guest VMs occupying capacity on this host.
|
||||||
Long vmCount = _vmInstanceDao.countRunningByHostId(host.getId());
|
if (_capacityMgr.checkIfHostReachMaxGuestLimit(host)){
|
||||||
Long maxGuestLimit = getHostMaxGuestLimit(host);
|
|
||||||
if (vmCount.longValue() == maxGuestLimit.longValue()){
|
|
||||||
if (s_logger.isDebugEnabled()) {
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
@ -394,14 +391,6 @@ public class FirstFitAllocator implements HostAllocator {
|
|||||||
return guestOSCategory.getName();
|
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
|
@Override
|
||||||
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
|
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
|
||||||
_name = name;
|
_name = name;
|
||||||
|
|||||||
@ -48,4 +48,11 @@ public interface CapacityManager extends Manager {
|
|||||||
* @return total allocated capacity for the storage pool
|
* @return total allocated capacity for the storage pool
|
||||||
*/
|
*/
|
||||||
long getAllocatedPoolCapacity(StoragePoolVO pool, VMTemplateVO templateForVmCreation);
|
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.HostVO;
|
||||||
import com.cloud.host.Status;
|
import com.cloud.host.Status;
|
||||||
import com.cloud.host.dao.HostDao;
|
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.offering.ServiceOffering;
|
||||||
import com.cloud.org.Grouping.AllocationState;
|
import com.cloud.org.Grouping.AllocationState;
|
||||||
import com.cloud.resource.ResourceListener;
|
import com.cloud.resource.ResourceListener;
|
||||||
@ -104,6 +106,8 @@ public class CapacityManagerImpl implements CapacityManager, StateListener<State
|
|||||||
SwiftManager _swiftMgr;
|
SwiftManager _swiftMgr;
|
||||||
@Inject
|
@Inject
|
||||||
ConfigurationManager _configMgr;
|
ConfigurationManager _configMgr;
|
||||||
|
@Inject
|
||||||
|
HypervisorCapabilitiesDao _hypervisorCapabilitiesDao;
|
||||||
|
|
||||||
private int _vmCapacityReleaseInterval;
|
private int _vmCapacityReleaseInterval;
|
||||||
private ScheduledExecutorService _executor;
|
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");
|
s_logger.debug("The last host of this VM cannot be found");
|
||||||
}else if(avoid.shouldAvoid(host)){
|
}else if(avoid.shouldAvoid(host)){
|
||||||
s_logger.debug("The last host of this VM is in avoid set");
|
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{
|
}else{
|
||||||
if (host.getStatus() == Status.Up && host.getResourceState() == ResourceState.Enabled) {
|
if (host.getStatus() == Status.Up && host.getResourceState() == ResourceState.Enabled) {
|
||||||
if(_capacityMgr.checkIfHostHasCapacity(host.getId(), cpu_requested, ram_requested, true, cpuOverprovisioningFactor, true)){
|
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.AsyncJobManager;
|
||||||
import com.cloud.async.AsyncJobVO;
|
import com.cloud.async.AsyncJobVO;
|
||||||
import com.cloud.async.BaseAsyncJobExecutor;
|
import com.cloud.async.BaseAsyncJobExecutor;
|
||||||
|
import com.cloud.capacity.CapacityManager;
|
||||||
import com.cloud.configuration.Config;
|
import com.cloud.configuration.Config;
|
||||||
import com.cloud.configuration.ConfigurationManager;
|
import com.cloud.configuration.ConfigurationManager;
|
||||||
import com.cloud.configuration.Resource.ResourceType;
|
import com.cloud.configuration.Resource.ResourceType;
|
||||||
@ -326,9 +327,11 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||||||
@Inject
|
@Inject
|
||||||
protected UserVmDetailsDao _vmDetailsDao;
|
protected UserVmDetailsDao _vmDetailsDao;
|
||||||
@Inject
|
@Inject
|
||||||
|
protected HypervisorCapabilitiesDao _hypervisorCapabilitiesDao;
|
||||||
|
@Inject
|
||||||
protected SecurityGroupDao _securityGroupDao;
|
protected SecurityGroupDao _securityGroupDao;
|
||||||
@Inject
|
@Inject
|
||||||
protected HypervisorCapabilitiesDao _hypervisorCapabilitiesDao;
|
protected CapacityManager _capacityMgr;;
|
||||||
@Inject
|
@Inject
|
||||||
protected VMInstanceDao _vmInstanceDao;
|
protected VMInstanceDao _vmInstanceDao;
|
||||||
@Inject
|
@Inject
|
||||||
@ -3268,15 +3271,12 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||||||
DeployDestination dest = new DeployDestination(dcVO, pod, cluster, destinationHost);
|
DeployDestination dest = new DeployDestination(dcVO, pod, cluster, destinationHost);
|
||||||
|
|
||||||
//check max guest vm limit for the destinationHost
|
//check max guest vm limit for the destinationHost
|
||||||
HypervisorType hypervisorType = destinationHost.getHypervisorType();
|
HostVO destinationHostVO = _hostDao.findById(destinationHost.getId());
|
||||||
String hypervisorVersion = destinationHost.getHypervisorVersion();
|
if(_capacityMgr.checkIfHostReachMaxGuestLimit(destinationHostVO)){
|
||||||
Long maxGuestLimit = _hypervisorCapabilitiesDao.getMaxGuestsLimit(hypervisorType, hypervisorVersion);
|
|
||||||
Long vmCount = _vmInstanceDao.countRunningByHostId(destinationHost.getId());
|
|
||||||
if (vmCount.longValue() == maxGuestLimit.longValue()){
|
|
||||||
if (s_logger.isDebugEnabled()) {
|
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);
|
VMInstanceVO migratedVm = _itMgr.migrate(vm, srcHostId, dest);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user