cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sanjaytripa...@apache.org
Subject git commit: updated refs/heads/4.4 to ce966c8
Date Mon, 07 Apr 2014 10:31:28 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/4.4 df4a21ae3 -> ce966c8b3


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


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/ce966c8b
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/ce966c8b
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/ce966c8b

Branch: refs/heads/4.4
Commit: ce966c8b381da9e3b22538d17f7e4e1b180a4a14
Parents: df4a21a
Author: Sanjay Tripathi <sanjay.tripathi@citrix.com>
Authored: Mon Apr 7 15:43:46 2014 +0530
Committer: Sanjay Tripathi <sanjay.tripathi@citrix.com>
Committed: Mon Apr 7 16:05:58 2014 +0530

----------------------------------------------------------------------
 .../src/com/cloud/resource/ResourceManager.java |  7 +++++++
 .../allocator/impl/FirstFitAllocator.java       | 20 ++++++++++++++++++--
 .../com/cloud/resource/ResourceManagerImpl.java |  7 +++++++
 .../cloud/resource/MockResourceManagerImpl.java |  6 ++++++
 4 files changed, 38 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ce966c8b/engine/components-api/src/com/cloud/resource/ResourceManager.java
----------------------------------------------------------------------
diff --git a/engine/components-api/src/com/cloud/resource/ResourceManager.java b/engine/components-api/src/com/cloud/resource/ResourceManager.java
index 5a9bddb..0608cb4 100755
--- a/engine/components-api/src/com/cloud/resource/ResourceManager.java
+++ b/engine/components-api/src/com/cloud/resource/ResourceManager.java
@@ -142,6 +142,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
      * @param vgpuType the VGPU type

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ce966c8b/server/src/com/cloud/agent/manager/allocator/impl/FirstFitAllocator.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/agent/manager/allocator/impl/FirstFitAllocator.java b/server/src/com/cloud/agent/manager/allocator/impl/FirstFitAllocator.java
index 3736884..a451fad 100755
--- a/server/src/com/cloud/agent/manager/allocator/impl/FirstFitAllocator.java
+++ b/server/src/com/cloud/agent/manager/allocator/impl/FirstFitAllocator.java
@@ -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;
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ce966c8b/server/src/com/cloud/resource/ResourceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/resource/ResourceManagerImpl.java b/server/src/com/cloud/resource/ResourceManagerImpl.java
index 5a5c196..0bbc2f0 100755
--- a/server/src/com/cloud/resource/ResourceManagerImpl.java
+++ b/server/src/com/cloud/resource/ResourceManagerImpl.java
@@ -2501,6 +2501,13 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
     }
 
     @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) {
             vgpuType = vGPUType.passthrough.getType();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ce966c8b/server/test/com/cloud/resource/MockResourceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/resource/MockResourceManagerImpl.java b/server/test/com/cloud/resource/MockResourceManagerImpl.java
index e6bf9a2..8c5f5da 100644
--- a/server/test/com/cloud/resource/MockResourceManagerImpl.java
+++ b/server/test/com/cloud/resource/MockResourceManagerImpl.java
@@ -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;
+    }
 }


Mime
View raw message