Bug 1135919

Summary: Unable to filter on classes (v1.5.2)
Product: Red Hat Satellite Reporter: Stephen Benjamin <stbenjam>
Component: ProvisioningAssignee: Katello Bug Bin <katello-bugs>
Status: CLOSED ERRATA QA Contact: Tazim Kolhar <tkolhar>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.0.4CC: cwelton, dcleal, jmagen, stbenjam, tkolhar
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
URL: http://projects.theforeman.org/issues/7035
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-08-12 05:15:42 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1110360    
Attachments:
Description Flags
class names none

Description Stephen Benjamin 2014-09-01 07:44:44 UTC
Hi, 

With Foreman version 1.5.2 I'm not able filtering the hostlist based on classes. Regardless of which class i try to filter with, Foreman returns all hosts as a result.

Example of filter: class = java

This query should return a few hosts but it returns all hosts.

I did some search and found an old bug (http://projects.theforeman.org/issues/4314). But I believe the cause isn't the same.

After I enabled debug mode. Here's the error I get when applying the class filter:
@  Host::Managed Load (0.3ms)  SELECT `hosts`.* FROM `hosts` WHERE `hosts`.`type` IN ('Host::Managed') LIMIT 1
   (0.5ms)  SELECT id FROM `config_groups` INNER JOIN `config_group_classes` ON `config_group_classes`.`config_group_id` = `config_groups`.`id` INNER JOIN `puppetclasses` ON `puppetclasses`.`id` = `config_group_classes`.`puppetclass_id` WHERE (puppetclasses.name = BINARY 'java') ORDER BY config_groups.name

Mysql2::Error: Column 'id' in field list is ambiguous: SELECT id FROM `config_groups` INNER JOIN `config_group_classes` ON `config_group_classes`.`config_group_id` = `config_groups`.`id` INNER JOIN `puppetclasses` ON `puppetclasses`.`id` = `config_group_classes`.`puppetclass_id` WHERE (puppetclasses.name = BINARY 'java') ORDER BY config_groups.name
   (0.2ms)  SELECT COUNT(*) FROM `user_facts` WHERE `user_facts`.`user_id` = 2
  Host::Managed Load (1.0ms)  SELECT `hosts`.* FROM `hosts` WHERE `hosts`.`type` IN ('Host::Managed') ORDER BY `hosts`.`name` ASC LIMIT 25 OFFSET 0
  Hostgroup Load (0.5ms)  SELECT `hostgroups`.* FROM `hostgroups` WHERE `hostgroups`.`id` IN (30, 20, 19, 16, 17, 12, 13, 10, 9, 6, 5, 27, 25, 24) ORDER BY hostgroups.title
  Operatingsystem Load (0.3ms)  SELECT `operatingsystems`.* FROM `operatingsystems` WHERE `operatingsystems`.`id` IN (5, 6, 1, 4) ORDER BY operatingsystems.name
@

The error states an ambiguous field 'id'. I modified the query by adding the tablename, but altough I got an empty result ... don't know whether there's another root cause of this problem.

Let me know if more information is needed.

Regards
Reto

Comment 1 Stephen Benjamin 2014-09-01 07:44:47 UTC
Created from redmine issue http://projects.theforeman.org/issues/7035

Comment 3 jmagen@redhat.com 2014-09-01 11:17:41 UTC
Merged f06b276b93f9ff47ca66174c606fee6fc2c64321 in upstream develop branch for
http://projects.theforeman.org/issues/7035

It should work when patch is cherry-picked downstream

Comment 4 Bryan Kearney 2014-09-01 12:05:23 UTC
Moving to POST since upstream bug http://projects.theforeman.org/issues/7035 has been closed
-------------
Dominic Cleal
Applied in changeset commit:f06b276b93f9ff47ca66174c606fee6fc2c64321.

Comment 7 Tazim Kolhar 2015-04-21 10:04:53 UTC
Hi,

please provide verification steps

thanks

Comment 8 Stephen Benjamin 2015-04-21 11:02:05 UTC
Steps to verify:
1. Create a couple of hosts
2. Assign a puppet class to one of them
3. Search for "class = <classname>"
4. Ensure there's only one result

Comment 9 Tazim Kolhar 2015-04-22 07:27:31 UTC
VERIFIED :
# rpm -qa | grep foreman
foreman-libvirt-1.7.2.15-1.el6_6sat.noarch
ruby193-rubygem-foreman-tasks-0.6.12.3-1.el6_6sat.noarch
foreman-postgresql-1.7.2.15-1.el6_6sat.noarch
ruby193-rubygem-foreman_docker-1.2.0.7-1.el6_6sat.noarch
ruby193-rubygem-foreman_gutterball-0.0.1.9-1.el6_6sat.noarch
rubygem-hammer_cli_foreman_discovery-0.0.1.4-1.el6_6sat.noarch
foreman-debug-1.7.2.15-1.el6_6sat.noarch
foreman-compute-1.7.2.15-1.el6_6sat.noarch
foreman-gce-1.7.2.15-1.el6_6sat.noarch
ruby193-rubygem-foreman_bootdisk-4.0.2.10-1.el6_6sat.noarch
rubygem-hammer_cli_foreman_tasks-0.0.3.3-1.el6_6sat.noarch
foreman-proxy-1.7.2.4-1.el6_6sat.noarch
dhcp207-193.lab.eng.pnq.redhat.com-foreman-client-1.0-1.noarch
dhcp207-193.lab.eng.pnq.redhat.com-foreman-proxy-1.0-2.noarch
foreman-1.7.2.15-1.el6_6sat.noarch
foreman-vmware-1.7.2.15-1.el6_6sat.noarch
ruby193-rubygem-foreman-redhat_access-0.1.0-1.el6_6sat.noarch
rubygem-hammer_cli_foreman-0.1.4.7-1.el6_6sat.noarch
dhcp207-193.lab.eng.pnq.redhat.com-foreman-proxy-client-1.0-1.noarch
foreman-selinux-1.7.2.13-1.el6_6sat.noarch
ruby193-rubygem-foreman_hooks-0.3.7-2.el6_6sat.noarch
rubygem-hammer_cli_foreman_bootdisk-0.1.2.5-1.el6_6sat.noarch
ruby193-rubygem-foreman_openscap-0.3.2.5-1.el6_6sat.noarch
foreman-ovirt-1.7.2.15-1.el6_6sat.noarch
ruby193-rubygem-foreman_discovery-2.0.0.9-1.el6_6sat.noarch
puppet-foreman_scap_client-0.3.3-6.el6_6sat.noarch

Create hosts
assign puppet class to it
Search for "class = <classname>"
it shows the host with assigned class

screenshot attached

Comment 10 Tazim Kolhar 2015-04-22 07:29:01 UTC
Created attachment 1017295 [details]
class names

Comment 11 Bryan Kearney 2015-08-11 13:31:22 UTC
This bug is slated to be released with Satellite 6.1.

Comment 12 errata-xmlrpc 2015-08-12 05:15:42 UTC
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-2015:1592