This is an automated email from the ASF dual-hosted git repository.
dahn pushed a commit to branch 4.17
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/4.17 by this push:
new d182eacf86 host affinity: fix vm cannot be started if a vm is stopped
in the affinity group (#6936)
d182eacf86 is described below
commit d182eacf8622d3ef462b6ef56fb95b78028877b6
Author: Wei Zhou <[email protected]>
AuthorDate: Tue Dec 6 10:05:49 2022 +0100
host affinity: fix vm cannot be started if a vm is stopped in the affinity
group (#6936)
---
.../java/org/apache/cloudstack/affinity/HostAffinityProcessor.java | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git
a/plugins/affinity-group-processors/host-affinity/src/main/java/org/apache/cloudstack/affinity/HostAffinityProcessor.java
b/plugins/affinity-group-processors/host-affinity/src/main/java/org/apache/cloudstack/affinity/HostAffinityProcessor.java
index 055a6442e1..0e7c536b0f 100644
---
a/plugins/affinity-group-processors/host-affinity/src/main/java/org/apache/cloudstack/affinity/HostAffinityProcessor.java
+++
b/plugins/affinity-group-processors/host-affinity/src/main/java/org/apache/cloudstack/affinity/HostAffinityProcessor.java
@@ -81,7 +81,9 @@ public class HostAffinityProcessor extends
AffinityProcessorBase implements Affi
Set<Long> hostIds = new HashSet<>();
for (Long groupVMId : vmIds) {
VMInstanceVO groupVM = _vmInstanceDao.findById(groupVMId);
- hostIds.add(groupVM.getHostId());
+ if (groupVM != null && groupVM.getHostId() != null) {
+ hostIds.add(groupVM.getHostId());
+ }
}
return hostIds;
}