Bug 1857866
| Summary: | Search for hosts based on facts randomly doesn't work | ||
|---|---|---|---|
| Product: | Red Hat Satellite | Reporter: | Petr Kubica <pkubica> |
| Component: | Hosts | Assignee: | satellite6-bugs <satellite6-bugs> |
| Status: | CLOSED NOTABUG | QA Contact: | tstrych |
| Severity: | high | Docs Contact: | |
| Priority: | unspecified | ||
| Version: | 6.7.0 | CC: | apatel, gdeolive, inecas, kgaikwad, lzap, mhulan, mperina, mtessun, oezr, pelauter |
| Target Milestone: | Unspecified | Keywords: | Triaged |
| Target Release: | Unused | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
| Whiteboard: | |||
| Fixed In Version: | Doc Type: | If docs needed, set a value | |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | 2021-05-06 09:15:07 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: | |||
| Bug Depends On: | |||
| Bug Blocks: | 1663217 | ||
I reproduced this BZ with sat 6.7.3 and with 6.8.0 snap 14. Hello, this is probably misunderstanding of Facts API and what it provides.
Satellite does not give any guarantee about facts, it only stores all facts in the inventory database. What is important is what fact client (facter or rhsm) reports them, if it reports anything. Some hosts may or may not have those clients enabled, some not. E.g. RHEL host which was registered to content has always facts reported by rhsm, client that was configured to have puppet also reports facty by facter. But it is totally possible to have e.g. CentOS host without either puppet or rhsm (or ansible). In that case, that host has completely *empty* facts. Therefore all searches will fail to find the host.
And it turns out that's your case, look:
# foreman-rake console
irb> Host.unscoped.all.each {|h| puts "HOST: #{h.name} HOSTNAME: #{h.facts["network::hostname"]} FQDN: #{h.facts["network::fqdn"]}" }
HOST: capsule.sat0.rhev.lab.eng.brq.redhat.com HOSTNAME: capsule.sat0.rhev.lab.eng.brq.redhat.com FQDN: capsule.sat0.rhev.lab.eng.brq.redhat.com
HOST: engine.sat0.rhev.lab.eng.brq.redhat.com HOSTNAME: engine.sat0.rhev.lab.eng.brq.redhat.com FQDN: engine.sat0.rhev.lab.eng.brq.redhat.com
HOST: brq-satellite.rhev.lab.eng.brq.redhat.com HOSTNAME: FQDN:
HOST: host-01.sat0.rhev.lab.eng.brq.redhat.com HOSTNAME: host-01.sat0.rhev.lab.eng.brq.redhat.com FQDN: host-01.sat0.rhev.lab.eng.brq.redhat.com
HOST: a.sat0.rhev.lab.eng.brq.redhat.com HOSTNAME: FQDN:
HOST: vm.sat0.rhev.lab.eng.brq.redhat.com HOSTNAME: vmnewname.sat0.rhev.lab.eng.brq.redhat.com FQDN: vmnewname.sat0.rhev.lab.eng.brq.redhat.com
Two hosts named brq-satellite and a do not have any facts associated with them for the reason explained above.
irb> Host.unscoped.find_by_name("a.sat0.rhev.lab.eng.brq.redhat.com").facts
=> {}
We have discussed possibility to have some "fallback" fact client that would be installed for hosts which don't have any client available. But this is just in planning phase.
Solution: Install RHSM or Facter or Ansible on those machines, register or configure them to upload facts.
|
Description of problem: We need to search host based on its FQDN and in RHV product it is done via API and search based on facts But after trying Some hosts works properly and some hosts doesn't. I couldn't find a rule which would describe in which cases it is working and in which not. If necessary I can provide the environment where it happens. Working: - Host is listed between hosts - GET https://<SATELLITE_URL>/api/v2/hosts/<HOST_FQDN> works - host has filled FQDN on an interface (checked in portal). Not working: GET https://<SATELLITE_URL>/api/v2/hosts?search=facts.network::fqdn=<HOST_FQDN> GET https://<SATELLITE_URL>/api/v2/hosts?search=facts.network::hostname=<HOST_FQDN> Getting: { "total": 6, "subtotal": 0, "page": 1, "per_page": 20, "search": "facts.network::fqdn=<HOST_FQDN>", "sort": { "by": null, "order": null }, "results": [] } foreman-tail: ==> /var/log/httpd/foreman-ssl_access_ssl.log <== <IP> - - [16/Jul/2020:19:01:07 +0200] "GET /api/v2/hosts?search=facts.network::fqdn=<HOST_FQDN> HTTP/1.1" 200 204 "-" "curl/7.29.0" ==> /var/log/foreman/production.log <== 2020-07-16T19:01:07 [I|app|44e68c6e] Started GET "/api/v2/hosts?search=facts.network::fqdn=<HOST_FQDN>" for <IP> at 2020-07-16 19:01:07 +0200 2020-07-16T19:01:07 [I|app|44e68c6e] Processing by Api::V2::HostsController#index as JSON 2020-07-16T19:01:07 [I|app|44e68c6e] Parameters: {"search"=>"facts.network::fqdn=<HOST_FQDN>", "apiv"=>"v2"} 2020-07-16T19:01:07 [I|app|44e68c6e] Authorized user admin(Admin User) 2020-07-16T19:01:08 [I|app|44e68c6e] Rendering api/v2/hosts/index.json.rabl within api/v2/layouts/index_layout 2020-07-16T19:01:08 [I|app|44e68c6e] Rendered api/v2/hosts/index.json.rabl within api/v2/layouts/index_layout (1.0ms) 2020-07-16T19:01:08 [I|app|44e68c6e] Completed 200 OK in 152ms (Views: 5.2ms | ActiveRecord: 17.5ms) Version-Release number of selected component (if applicable): Satellite 6.7.1 How reproducible: With almost half cases, but randomly Steps to Reproduce: 1. Have configured satellite environment, create a host within satellite (it could be a dummy host) a.sub1.sub2.sub3.sub4.example.com and also fill an interface 2. Search in search bar for this host: facts.network::fqdn=a.sub1.sub2.sub3.sub4.example.com or GET https://<SATELLITE_URL>/api/v2/hosts?search=facts.network::fqdn=<HOST_FQDN> Actual results: In some cases it will successfully find the host in some doesn't