Bug #19707

Searching for specific organizations/locations broken

Added by Christoph Manns 6 months ago. Updated 2 months ago.

Status:Closed
Priority:Normal
Assigned To:Ondřej Pražák
Category:Organizations and Locations
Target version:Team Marek Iteration 20
Difficulty: Bugzilla link:1472863
Found in release:1.15.0 Pull request:https://github.com/theforeman/foreman/pull/4815, https://github.com/theforeman/foreman/pull/4821
Story points-
Velocity based estimate-
Release1.15.4Release relationshipAuto

Description

If I try to search through subnets with location_id every subnet is returned as long as the location_id actually exists. If I search for a nonexsitent location_id no subnet gets returned.
Also searching for organizations seems to be broken too, because when I enter a location name as organization I get a list of all subnets.

Examples:

Subnet1:
name: net1-mgmt
location_id: 8

Subnet2:
name: net2-mgmt
location_id: 9

search_string: location_id = 9 and name ~ net%-mgmt

Result: Both Subnets
Expected Result: Subnet2

search_string: location_id = 90 and name ~ net%-mgmt

Result: Nothing
Expected Result: Nothing (this is actually correct)

search_string: organization_id = 9 and name ~ net%-mgmt

Result: Both Subnets
Expected Result: Nothing as organization_id 9 does not exist

proxies.png (17.5 KB) Preview Michael Moll, 05/30/2017 12:40 PM

Proxies

Related issues

Related to Foreman - Bug #20867: Scoped search 4.1.1 introduces a regression and breaks tests Closed 09/07/2017
Related to Foreman - Bug #20872: Update scoped_search to 4.1.2 or higher Closed 09/07/2017

Associated revisions

Revision 114973b3
Added by Michael Moll 2 months ago

Refs #19707 - test searching domains with locs

Revision 3c260702
Added by Michael Moll 2 months ago

Refs #19707 - test searching domains with locs

(cherry picked from commit 114973b3525a60ca2649977ffde389229d5a0157)

Revision 09a879ab
Added by Michael Moll 2 months ago

Refs #19707 - test searching domains with locs

(cherry picked from commit 114973b3525a60ca2649977ffde389229d5a0157)

History

#1 Updated by Michael Moll 6 months ago

Somebody on IRC had the same problem with an API call for getting a list of proxies per location. This worked in 1.14: '/api/smart_proxies?search=feature=TFTP+and+location=xxx'

#2 Updated by Michael Moll 6 months ago

  • Subject changed from Searching subnets for specific location_id to Searching for specific organizations/locations broken
  • Category changed from Search to Organizations and Locations

#3 Updated by Daniel Lobato Garcia 6 months ago

I'm currently not able to reproduce this neither the comment by mmoll, I'll try later with exactly the same setup as described in the issue.

#4 Updated by Michael Moll 6 months ago

See the attached picture for my proxies. geode.kvedulv.de is only in the location "Home", but still is showing up in the search results via API:

mmoll@sledge:/tmp$ http --verify=no --auth mmoll:xxx 'https://sledge.kvedulv.de/api/smart_proxies?search=location=GCSC2'
[...]
{
    "page": 1, 
    "per_page": 20, 
    "results": [
        {
            "created_at": "2017-02-25 21:35:42 UTC", 
            "features": [
                {
                    "id": 4, 
                    "name": "DHCP" 
                }, 
                {
                    "id": 16, 
                    "name": "Logs" 
                }
            ], 
            "id": 3, 
            "name": "geode.kvedulv.de", 
            "updated_at": "2017-02-25 21:35:42 UTC", 
            "url": "https://geode.kvedulv.de:8443" 
        }, 
        {
            "created_at": "2015-04-10 11:19:19 UTC", 
            "features": [
                {
                    "id": 6, 
                    "name": "Puppet CA" 
                }, 
                {
                    "id": 5, 
                    "name": "Puppet" 
                }, 
                {
                    "id": 14, 
                    "name": "Dynflow" 
                }, 
                {
                    "id": 15, 
                    "name": "SSH" 
                }, 
                {
                    "id": 16, 
                    "name": "Logs" 
                }, 
                {
                    "id": 2, 
                    "name": "TFTP" 
                }
            ], 
            "id": 1, 
            "name": "sledge.kvedulv.de", 
            "updated_at": "2016-09-14 18:25:54 UTC", 
            "url": "https://sledge.kvedulv.de:8443" 
        }
    ], 
    "search": "location=GCSC2", 
    "sort": {
        "by": null, 
        "order": null
    }, 
    "subtotal": 2, 
    "total": 2
}

#5 Updated by Marek Hulán 6 months ago

I can reproduce as well. It's not specific to API. I put some reproducing and debugging info here - https://gist.github.com/ares/6c5dc51581e20805b7798212960bc108

#6 Updated by Christian Schulze-Wiehenbrauk 6 months ago

Marek Hulán wrote:

I can reproduce as well. It's not specific to API. I put some reproducing and debugging info here - https://gist.github.com/ares/6c5dc51581e20805b7798212960bc108

I had a look at the sql statement and it seems that a filter is missing for the sub select: taxable_taxonomies.type = $1 resp. taxonomies.type = $2. This leads to a erroneous result set, containing ids that have the wrong taxable_taxonomies.type.

#7 Updated by Christian Schulze-Wiehenbrauk 6 months ago

EDIT: further explanation here: https://gist.github.com/Ntr0/922a52b11476cde4ed256069c06684a1

To reproduce this bug in unit tests different taxable_taxonomy types must have the same ID and the same taxonomy_id.

#8 Updated by Christian Schulze-Wiehenbrauk 6 months ago

Not sure how to contribute this besides a gist,
so here is the unit test:
https://gist.github.com/Ntr0/94c2bd1350253db0620933d297473b86

#9 Updated by Jitendra Yejare 4 months ago

  • Bugzilla link set to 1472863

#10 Updated by Tomáš Strachota 4 months ago

There's a similar issue with filtering hosts by hostgroups: http://projects.theforeman.org/issues/20204 Could be a dupe.

#11 Updated by Tomáš Strachota 4 months ago

Disregard my previous comment, it's a different bug.

#12 Updated by Marek Hulán 4 months ago

  • Target version set to Team Marek Iteration 18

#13 Updated by Marek Hulán 4 months ago

  • Target version changed from Team Marek Iteration 18 to Team Marek Iteration 19

#14 Updated by Ondřej Pražák 3 months ago

  • Assigned To set to Ondřej Pražák

#15 Updated by Marek Hulán 3 months ago

  • Target version changed from Team Marek Iteration 19 to Team Marek Iteration 20

#16 Updated by Marek Hulán 3 months ago

Fixed in scoped_search 4.1.1 but that introduced another regression so we ended up using 4.1.2.

#17 Updated by Marek Hulán 3 months ago

  • Related to Bug #20867: Scoped search 4.1.1 introduces a regression and breaks tests added

#18 Updated by Marek Hulán 3 months ago

  • Related to Bug #20872: Update scoped_search to 4.1.2 or higher added

#19 Updated by Marek Hulán 3 months ago

  • Status changed from New to Closed
  • Release set to 1.17.0

This has been addressed by #20872

#20 Updated by Marek Hulán 3 months ago

  • Pull request https://github.com/theforeman/foreman/pull/4815 added

#21 Updated by The Foreman Bot 3 months ago

  • Pull request https://github.com/theforeman/foreman/pull/4821 added

#22 Updated by Marek Hulán 2 months ago

  • Release changed from 1.17.0 to 1.15.4

Also available in: Atom PDF