Hide Forgot
Description of problem: Searching template for string "default" returns the wrong result → hammer --no-headers --csv template list --search "TEST defaul" 137,TEST default,provision → hammer --no-headers --csv template list --search "TEST default" No Result Other test result -------- Satellite 6.5 ---- → hammer --no-headers --csv template list --search "default" | wc -l 93 → hammer --no-headers --csv template list --search "defaul" | wc -l 61 Satellite 6.3(Correct result) --- → hammer --csv template list --search "default" | wc -l 122 → hammer --csv template list --search "defaul" | wc -l 122 Version-Release number of selected component (if applicable):6.5.0 How reproducible: Always Additional info: Sql Query in Satellite 6.3 Satellite 6.3: ------ SELECT COUNT(DISTINCT "templates"."id") FROM "templates" LEFT OUTER JOIN "operatingsystems_provisioning_templates" ON "operatingsystems_provisioning_templates"."provisioning_template_id" = "templates"."id" LEFT OUTER JOIN "operatingsystems" ON "operatingsystems"."id" = "operatingsystems_provisioning_templates"."operatingsystem_id" LEFT OUTER JOIN "template_combinations" ON "template_combinations"."provisioning_template_id" = "templates"."id" LEFT OUTER JOIN "environments" ON "environments"."id" = "template_combinations"."environment_id" LEFT OUTER JOIN "template_combinations" "template_combinations_templates_join" ON "template_combinations_templates_join"."provisioning_template_id" = "templates"."id" LEFT OUTER JOIN "hostgroups" ON "hostgroups"."id" = "template_combinations_templates_join"."hostgroup_id" LEFT OUTER JOIN "template_kinds" ON "template_kinds"."id" = "templates"."template_kind_id" WHERE "templates"."type" IN ('ProvisioningTemplate') AND ((("templates"."name" ILIKE '%UNSW%' OR "templates"."template" ILIKE '%UNSW%' OR "operatingsystems"."name" ILIKE '%UNSW%' OR "environments"."name" ILIKE '%UNSW%' OR "hostgroups"."name" ILIKE '%UNSW%' OR "template_kinds"."name" ILIKE '%UNSW%') AND ("templates"."name" ILIKE '%default%' OR "templates"."template" ILIKE '%default%' OR "operatingsystems"."name" ILIKE '%default%' OR "environments"."name" ILIKE '%default%' OR "hostgroups"."name" ILIKE '%default%' OR "template_kinds"."name" ILIKE '%default%'))) Satellite 6.5: ------- irb(main):010:0> ProvisioningTemplate.search_for("UNSW default").count D, [2019-02-18T16:39:01.316511 #28441] DEBUG -- : (14.2ms) SELECT COUNT(DISTINCT "templates"."id") FROM "templates" LEFT OUTER JOIN "operatingsystems_provisioning_templates" ON "operatingsystems_provisioning_templates"."provisioning_template_id" = "templates"."id" LEFT OUTER JOIN "operatingsystems" ON "operatingsystems"."id" = "operatingsystems_provisioning_templates"."operatingsystem_id" LEFT OUTER JOIN "template_combinations" ON "template_combinations"."provisioning_template_id" = "templates"."id" LEFT OUTER JOIN "environments" ON "environments"."id" = "template_combinations"."environment_id" LEFT OUTER JOIN "template_combinations" "template_combinations_templates_join" ON "template_combinations_templates_join"."provisioning_template_id" = "templates"."id" LEFT OUTER JOIN "hostgroups" ON "hostgroups"."id" = "template_combinations_templates_join"."hostgroup_id" LEFT OUTER JOIN "template_kinds" ON "template_kinds"."id" = "templates"."template_kind_id" WHERE "templates"."type" IN ('ProvisioningTemplate') AND ((("templates"."name" ILIKE '%UNSW%' OR "templates"."template" ILIKE '%UNSW%' OR "operatingsystems"."name" ILIKE '%UNSW%' OR "environments"."name" ILIKE '%UNSW%' OR "hostgroups"."name" ILIKE '%UNSW%' OR "template_kinds"."name" ILIKE '%UNSW%') AND (("templates"."default" <> 'f')))) In Satellite 6.5: the sql query search only in the default template AND (("templates"."default" <> 'f')) Workaround: Set default = true in the template
Does it work if you search like 'name ~ "TEST default"'? Note that default here relates also to "default" checkbox. You need to be a bit more explicit in the search syntax in this case.
Marek, But the same works fine in Satellite 6.3.5 and the "default" checkbox is also present in 6.3.5
> But the same works fine in Satellite 6.3.5 and the "default" checkbox is also present in 6.3.5 because by that time, we didn't have the default attribute available for searching, it's not always a bug if something behaved differently in previous version :-) In your example > hammer template list --search 'UNSW def' it defacto means search "name ~ UNSW or name ~ def" which obviously works in your second example > hammer template list --search 'UNSW default' the default is a new keyword, referring to value of "default" checkbox of a template. If you want to search for templates that contain either UNSW or default word in their name, do it this way > hammer template list --search 'name ~ UNSW or name ~ default' if you wanted to find all templates that contain "UNSW default" in their name, do it this way > hammer template list --search 'name ~ "UNSW default"' I tested all above and it works just fine. I don't think there's any bug here, so I'm closing this. Please let me know if I missed something.
After a discussion with Ranjan, I'm reopening. Because people usually don't search based on default attribute but rather name, it's still advised to be explicit and use "name ~ value", but it's probably worth aliasing the "default" attribute to default_template. That way generic search term like "Kickstart default" would work correctly.
Created redmine issue https://projects.theforeman.org/issues/26083 from this bug
Moving this bug to POST for triage into Satellite 6 since the upstream issue https://projects.theforeman.org/issues/26083 has been resolved.
> hammer --no-headers --csv template list --search "default" | wc -l 62 > hammer --no-headers --csv template list --search "defaul" | wc -l 62 > hammer template list --search 'Kickstart default' | wc -l 18 > hammer template list --search 'Kickstart default' | wc -l 18 Verified with Satellite 6.5 with Snap4. It's working fine 'defaul' and 'default' keywords.
Sorry, It was Satellite 6.6 with Snap4
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHSA-2019:3172