CLOUDSTACK-6345: Non gpu enabled VMs are getting deployed in gpu enabled Hosts.

This commit is contained in:
Sanjay Tripathi 2014-04-07 15:43:46 +05:30
parent 6da087e601
commit 2530bf9658
4 changed files with 38 additions and 2 deletions

View File

@ -141,6 +141,13 @@ public interface ResourceManager extends ResourceService {
*/
List<HostVO> listAllUpAndEnabledNonHAHosts(Type type, Long clusterId, Long podId, long dcId);
/**
* Check if host is GPU enabled
* @param hostId the host to be checked
* @return true if host contains GPU card else false
*/
boolean isHostGpuEnabled(long hostId);
/**
* Check if host has GPU devices available
* @param hostId the host to be checked

View File

@ -243,7 +243,7 @@ public class FirstFitAllocator extends AdapterBase implements HostAllocator {
// We will try to reorder the host lists such that we give priority to hosts that have
// the minimums to support a VM's requirements
hosts = prioritizeHosts(template, hosts);
hosts = prioritizeHosts(template, offering, hosts);
if (s_logger.isDebugEnabled()) {
s_logger.debug("Found " + hosts.size() + " hosts for allocation after prioritization: " + hosts);
@ -353,7 +353,7 @@ public class FirstFitAllocator extends AdapterBase implements HostAllocator {
return true;
}
protected List<? extends Host> prioritizeHosts(VMTemplateVO template, List<? extends Host> hosts) {
protected List<? extends Host> prioritizeHosts(VMTemplateVO template, ServiceOffering offering, List<? extends Host> hosts) {
if (template == null) {
return hosts;
}
@ -416,6 +416,22 @@ public class FirstFitAllocator extends AdapterBase implements HostAllocator {
prioritizedHosts.addAll(0, highPriorityHosts);
prioritizedHosts.addAll(lowPriorityHosts);
// if service offering is not GPU enabled then move all the GPU enabled hosts to the end of priority list.
if (_serviceOfferingDetailsDao.findDetail(offering.getId(), GPU.Keys.vgpuType.toString()) == null) {
List<Host> gpuEnabledHosts = new ArrayList<Host>();
// Check for GPU enabled hosts.
for (Host host : prioritizedHosts) {
if (_resourceMgr.isHostGpuEnabled(host.getId())) {
gpuEnabledHosts.add(host);
}
}
// Move GPU enabled hosts to the end of list
if(!gpuEnabledHosts.isEmpty()) {
prioritizedHosts.removeAll(gpuEnabledHosts);
prioritizedHosts.addAll(gpuEnabledHosts);
}
}
return prioritizedHosts;
}

View File

@ -2500,6 +2500,13 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
return sc.list();
}
@Override
public boolean isHostGpuEnabled(long hostId) {
SearchCriteria<HostGpuGroupsVO> sc = _gpuAvailability.create();
sc.setParameters("hostId", hostId);
return _hostGpuGroupsDao.customSearch(sc, null).size() > 0 ? true : false;
}
@Override
public List<HostGpuGroupsVO> listAvailableGPUDevice(long hostId, String vgpuType) {
if (vgpuType == null) {

View File

@ -585,4 +585,10 @@ public class MockResourceManagerImpl extends ManagerBase implements ResourceMana
// TODO Auto-generated method stub
return null;
}
@Override
public boolean isHostGpuEnabled(long hostId) {
// TODO Auto-generated method stub
return false;
}
}