You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ro...@apache.org on 2020/07/04 05:31:56 UTC

[cloudstack] branch 4.13 updated: server: Dedicated hosts should be 'Not Suitable' while find hosts for vm migration (#4001)

This is an automated email from the ASF dual-hosted git repository.

rohit pushed a commit to branch 4.13
in repository https://gitbox.apache.org/repos/asf/cloudstack.git


The following commit(s) were added to refs/heads/4.13 by this push:
     new 4da374b  server: Dedicated hosts should be 'Not Suitable' while find hosts for vm migration (#4001)
4da374b is described below

commit 4da374b6b404d401d6a1f39d4df45e72fcabbbf8
Author: Wei Zhou <w....@global.leaseweb.com>
AuthorDate: Sat Jul 4 07:31:41 2020 +0200

    server: Dedicated hosts should be 'Not Suitable' while find hosts for vm migration (#4001)
    
    While migrate a vm, in the popup, the host dedicated to other accounts/domains are also 'Suitable" for migration, which is obviously wrong.
    
    The same issue happens with api findHostsForMigration
---
 .../src/main/java/com/cloud/deploy/DeploymentPlanningManager.java   | 3 +++
 .../main/java/com/cloud/deploy/DeploymentPlanningManagerImpl.java   | 6 ++----
 server/src/main/java/com/cloud/server/ManagementServerImpl.java     | 5 +++++
 3 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/engine/components-api/src/main/java/com/cloud/deploy/DeploymentPlanningManager.java b/engine/components-api/src/main/java/com/cloud/deploy/DeploymentPlanningManager.java
index ee6721a..2266cd5 100644
--- a/engine/components-api/src/main/java/com/cloud/deploy/DeploymentPlanningManager.java
+++ b/engine/components-api/src/main/java/com/cloud/deploy/DeploymentPlanningManager.java
@@ -16,6 +16,7 @@
 // under the License.
 package com.cloud.deploy;
 
+import com.cloud.dc.DataCenter;
 import com.cloud.deploy.DeploymentPlanner.ExcludeList;
 import com.cloud.exception.AffinityConflictException;
 import com.cloud.exception.InsufficientServerCapacityException;
@@ -49,4 +50,6 @@ public interface DeploymentPlanningManager extends Manager {
     void cleanupVMReservations();
 
     DeploymentPlanner getDeploymentPlannerByName(String plannerName);
+
+    void checkForNonDedicatedResources(VirtualMachineProfile vmProfile, DataCenter dc, ExcludeList avoids);
 }
diff --git a/server/src/main/java/com/cloud/deploy/DeploymentPlanningManagerImpl.java b/server/src/main/java/com/cloud/deploy/DeploymentPlanningManagerImpl.java
index a95f4ef..0dd4462 100644
--- a/server/src/main/java/com/cloud/deploy/DeploymentPlanningManagerImpl.java
+++ b/server/src/main/java/com/cloud/deploy/DeploymentPlanningManagerImpl.java
@@ -351,9 +351,6 @@ StateListener<State, VirtualMachine.Event, VirtualMachine> {
             }
         }
 
-        if (vm.getType() == VirtualMachine.Type.User) {
-            checkForNonDedicatedResources(vmProfile, dc, avoids);
-        }
         if (s_logger.isDebugEnabled()) {
             s_logger.debug("Deploy avoids pods: " + avoids.getPodsToAvoid() + ", clusters: " + avoids.getClustersToAvoid() + ", hosts: " + avoids.getHostsToAvoid());
         }
@@ -561,7 +558,8 @@ StateListener<State, VirtualMachine.Event, VirtualMachine> {
         return null;
     }
 
-    private void checkForNonDedicatedResources(VirtualMachineProfile vmProfile, DataCenter dc, ExcludeList avoids) {
+    @Override
+    public void checkForNonDedicatedResources(VirtualMachineProfile vmProfile, DataCenter dc, ExcludeList avoids) {
         boolean isExplicit = false;
         VirtualMachine vm = vmProfile.getVirtualMachine();
 
diff --git a/server/src/main/java/com/cloud/server/ManagementServerImpl.java b/server/src/main/java/com/cloud/server/ManagementServerImpl.java
index fdd6354..40ef0ed 100644
--- a/server/src/main/java/com/cloud/server/ManagementServerImpl.java
+++ b/server/src/main/java/com/cloud/server/ManagementServerImpl.java
@@ -1321,6 +1321,11 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
             }
         }
 
+        if (vm.getType() == VirtualMachine.Type.User || vm.getType() == VirtualMachine.Type.DomainRouter) {
+            final DataCenterVO dc = _dcDao.findById(srcHost.getDataCenterId());
+            _dpMgr.checkForNonDedicatedResources(vmProfile, dc, excludes);
+        }
+
         for (final HostAllocator allocator : hostAllocators) {
             if (canMigrateWithStorage) {
                 suitableHosts = allocator.allocateTo(vmProfile, plan, Host.Type.Routing, excludes, allHosts, HostAllocator.RETURN_UPTO_ALL, false);