[
https://issues.apache.org/jira/browse/CLOUDSTACK-9696?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15927783#comment-15927783
]
ASF GitHub Bot commented on CLOUDSTACK-9696:
--------------------------------------------
Github user anshul1886 commented on a diff in the pull request:
https://github.com/apache/cloudstack/pull/1853#discussion_r106381321
--- Diff: server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java ---
@@ -584,105 +583,64 @@ private void
checkForNonDedicatedResources(VirtualMachineProfile vmProfile, Data
isExplicit = true;
}
- List<Long> allPodsInDc = _podDao.listAllPods(dc.getId());
- List<Long> allDedicatedPods = _dedicatedDao.listAllPods();
- allPodsInDc.retainAll(allDedicatedPods);
-
- List<Long> allClustersInDc =
_clusterDao.listAllCusters(dc.getId());
- List<Long> allDedicatedClusters = _dedicatedDao.listAllClusters();
- allClustersInDc.retainAll(allDedicatedClusters);
-
- List<Long> allHostsInDc = _hostDao.listAllHosts(dc.getId());
- List<Long> allDedicatedHosts = _dedicatedDao.listAllHosts();
- allHostsInDc.retainAll(allDedicatedHosts);
-
- //Only when the type is instance VM and not explicitly dedicated.
- if (vm.getType() == VirtualMachine.Type.User && !isExplicit) {
- //add explicitly dedicated resources in avoidList
-
- avoids.addPodList(allPodsInDc);
- avoids.addClusterList(allClustersInDc);
- avoids.addHostList(allHostsInDc);
- }
-
- //Handle the Virtual Router Case
- //No need to check the isExplicit. As both the cases are handled.
- if (vm.getType() == VirtualMachine.Type.DomainRouter) {
- long vmAccountId = vm.getAccountId();
- long vmDomainId = vm.getDomainId();
-
- //Lists all explicitly dedicated resources from vm account ID
or domain ID.
- List<Long> allPodsFromDedicatedID = new ArrayList<Long>();
- List<Long> allClustersFromDedicatedID = new ArrayList<Long>();
- List<Long> allHostsFromDedicatedID = new ArrayList<Long>();
-
- //Whether the dedicated resources belong to Domain or not. If
not, it may belongs to Account or no dedication.
- List<AffinityGroupDomainMapVO> domainGroupMappings =
_affinityGroupDomainMapDao.listByDomain(vmDomainId);
-
- //For temporary storage and indexing.
- List<DedicatedResourceVO> tempStorage;
-
- if (domainGroupMappings == null ||
domainGroupMappings.isEmpty()) {
- //The dedicated resource belongs to VM Account ID.
-
- tempStorage = _dedicatedDao.searchDedicatedPods(null,
vmDomainId, vmAccountId, null).first();
-
- for(DedicatedResourceVO vo : tempStorage) {
- allPodsFromDedicatedID.add(vo.getPodId());
- }
-
- tempStorage.clear();
- tempStorage = _dedicatedDao.searchDedicatedClusters(null,
vmDomainId, vmAccountId, null).first();
+ if ((vm.getType() == VirtualMachine.Type.User && !isExplicit) ||
vm.getType() == VirtualMachine.Type.DomainRouter) {
+ List<Long> allPodsInDc = _podDao.listAllPods(dc.getId());
+ List<Long> allDedicatedPods = _dedicatedDao.listAllPods();
+ allPodsInDc.retainAll(allDedicatedPods);
- for(DedicatedResourceVO vo : tempStorage) {
- allClustersFromDedicatedID.add(vo.getClusterId());
- }
+ List<Long> allClustersInDc =
_clusterDao.listAllCusters(dc.getId());
+ List<Long> allDedicatedClusters =
_dedicatedDao.listAllClusters();
+ allClustersInDc.retainAll(allDedicatedClusters);
- tempStorage.clear();
- tempStorage = _dedicatedDao.searchDedicatedHosts(null,
vmDomainId, vmAccountId, null).first();
+ List<Long> allHostsInDc = _hostDao.listAllHosts(dc.getId());
+ List<Long> allDedicatedHosts = _dedicatedDao.listAllHosts();
+ allHostsInDc.retainAll(allDedicatedHosts);
- for(DedicatedResourceVO vo : tempStorage) {
- allHostsFromDedicatedID.add(vo.getHostId());
- }
+ //Only when the type is instance VM and not explicitly
dedicated.
+ if (vm.getType() == VirtualMachine.Type.User && !isExplicit) {
+ //add explicitly dedicated resources in avoidList
- //Remove the dedicated ones from main list
- allPodsInDc.removeAll(allPodsFromDedicatedID);
- allClustersInDc.removeAll(allClustersFromDedicatedID);
- allHostsInDc.removeAll(allHostsFromDedicatedID);
+ avoids.addPodList(allPodsInDc);
+ avoids.addClusterList(allClustersInDc);
+ avoids.addHostList(allHostsInDc);
}
- else {
- //The dedicated resource belongs to VM Domain ID or No
dedication.
- tempStorage = _dedicatedDao.searchDedicatedPods(null,
vmDomainId, null, null).first();
+ //Handle the Virtual Router Case
+ //No need to check the isExplicit. As both the cases are
handled.
+ if (vm.getType() == VirtualMachine.Type.DomainRouter) {
+ long vmAccountId = vm.getAccountId();
+ long vmDomainId = vm.getDomainId();
- for(DedicatedResourceVO vo : tempStorage) {
- allPodsFromDedicatedID.add(vo.getPodId());
- }
+ List<Long> allPodsFromDedicatedID = new ArrayList<Long>();
+ List<Long> allClustersFromDedicatedID = new
ArrayList<Long>();
+ List<Long> allHostsFromDedicatedID = new ArrayList<Long>();
- tempStorage.clear();
- tempStorage = _dedicatedDao.searchDedicatedClusters(null,
vmDomainId, null, null).first();
-
- for(DedicatedResourceVO vo : tempStorage) {
- allClustersFromDedicatedID.add(vo.getClusterId());
- }
+ for (DedicatedResourceVO vo :
_dedicatedDao.listAvailableResources(vmAccountId, vmDomainId)) {
+ if (vo.getPodId() != null) {
+ allPodsFromDedicatedID.add(vo.getPodId());
+ continue;
+ }
- tempStorage.clear();
- tempStorage = _dedicatedDao.searchDedicatedHosts(null,
vmDomainId, null, null).first();
+ if (vo.getClusterId() != null) {
+ allClustersFromDedicatedID.add(vo.getClusterId());
+ continue;
+ }
- for(DedicatedResourceVO vo : tempStorage) {
- allHostsFromDedicatedID.add(vo.getHostId());
+ if (vo.getHostId() != null) {
+ allHostsFromDedicatedID.add(vo.getHostId());
+ }
}
//Remove the dedicated ones from main list
allPodsInDc.removeAll(allPodsFromDedicatedID);
--- End diff --
@koushik-das User can specify the affinity group for VM while deploying VM.
So if user has specified the affinity group then only that VM needs to go to
dedicated hosts. While in case of router user has not such option and needs to
be inferred from account/domain of the user. These whole checks are mainly
introduced to avoid virtual router going to dedicated resources of other
account/domain.
> Fail to deploy VM on dedicating clusters and hosts
> --------------------------------------------------
>
> Key: CLOUDSTACK-9696
> URL: https://issues.apache.org/jira/browse/CLOUDSTACK-9696
> Project: CloudStack
> Issue Type: Bug
> Security Level: Public(Anyone can view this level - this is the
> default.)
> Reporter: Anshul Gangwar
> Assignee: Anshul Gangwar
>
> IN the below scenario:
> cluster C1 is having 2 hosts, H1 and H2.
> Root domain is having 2 sub domain, D1 and D2
> C1 is dedicated to Root and H1 and H2 are dedicated to D1 and D2 respectively
> D1 and D2 has users U1 and U2 respectively
> Login into U1 and deploy the VM
> router and VM deployment failed with the error:
> com.cloud.exception.InsufficientServerCapacityException: Unable to create a
> deployment
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)