Bug 1303570

Summary: All package/package-groups commands along with host-name raises failed with error: found more than one host
Product: Red Hat Satellite Reporter: Sachin Ghai <sghai>
Component: HostsAssignee: satellite6-bugs <satellite6-bugs>
Status: CLOSED ERRATA QA Contact: Sachin Ghai <sghai>
Severity: high Docs Contact:
Priority: unspecified    
Version: NightlyCC: bbuckingham, jyejare, mmccune
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
URL: http://projects.theforeman.org/issues/13495
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-07-27 11:16:10 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: 1136091    
Attachments:
Description Flags
debug logs while installing a package none

Description Sachin Ghai 2016-02-01 10:43:39 UTC
Description of problem:
I was trying to perform package/package-group install/remove/upgrade operations via hammer. All these operations works fine if  pass the host-id. However If I use --host option with host-name, hammer raises error as below:

[root@cloud-q~]# hammer -u admin -p changeme host package install --host cloud-qe-3.lab.redhat.com --packages zsh

Could not install packages:
  Error: found more than one host


 ~]# hammer -u admin -p changeme host package-group install --host cloud-qe-3.lab.redhat.com --groups 'Development Tools'
Could not install package-groups:
  Error: found more than one host


Version-Release number of selected component (if applicable):
katello-2.5.0-3.nightly.el7.noarch
foreman-release-1.11.0-0.develop.201601211808gitd546fd0.el7.noarch
tfm-rubygem-hammer_cli_katello-0.0.20-1.el7.noarch
tfm-rubygem-hammer_cli-0.5.1-2.el7.noarch

How reproducible:
always

Steps to Reproduce:
1. Any package/package-group sub-command with --host instead of --host-id
2.
3.

Actual results:
Could not install package-groups:
  Error: found more than one host

Expected results:


Additional info:

[ERROR 2016-02-01 05:22:56 Exception] Error: found more than one host
Could not install packages:
  Error: found more than one host
[ERROR 2016-02-01 05:22:56 Exception] 

