Bug 1699188
Summary: | Adding search for Operating system in role's host filter with permission view_hosts does not construct SQL query when API is used | ||
---|---|---|---|
Product: | Red Hat Satellite | Reporter: | roarora |
Component: | Users & Roles | Assignee: | Ondřej Ezr <oezr> |
Status: | CLOSED ERRATA | QA Contact: | Radovan Drazny <rdrazny> |
Severity: | medium | Docs Contact: | |
Priority: | high | ||
Version: | 6.4 | CC: | dhlavacd, kkohli, mhulan, oezr, philip.isaac, rankumar |
Target Milestone: | 6.9.0 | Keywords: | Triaged |
Target Release: | Unused | ||
Hardware: | All | ||
OS: | All | ||
Whiteboard: | |||
Fixed In Version: | Doc Type: | If docs needed, set a value | |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 2021-04-21 13:11:45 UTC | Type: | Bug |
Regression: | --- | Mount Type: | --- |
Documentation: | --- | CRM: | |
Verified Versions: | Category: | --- | |
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
Cloudforms Team: | --- | Target Upstream Version: | |
Embargoed: |
Description
roarora
2019-04-12 03:57:32 UTC
Hello, I am seeing the same issue in Red Hat Satellite 6.6. I have created the filter "host collection = HC1" in "Host" filter and "name = HG1" in "Host Group" filter. But synchronizing the inventory from Ansible Tower 3.5.3. - ansible-tower-3.5.3-1.el7at.x86_64 - satellite-6.6.0-5.beta.el7sat.noarch ==== Satellite production log ====== <output truncated> ActiveRecord::ConfigurationError: Can't join 'Host::Base' to association named 'host_collections'; perhaps you misspelled it? /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/associations/join_dependency.rb:188:in `find_reflection' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/associations/join_dependency.rb:193:in `block in build' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/associations/join_dependency.rb:192:in `each' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/associations/join_dependency.rb:192:in `map' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/associations/join_dependency.rb:192:in `build' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/associations/join_dependency.rb:201:in `block in build' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/associations/join_dependency.rb:192:in `each' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/associations/join_dependency.rb:192:in `map' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/associations/join_dependency.rb:192:in `build' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/associations/join_dependency.rb:72:in `initialize' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/relation/query_methods.rb:1023:in `new' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/relation/query_methods.rb:1023:in `build_join_query' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/relation/query_methods.rb:1009:in `build_joins' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/relation/query_methods.rb:929:in `build_arel' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/relation/query_methods.rb:903:in `arel' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/relation.rb:549:in `block (2 levels) in exec_queries' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/relation/finder_methods.rb:394:in `apply_join_dependency' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/relation.rb:544:in `block in exec_queries' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/relation.rb:578:in `skip_query_cache_if_necessary' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/relation.rb:541:in `exec_queries' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/relation.rb:414:in `load' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/relation.rb:200:in `records' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/relation/delegation.rb:41:in `each' <output truncated> ==================================== ==== Ansible tower task log ======= stderr: ansible-inventory 2.8.3 config file = /etc/ansible/ansible.cfg configured module search path = [u'/var/lib/awx/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules'] ansible python module location = /usr/lib/python2.7/site-packages/ansible executable location = /usr/bin/ansible-inventory python version = 2.7.5 (default, Jun 11 2019, 12:19:05) [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] Using /etc/ansible/ansible.cfg as config file [WARNING]: * Failed to parse /var/lib/awx/venv/awx/lib64/python3.6/site- packages/awx/plugins/inventory/foreman.py with script plugin: Inventory script (/var/lib/awx/venv/awx/lib64/python3.6/site- packages/awx/plugins/inventory/foreman.py) had an execution error: /var/lib/awx/venv/ansible/lib/python2.7/site- packages/urllib3/connectionpool.py:847: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl- warnings InsecureRequestWarning) /var/lib/awx/venv/ansible/lib/python2.7 /site-packages/urllib3/connectionpool.py:847: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced- usage.html#ssl-warnings InsecureRequestWarning) /var/lib/awx/venv/ansible/lib/python2.7/site- packages/urllib3/connectionpool.py:847: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl- warnings InsecureRequestWarning) Traceback (most recent call last): File "/var/lib/awx/venv/awx/lib64/python3.6/site- packages/awx/plugins/inventory/foreman.py", line 462, in <module> sys.exit(not ForemanInventory().run()) File "/var/lib/awx/venv/awx/lib64/python3.6/site- packages/awx/plugins/inventory/foreman.py", line 456, in run self.get_inventory() File "/var/lib/awx/venv/awx/lib64/python3.6/site- packages/awx/plugins/inventory/foreman.py", line 404, in get_inventory self.update_cache() File "/var/lib/awx/venv/awx/lib64/python3.6/site- packages/awx/plugins/inventory/foreman.py", line 352, in update_cache self.facts[dns_name] = self._get_facts(host) File "/var/lib/awx/venv/awx/lib64/python3.6/site- packages/awx/plugins/inventory/foreman.py", line 244, in _get_facts ret = self._get_facts_by_id(host['id']) File "/var/lib/awx/venv/awx/lib64/python3.6 /site-packages/awx/plugins/inventory/foreman.py", line 221, in _get_facts_by_id return self._get_json(url) File "/var/lib/awx/venv/awx/lib64/python3.6/site- packages/awx/plugins/inventory/foreman.py", line 186, in _get_json ret.raise_for_status() File "/var/lib/awx/venv/ansible/lib/python2.7/site- packages/requests/models.py", line 940, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 500 Server Error: Internal Server Error for url: https://sat66.example.com/api/v2/hosts/16/facts?per_page=250&page=1 File "/usr/lib/python2.7/site-packages/ansible/inventory/manager.py", line 268, in parse_source plugin.parse(self._inventory, self._loader, source, cache=cache) File "/usr/lib/python2.7/site-packages/ansible/plugins/inventory/script.py", line 161, in parse raise AnsibleParserError(to_native(e)) [WARNING]: Unable to parse /var/lib/awx/venv/awx/lib64/python3.6/site- packages/awx/plugins/inventory/foreman.py as an inventory source ERROR! No inventory was parsed, please check your configuration and options. ======================================= Rajan, your report seems to be dup of BZ 1699607 This seems as BZ 1569395, which has been fixed in 6.5, could you please check the upgrade resolves your issue? Created redmine issue https://projects.theforeman.org/issues/29011 from this bug Upstream bug assigned to oezr Moving this bug to POST for triage into Satellite since the upstream issue https://projects.theforeman.org/issues/30555 has been resolved. Fix is in Satellite 6.9 SNAP 1 with foreman-2.3.0-0.7.rc1.el7sat.noarch Verified on Sat 6.9 Snap 17 using the original reproducer. Running the API call with an user with role and filter assigned: curl -k -u toweruser:toweruser https://dhcp-3-24.vms.sat.rdu2.redhat.com/api/v2/hosts/3/facts { "total": 0, "subtotal": 1, "page": 1, "per_page": 20, "search": " host = 3", "sort": { "by": null, "order": null }, "results": {"dhcp-2-102.vms.sat.rdu2.redhat.com":{"net::interface::eth0::ipv6_netmask":null,"proc_cpuinfo":null,"net::interface::eth0::ipv6_address":null,"net::interface":null,"dmi::meta":null,"network":null,"lscpu":null,"net::interface::eth0":null,"memory":null,"dmi::memory":null,"dmi":null,"dmi::baseboard":null,"distribution":null,"net":null,"cpu":null,"dmi::chassis":null,"dmi::bios":null,"dmi::processor":null,"dmi::system":null,"proc_cpuinfo::common":null}} } Facts are retrieved correctly. 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 (Moderate: Satellite 6.9 Release), 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-2021:1313 |