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

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


The following commit(s) were added to refs/heads/main by this push:
     new 5d1e54a  server: fix host anti-affinity when start batch vms (#6002)
5d1e54a is described below

commit 5d1e54a4ab1e6f884263ca87d7d2807039b81714
Author: Wei Zhou <[email protected]>
AuthorDate: Mon Feb 21 09:54:03 2022 +0100

    server: fix host anti-affinity when start batch vms (#6002)
---
 .../java/org/apache/cloudstack/affinity/HostAntiAffinityProcessor.java | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git 
a/plugins/affinity-group-processors/host-anti-affinity/src/main/java/org/apache/cloudstack/affinity/HostAntiAffinityProcessor.java
 
b/plugins/affinity-group-processors/host-anti-affinity/src/main/java/org/apache/cloudstack/affinity/HostAntiAffinityProcessor.java
index 0af118f..21ac1ac 100644
--- 
a/plugins/affinity-group-processors/host-anti-affinity/src/main/java/org/apache/cloudstack/affinity/HostAntiAffinityProcessor.java
+++ 
b/plugins/affinity-group-processors/host-anti-affinity/src/main/java/org/apache/cloudstack/affinity/HostAntiAffinityProcessor.java
@@ -16,6 +16,7 @@
 // under the License.
 package org.apache.cloudstack.affinity;
 
+import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
 
@@ -85,7 +86,7 @@ public class HostAntiAffinityProcessor extends 
AffinityProcessorBase implements
                             if (s_logger.isDebugEnabled()) {
                                 s_logger.debug("Added host " + 
groupVM.getHostId() + " to avoid set, since VM " + groupVM.getId() + " is 
present on the host");
                             }
-                        } else if 
(VirtualMachine.State.Stopped.equals(groupVM.getState()) && 
groupVM.getLastHostId() != null) {
+                        } else if 
(Arrays.asList(VirtualMachine.State.Starting, 
VirtualMachine.State.Stopped).contains(groupVM.getState()) && 
groupVM.getLastHostId() != null) {
                             long secondsSinceLastUpdate = 
(DateUtil.currentGMTTime().getTime() - groupVM.getUpdateTime().getTime()) / 
1000;
                             if (secondsSinceLastUpdate < 
_vmCapacityReleaseInterval) {
                                 avoid.addHost(groupVM.getLastHostId());

Reply via email to