server: cannot deploy/start vm if service offering has multiple tags#5521
server: cannot deploy/start vm if service offering has multiple tags#5521yadvr merged 1 commit intoapache:mainfrom
Conversation
|
@blueorangutan package |
|
@nvazquez a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. |
|
Packaging result: ✔️ el7 ✔️ el8 ✔️ debian ✔️ suse15. SL-JID 1426 |
|
@blueorangutan test |
|
@nvazquez a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests |
nvazquez
left a comment
There was a problem hiding this comment.
LGTM - Manually verified
|
Ping for review @sureshanaparti @davidjumani @rhtyd |
|
Trillian test result (tid-2229)
|
| + "HAVING tag_count = %s "; | ||
| private static final String SEPARATOR = ","; | ||
| private static final String LIST_CLUSTERID_FOR_HOST_TAG = "select distinct cluster_id from host join host_tags on host.id = host_tags.host_id and host_tags.tag = ?"; | ||
| private static final String LIST_CLUSTERID_FOR_HOST_TAG = "select distinct cluster_id from host join ( %s ) AS selected_hosts ON host.id = selected_hosts.host_id"; |
There was a problem hiding this comment.
@rhtyd It seems, all the tags are part of the sub-query stmt "LIST_HOST_IDS_BY_COMPUTETAGS" and the returned hosts from that sub-query were considered from further filtering.
There was a problem hiding this comment.
Should
%sbe replaced with?
@rhtyd
see suresh's comment above.
cloudstack/engine/schema/src/main/java/com/cloud/host/dao/HostDaoImpl.java
Lines 1208 to 1213 in fccd02b
an example of final sql is (if there are 3 tags)
select distinct cluster_id from host join
( SELECT filtered.host_id, COUNT(filtered.tag) AS tag_count FROM (SELECT host_id, tag FROM host_tags GROUP BY host_id,tag) AS filtered WHERE tag IN(?,?,?) GROUP BY host_id HAVING tag_count = 3 ) AS selected_hosts
ON host.id = selected_hosts.host_id;
Description
This PR fixes an issue in #4399
Steps to reproduce the issue
(1) create service offering with multiple host tags (2 or more)
(2) create a vm with the service offering
expected result
vm is started or
get error message "No suitable host found for follow compute offering tags: tag1,tag2"
actual result:
Got exception
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity
Screenshots (if appropriate):
How Has This Been Tested?