Project

General

Profile

Bug #25897

Using search query for listing content hosts produces unexpected output

Added by Moti Asayag 9 months ago. Updated about 1 month ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
API
Target version:
-
Difficulty:
Triaged:
Yes
Bugzilla link:
Fixed in Releases:
Found in Releases:

Description

While trying to use the search query with 'or' option to list two content hosts with FQDN, the result is long duplicated list of host entries.

The search query is: facts.network::hostname = "host_1" or facts.network::hostname = "host_2"
The result of each part of the search is as follow:
facts.network::hostname = "host_1" - returns only one record
facts.network::hostname = "host_2" - returns no record (no matches)

The combined query produces a duplicated list of 20 records of host_1.

curl -k -u admin:123456 "https://katello.example.com/api/v2/hosts?search=facts.network::hostname=host_1.example.com%20or%20facts.network::hostname=host_2.example.com&format=json" {
"total": 3,
"subtotal": 20,
"page": 1,
"per_page": 20,
"search": "facts.network::hostname=host_1.example.com or facts.network::hostname=host_2.example.com",
"sort": {
"by": null,
"order": null
},
"results": [{...}]
}

Associated revisions

Revision f8da6705 (diff)
Added by Partha Aji 4 months ago

Fixes #25897 - Can lookup hosts based on facts

Prior to this commit
---------------------
>> Host.search_for(
"name= rhel7.partello.example.com or facts.greatest_fact_ever=lol").
count
>>161

Post this commit
---------------

same query

1

The scoped search for fact values did a join instead of a "subselect"
causing the host row to be repeated for each fact belonging to the host.
This commit fixes that by moving the entire thing to subselect.

History

#1 Updated by John Mitsch 9 months ago

  • Triaged changed from No to Yes
  • Target version set to Katello Backlog

we can look into this, it may be a issue in foreman rather than katello but we will double check before re-assigning

#2 Updated by Partha Aji 5 months ago

  • Target version deleted (Katello Backlog)
  • Assignee set to Partha Aji
  • Category changed from API to API
  • Project changed from Katello to Foreman

#3 Updated by The Foreman Bot 5 months ago

  • Status changed from New to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/6777 added

#4 Updated by Timo Goebel 4 months ago

  • Fixed in Releases 1.23.0 added

#5 Updated by Partha Aji 4 months ago

  • Status changed from Ready For Testing to Closed

#6 Updated by Bryan Kearney about 1 month ago

  • Bugzilla link set to 1511254

Also available in: Atom PDF