Bug 1908015

Summary: Discovered host is assigned a taxonomy at random and Satellite fails to honor the correct taxonomy when loading and matching discovery rules
Product: Red Hat Satellite Reporter: Pablo Hess <phess>
Component: Discovery PluginAssignee: Lukas Zapletal <lzap>
Status: CLOSED ERRATA QA Contact: Roman Plevka <rplevka>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.8.0CC: lzap, ogajduse, pcreech, rabajaj, zhunting
Target Milestone: 6.9.0Keywords: Regression, Triaged
Target Release: Unused   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Discovery Plugin 16.0 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1908856 (view as bug list) Environment:
Last Closed: 2021-04-21 13:24:23 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 Pablo Hess 2020-12-15 17:05:31 UTC
Description of problem:
When using discovery rules, discovered hosts may be assigned a random taxonomy by Satellite. Satellite may say it assigned a different taxonomy right next (one that makes sense given e.g. the discovered host's subnet) but the newly assigned taxonomy will be disregarded when loading discovery rules.

As a result, discovery rules are loaded and matched as if the host still belonged to the randomly assigned taxonomy, not the actual taxonomy.

This can be worked around by setting the discovery_location and discovery_organization settings on Satellite to the correct ones the discovered host belongs to. However, if one wants to discover hosts in two or more different taxonomies and wants discovery rules to correctly load and match, this workaround does not fix the issue.


This has been resolved at least in part upstream: https://projects.theforeman.org/issues/30948


Version-Release number of selected component (if applicable):
foreman-2.1.2.21-1.el7sat.noarch
tfm-rubygem-foreman_discovery-16.1.2-1.el7sat.noarch
tfm-rubygem-smart_proxy_discovery-1.0.5-5.el7sat.noarch

How reproducible:
Every single time if a host's actual taxonomy does not match Satellite's default discovery taxonomy.

Steps to Reproduce:
1. Set Satellite's default discovery location to L2 or leave it undefined.
2. Have discovery rules in place for L1 that differ from the ones in L2.
3. Have a subnet S1 belonging to location L1 only.
4. Discover a host in S1 and L1.

Actual results:
Satellite loads discovery rules for L2 and none of them match; discovery rules do not work. But Satellite correctly re-assigns the host's location to L1. If one re-sends the discovery facts from the host, Satellite then loads discovery rules for L1 location and one of them finally matches the host, so the host reboots automatically to a functioning provisioning workflow.

Expected results:
Satellite figures out the host's taxonomy based on at least its subnet and correctly loads discovery rules accordingly, so one of those rules matches and automated discovery ensues.


Additional info:
Per lzap, this patch may need to be backported: https://github.com/theforeman/foreman_discovery/pull/509/files

Comment 2 Lukas Zapletal 2020-12-16 08:30:55 UTC
Please apply the following patch:

https://github.com/theforeman/foreman_discovery/pull/509/files

Find the app/controllers/api/v2/discovered_hosts_controller.rb file it resides somewhere reed in /opt/tfm SCL prefix I don't remember. Then restart all services.

I tried this on my system and I must have my taxonomy set up differently, it always works in my case. Confirming this works would be a huge help, thanks.

Comment 4 Bryan Kearney 2020-12-16 19:29:42 UTC
Moving this bug to POST for triage into Satellite since the upstream issue https://projects.theforeman.org/issues/30948 has been resolved.

Comment 12 errata-xmlrpc 2021-04-21 13:24:23 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 (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