cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tall...@apache.org
Subject [49/60] [abbrv] git commit: updated refs/heads/marvin to 0e223d6
Date Tue, 08 Apr 2014 12:26:04 GMT
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/2530bf96
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/2530bf96
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/2530bf96

Branch: refs/heads/marvin
Commit: 2530bf965888cfbdf80eca07644eb5d5f226ab32
Parents: 6da087e
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 15:43:46 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/2530bf96/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/2530bf96/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/2530bf96/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 3eb51a5..0fefd62 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/2530bf96/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