HammerCLIForeman::ResolverError (found more than one host):
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.5.1/lib/hammer_cli_foreman/id_resolver.rb:201:in `pick_result'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.5.1/lib/hammer_cli_foreman/id_resolver.rb:160:in `find_resource'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.5.1/lib/hammer_cli_foreman/id_resolver.rb:143:in `get_id'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.5.1/lib/hammer_cli_foreman/id_resolver.rb:133:in `block (2 levels) in define_id_finders'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.5.1/lib/hammer_cli_foreman/commands.rb:153:in `get_resource_id'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.5.1/lib/hammer_cli_foreman/commands.rb:222:in `block in customized_options'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.5.1/lib/hammer_cli_foreman/commands.rb:219:in `each'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.5.1/lib/hammer_cli_foreman/commands.rb:219:in `customized_options'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.5.1/lib/hammer_cli_foreman/commands.rb:243:in `request_params'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.5.1/lib/hammer_cli/apipie/command.rb:43:in `send_request'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.5.1/lib/hammer_cli_foreman/commands.rb:189:in `send_request'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman_tasks-0.0.8/lib/hammer_cli_foreman_tasks/async_command.rb:14:in `execute'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.0.0/lib/clamp/command.rb:68:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.5.1/lib/hammer_cli/abstract.rb:22:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.0.0/lib/clamp/subcommand/execution.rb:11:in `execute'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.0.0/lib/clamp/command.rb:68:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.5.1/lib/hammer_cli/abstract.rb:22:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.0.0/lib/clamp/subcommand/execution.rb:11:in `execute'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.0.0/lib/clamp/command.rb:68:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.5.1/lib/hammer_cli/abstract.rb:22:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.0.0/lib/clamp/subcommand/execution.rb:11:in `execute'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.0.0/lib/clamp/command.rb:68:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.5.1/lib/hammer_cli/abstract.rb:22:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.0.0/lib/clamp/command.rb:133:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.5.1/bin/hammer:125:in `<top (required)>'
    /usr/bin/hammer:23:in `load'
    /usr/bin/hammer:23:in `<main>'

Comment 1 Sachin Ghai 2016-02-01 10:46:08 UTC
Created attachment 1120062 [details]
debug logs while installing a package

Comment 2 Sachin Ghai 2016-02-01 10:47:48 UTC
Looks like 3 hosts with same domain name are fetched via api instead of one specified:

==
[ INFO 2016-02-01 05:43:52 HammerCLIKatello::HostPackage::InstallCommand] Called with options: {"option_host_name"=>"cloud-qe-3.idmqe.lab.eng.bos.redhat.com", "option_packages"=>["zsh"]}
[ INFO 2016-02-01 05:43:52 API] GET /api/hosts
[DEBUG 2016-02-01 05:43:52 API] Params: {
    "name" => "cloud-qe-3.idmqe.lab.eng.bos.redhat.com"
}
[DEBUG 2016-02-01 05:43:52 API] Headers: {
    :params => {
        "name" => "cloud-qe-3.idmqe.lab.eng.bos.redhat.com"
    }
}
[DEBUG 2016-02-01 05:43:52 API] Response: {
       "total" => 3,
    "subtotal" => 3,
        "page" => 1,
    "per_page" => 20,
      "search" => nil,
        "sort" => {
           "by" => nil,
        "order" => nil
    },

Comment 3 Sachin Ghai 2016-02-01 10:50:23 UTC
Created redmine issue http://projects.theforeman.org/issues/13495 from this bug

Comment 5 Bryan Kearney 2016-02-14 17:09:55 UTC
Upstream bug component is Hosts

Comment 6 Jitendra Yejare 2016-04-04 10:07:21 UTC
In Sat 6.2 beta snap 6.1, I see the issue is reproducible with errata installation as well.

Output:
[root@qeblade36 ~]# hammer host errata apply --errata-ids <errata_id> --host <hostname>
Could not apply errata:
  Error: found more than one host

So making it as a blocker for beta.

This bug is blocking 1126091 from verifying.

Comment 7 Mike McCune 2016-04-20 13:30:50 UTC
WORKAROUND:

For any use of "hammer host package/errata/package-group" commands please use the --host-id parameter instead of the --host name parameter.

This bug will be resolved in the GA release of Satellite 6.2.0

Comment 8 Brad Buckingham 2016-05-02 15:20:19 UTC
I attempted to reproduce this one with Satellite 6.2 Beta Snap 9.x; however, it appears 
to be working correctly on my configuration.  Note: my configuration only has 2 hosts; however,
I still anticipated receiving the error.  

Moving the bz to ON_QA for verification.


hammer> host package install --host rhel7-client1.example.com --packages bear
[.............................................................................] [100%]
bear-4.1-1.noarch

hammer> host package-group install --host rhel7-client1.example.com --groups mammals
[.............................................................................] [100%]
No new packages installed

hammer> host errata apply --host rhel7-client1.example.com --errata-ids RHEA-2012:0002
[.............................................................................] [100%]
walrus-5.21-1.noarch

Comment 9 Sachin Ghai 2016-05-13 11:36:50 UTC
Verified with sat6.2 GA snap10

I can install package/package-groups on selected host by passing --host option.

~]# hammer -u admin -p changeme host package install --host shost.idmqe.lab.eng.bos.redhat.com --packages zsh
[......................................................................................................] [100%]
zsh-5.0.2-14.el7.x86_64



[root@cloud-qe-3 ~]# hammer -u admin -p changeme host package-group install --host shost.idmqe.lab.eng.bos.redhat.com --groups 'Development Tools'
[......................................................................................................] [100%]
1:doxygen-1.8.5-3.el7.x86_64
cscope-15.8-7.el7.x86_64
patch-2.7.1-8.el7.x86_64
systemtap-2.8-10.el7.x86_64

Comment 10 Sachin Ghai 2016-05-13 12:01:04 UTC
Hammer host errataapply works too.

[root@cloud-qe-3 ~]# hammer -u admin -p changeme host errata list --host shost.idmqe.lab.eng.bos.redhat.com
-------------------------------------|----------------|----------|-------------|------------
ID                                   | ERRATUM ID     | TYPE     | TITLE       | INSTALLABLE
-------------------------------------|----------------|----------|-------------|------------
1bcca16f-9cac-4577-81d9-b919483c6934 | RHEA-2012:0002 | security | Sea_Erratum |            
-------------------------------------|----------------|----------|-------------|------------

[root@cloud-qe-3 ~]# hammer -u admin -p changeme host errata apply --host shost.idmqe.lab.eng.bos.redhat.com --errata-ids RHEA-2012:0002
[......................................................................................................] [100%]
walrus-5.21-1.noarch

Comment 11 Bryan Kearney 2016-07-27 11:16:10 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/RHBA-2016:1501