Bug 1584785 - Filtering of some entities does not work
Summary: Filtering of some entities does not work
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Hammer - Content
Version: 6.4
Hardware: Unspecified
OS: Unspecified
unspecified
high vote
Target Milestone: 6.4.0
Assignee: Christine Fouant
QA Contact: Lukáš Hellebrandt
URL:
Whiteboard:
: 1610695 1614360 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-05-31 16:22 UTC by Lukáš Hellebrandt
Modified: 2019-12-19 18:54 UTC (History)
16 users (show)

Fixed In Version: tfm-rubygem-hammer_cli_katello-0.13.4.3-1
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-10-16 18:54:12 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 23993 0 Normal Closed Filtering of some entities does not work 2020-05-10 09:47:05 UTC
Foreman Issue Tracker 25027 0 Normal Closed Filtering of some entities does not work 2020-05-10 09:47:05 UTC

Description Lukáš Hellebrandt 2018-05-31 16:22:42 UTC
Description of problem:
Some entities can only be specified using --<entity>-id because when specified by name by --<entity>, search doesn't query for the name entered and returns multiple results. I discovered this for images and compute resources.

By using 'hammer -d', I discovered the correct request and response (for the entity which works) are:


[DEBUG 2018-05-31T12:08:08 API] Headers: {
    :params => {
        :search => "name = \"Kickstart default\""
    }
}
[DEBUG 2018-05-31T12:08:08 API] Response: {
       "total" => 14,
    "subtotal" => 1,
        "page" => 1,
    "per_page" => 20,
      "search" => "name = \"Kickstart default\"",
        "sort" => {
           "by" => nil,
        "order" => nil
    },
...

Notice the request is in form ':search => "name = \"Kickstart default\""' and response shows non-nil 'search' param.
And the incorrect ones are:

[DEBUG 2018-05-31T12:08:08 API] Headers: {
    :params => {
        "compute_resource_id" => 1,
         "operatingsystem_id" => 1,
                       "name" => "fish"
    }
}
[DEBUG 2018-05-31T12:08:09 API] Response: {
       "total" => 2,
    "subtotal" => 2,
        "page" => 1,
    "per_page" => 20,
      "search" => nil,
        "sort" => {
           "by" => nil,
        "order" => nil
    },
...
Notice the request is wrongly in form '"name" => "fish"' and 'search' in response is nil.

Version-Release number of selected component (if applicable):
Tested on Sat 6.4 snap 5

How reproducible:
Deterministic

Steps to Reproduce:
# hammer host create --compute-resource-id 1 ...

Actual results:
Could not create the host:
  Error: Found more than one image.

Expected results:
Same as specifying the entity (compute resource in this case) by id

Additional info:

Comment 2 Lukáš Hellebrandt 2018-06-14 13:41:26 UTC
Surprisingly, yes, this is a regression. On 6.3:

# hammer -d host create --compute-resource-id 1 --architecture x86_64 --domain example.com --operatingsystem-id 1 --partition-table-id 1 --location-id 2 --organization-id 1 --name fish --root-password toortoor --image image1

Params: {
    "operatingsystem_id" => 1,
                 :search => "name = \"image1\""
}
[DEBUG 2018-06-14 09:37:14 API] Headers: {
    :params => {
        "operatingsystem_id" => 1,
                     :search => "name = \"image1\""
    }
}


Response: {
       "total" => 2,
    "subtotal" => 1,
        "page" => 1,
    "per_page" => 20,
      "search" => "name = \"image1\"",
        "sort" => {
           "by" => nil,
        "order" => nil
    },
     "results" => [
        [0] {
               "operatingsystem_id" => 1,
             "operatingsystem_name" => "RHEL Server 7.5",
              "compute_resource_id" => 1,
            "compute_resource_name" => "rhev3",
                  "architecture_id" => 1,
                "architecture_name" => "x86_64",
                             "uuid" => "7c5cc85e-a5be-4c7b-84a1-9dafbd556a14",
                         "username" => "root",
                       "created_at" => "2018-06-14 13:36:02 UTC",
                       "updated_at" => "2018-06-14 13:36:02 UTC",
                        "user_data" => false,
                               "id" => 1,
                             "name" => "image1"
        }
    ]
}

Comment 5 Ivan Necas 2018-06-19 07:29:57 UTC
Created redmine issue http://projects.theforeman.org/issues/23993 from this bug

Comment 6 Tomas Strachota 2018-06-19 07:40:48 UTC
Hi Lukas,
it's not mentioned in the original bug description, but from your subsequent comment I guess it's the host create command that doesn't work. Have you observed the issue in some other commands too? If yes, could you name them please?

It would be helpful if you could attach full -d log of the commands that are affected by this.

Comment 7 Ivan Necas 2018-06-25 12:56:44 UTC
I was too harsh with devel triage,

I was able to reproduced with foreman+katello, when I disabled the katello hammer plugin, it started working again, so it seems something from hammer-cli-katello is causing the troubles:

The corresponding debug output is this:

```
ESC[32m INFOESC[0m ESC[34m2018-06-25T12:42:14ESC[0m ESC[36mAPIESC[0m] GET /api/compute_resources
[DEBUG ESC[34m2018-06-25T12:42:14ESC[0m ESC[36mAPIESC[0m] Params: {
    "name" => "blacr"
}
[DEBUG ESC[34m2018-06-25T12:42:14ESC[0m ESC[36mAPIESC[0m] Headers: {
    :params => {
        "name" => "blacr"
    }
}
[DEBUG ESC[34m2018-06-25T12:42:14ESC[0m ESC[36mAPIESC[0m] Using authenticator: HammerCLIForeman::Api::InteractiveBasicAuth
[DEBUG ESC[34m2018-06-25T12:42:14ESC[0m ESC[36mAPIESC[0m] Response: {
       "total" => 2,
    "subtotal" => 2,
        "page" => 1,
    "per_page" => 20,
      "search" => nil,
        "sort" => {
           "by" => nil,
        "order" => nil
    },
```

Comment 8 Ivan Necas 2018-06-25 16:02:08 UTC
I've tracked the issue down to this file https://github.com/katello/hammer-cli-katello/blob/5d263458e426b20b671ed6475d7379dd6174b941/lib/hammer_cli_katello/foreman_search_options_creators.rb - it seems that every searchable not explicitly mentioned there, will not get properly resolved, at least in the host commands.

Easy fix would probably be adding the additional searchables there, but better approach would be to make the Katello's searchables opt-in, not opt-out, as they are right now.

Comment 9 Ivan Necas 2018-08-07 15:25:33 UTC
*** Bug 1610695 has been marked as a duplicate of this bug. ***

Comment 10 Lukas Pramuk 2018-08-10 09:17:12 UTC
*** Bug 1614360 has been marked as a duplicate of this bug. ***

Comment 11 Lukas Pramuk 2018-08-10 09:19:12 UTC
In my duplicate there is some useful info:
https://bugzilla.redhat.com/show_bug.cgi?id=1614360#c2

Comment 12 Satellite Program 2018-08-13 14:07:31 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue https://projects.theforeman.org/issues/23993 has been resolved.

Comment 13 Lukáš Hellebrandt 2018-09-13 12:07:46 UTC
FailedQA with Sat 6.4 snap 21.

Used reproducer from comment 2 on a Satellite with |images|>1, reproduced the bug.

Comment 14 Brad Buckingham 2018-09-24 20:43:39 UTC
Associating an upstream redmine (25027) that contains a fix for the failure.  The change has been merged upstream; therefore, moving bug to POST.

Comment 15 Patrick Creech 2018-09-25 13:35:21 UTC
This PR's unit tests failed.  Brad, can someone take a look?

	satellite6/hammer_cli_katello/merge_requests/52

Comment 16 Patrick Creech 2018-09-25 13:44:22 UTC
switching needinfo to Christine

Comment 17 Patrick Creech 2018-09-25 14:55:04 UTC
This ended up being an issue with our tests pulling in the wrong version of a dependency.  Cherrypick successfull

Comment 18 Lukáš Hellebrandt 2018-10-02 09:54:09 UTC
I tried the hammer host create command to create a host on RHEV and I specified every parameter by name rather than ID. I don't know of any other entity that can't be searched by name => verified with Sat 6.4 snap 24.

Comment 19 Bryan Kearney 2018-10-16 18:54:12 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, 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-2018:2927


Note You need to log in before you can comment on or make changes to this bug.