Skip to content

Commit b215abc

Browse files
server: do not check affinity groups if no vm group mappings (#9542)
this fixes the exception in smoke test test_affinity_groups ``` 2024-08-19T08:34:15,132 ERROR [c.c.a.ApiAsyncJobDispatcher] (API-Job-Executor-87:[ctx-f7804a8e, job-9232]) (logid:b71ddec8) Unexpected exception while executing org.apache.cloudstack.api.command.admin.vm.DeployVMCmdByAdmin com.cloud.utils.exception.CloudRuntimeException: Unable to find on DB, due to: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') FOR UPDATE' at line 1 at com.cloud.utils.db.GenericDaoBase.searchIncludingRemoved(GenericDaoBase.java:441) at com.cloud.utils.db.GenericDaoBase.searchIncludingRemoved(GenericDaoBase.java:368) at com.cloud.utils.db.GenericDaoBase.search(GenericDaoBase.java:357) at com.cloud.utils.db.GenericDaoBase.lockRows(GenericDaoBase.java:343) at org.apache.cloudstack.affinity.dao.AffinityGroupDaoImpl.listByIds(AffinityGroupDaoImpl.java:171) ```
1 parent 9b22cd5 commit b215abc

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

plugins/affinity-group-processors/host-anti-affinity/src/main/java/org/apache/cloudstack/affinity/HostAntiAffinityProcessor.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@ public boolean check(VirtualMachineProfile vmProfile, DeployDestination plannedD
139139
VirtualMachine vm = vmProfile.getVirtualMachine();
140140

141141
List<AffinityGroupVMMapVO> vmGroupMappings = _affinityGroupVMMapDao.findByVmIdType(vm.getId(), getType());
142+
if (CollectionUtils.isEmpty(vmGroupMappings)) {
143+
return true;
144+
}
142145

143146
for (AffinityGroupVMMapVO vmGroupMapping : vmGroupMappings) {
144147
// if more than 1 VM's are present in the group then check for

0 commit comments

Comments
 (0)