Bug 1692698

Summary: hammer throws "too few arguments (ArgumentError)" when Satellite returns 500
Product: Red Hat Satellite Reporter: Evgeni Golov <egolov>
Component: HammerAssignee: Oleh Fedorenko <ofedoren>
Status: CLOSED ERRATA QA Contact: Mirek Długosz <mzalewsk>
Severity: low Docs Contact:
Priority: unspecified    
Version: 6.5.0CC: apatel, brian.mccafferty, desingh, dhlavacd, kgaikwad, mbacovsk, mshira, rabajaj, vmeghana
Target Milestone: 6.8.0Keywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: tfm-rubygem-hammer_cli_katello-0.21.0 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-10-27 13:32: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:
Attachments:
Description Flags
hammer -d ping output none

Description Evgeni Golov 2019-03-26 09:25:16 UTC
Description of problem:
When Satellite returns 500 errors (because Passenger is unhappy), running hammer commands like "hammer ping" results in an ugly error instead of a nice message saying that the Satellite could not be reached.

Version-Release number of selected component (if applicable):
tfm-rubygem-hammer_cli-0.15.1.1-1.el7sat.noarch

How reproducible:
100%

Steps to Reproduce:
1. make Passenger return an error (like "Web application could not be started" by installing an incompatible GEM version)
2. hammer ping

Actual results:
# hammer ping
Traceback (most recent call last):
	14: from /bin/hammer:23:in `<main>'
	13: from /bin/hammer:23:in `load'
	12: from /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.15.1.1/bin/hammer:147:in `<top (required)>'
	11: from /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.1.2/lib/clamp/command.rb:132:in `run'
	10: from /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.15.1.1/lib/hammer_cli/abstract.rb:28:in `run'
	 9: from /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.15.1.1/lib/hammer_cli/abstract.rb:32:in `rescue in run'
	 8: from /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.15.1.1/lib/hammer_cli/abstract.rb:188:in `handle_exception'
	 7: from /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.15.1.1/lib/hammer_cli/exception_handler.rb:31:in `handle_exception'
	 6: from /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.15.1.1/lib/hammer_cli/exception_handler.rb:65:in `handle_general_exception'
	 5: from /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.15.1.1/lib/hammer_cli/exception_handler.rb:48:in `print_error'
	 4: from /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.15.1.1/lib/hammer_cli/output/output.rb:23:in `print_error'
	 3: from /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.15.1.1/lib/hammer_cli/output/adapter/abstract.rb:33:in `print_error'
	 2: from /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.15.1.1/lib/hammer_cli/utils.rb:13:in `format'
	 1: from /opt/theforeman/tfm/root/usr/share/gems/gems/fast_gettext-1.4.1/lib/fast_gettext/vendor/string.rb:70:in `%'
/opt/theforeman/tfm/root/usr/share/gems/gems/fast_gettext-1.4.1/lib/fast_gettext/vendor/string.rb:70:in `%': too few arguments (ArgumentError)


Expected results:
A human readable error. Compare this to the error you get when httpd is completely down:
# hammer ping
Could not load the API description from the server: 
Failed to open TCP connection to sat-6-5-qa-rhel7.kangae.example.com:443 (Connection refused - connect(2) for "sat-6-5-qa-rhel7.kangae.example.com" port 443)
  - is the server down?
  - was 'foreman-rake apipie:cache' run on the server when using apipie cache? (typical production settings)


Additional info:

Comment 3 Martin Bacovsky 2019-03-27 16:48:15 UTC
Could you please share debug output of 'hammer -d ping'? Then we can better discuss what should be the appropriate solution.

I tried to reproduce and got 500 error containing some backtrace. 500 is generic (unhandled) error and the backtrace is
the massage attached by server. Hammer by default prints the error message. Is this the same what you see?
Shouldn't the message be improved on the server side?
Would be prepending message like "Your server encountred unhandled error:" acceptable solution for you?
Prinitng that the server is down on unhandled errors does not seem correct to me.

Comment 4 Evgeni Golov 2019-03-27 18:15:16 UTC
Created attachment 1548695 [details]
hammer -d ping output

Sure, attached.

The error displayed is from hammer, not the one that Satellite suffers (in the pictured case, it's an incompatible GEM, the easiest way to make Satellite not to start up properly).

Comment 5 Evgeni Golov 2019-05-08 11:50:14 UTC
*** Bug 1707792 has been marked as a duplicate of this bug. ***

Comment 6 Martin Bacovsky 2019-08-08 12:52:12 UTC
Created redmine issue https://projects.theforeman.org/issues/27548 from this bug

Comment 7 Bryan Kearney 2019-12-03 20:23:41 UTC
Upstream bug assigned to ofedoren

Comment 8 Bryan Kearney 2019-12-03 20:23:42 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue https://projects.theforeman.org/issues/27548 has been resolved.

Comment 9 Mirek Długosz 2020-06-23 18:38:00 UTC
As reproducer, I modified foreman_rh_cloud plugin file lib/foreman_rh_cloud/engine.rb to require non-existing foreman version. Then I restarted Satellite services and ran hammer ping.

On 6.6:
#v+
$ hammer ping
Traceback (most recent call last):
        14: from /usr/bin/hammer:23:in `<main>'
        13: from /usr/bin/hammer:23:in `load'
        12: from /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.17.1/bin/hammer:147:in `<top (required)>'
        11: from /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.1.2/lib/clamp/command.rb:132:in `run'
        10: from /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.17.1/lib/hammer_cli/abstract.rb:68:in `run'
         9: from /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.17.1/lib/hammer_cli/abstract.rb:72:in `rescue in run'
         8: from /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.17.1/lib/hammer_cli/abstract.rb:256:in `handle_exception'
         7: from /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.17.1/lib/hammer_cli/exception_handler.rb:31:in `handle_exception'
         6: from /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.17.1/lib/hammer_cli/exception_handler.rb:65:in `handle_general_exception'
         5: from /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.17.1/lib/hammer_cli/exception_handler.rb:48:in `print_error'
         4: from /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.17.1/lib/hammer_cli/output/output.rb:23:in `print_error'
         3: from /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.17.1/lib/hammer_cli/output/adapter/abstract.rb:33:in `print_error'
         2: from /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.17.1/lib/hammer_cli/utils.rb:13:in `format'
         1: from /opt/theforeman/tfm/root/usr/share/gems/gems/fast_gettext-1.4.1/lib/fast_gettext/vendor/string.rb:70:in `%'
/opt/theforeman/tfm/root/usr/share/gems/gems/fast_gettext-1.4.1/lib/fast_gettext/vendor/string.rb:70:in `%': too few arguments (ArgumentError)
#v-

On 6.8:
#v+
$ hammer ping
Error: 502 Bad Gateway
#v-

Tested on:
Satellite 6.8.0 snap 5
pulp-server-2.21.2-1.el7sat.noarch
satellite-6.8.0-0.4.beta.el7sat.noarch
foreman-2.1.0-0.20.rc2.el7sat.noarch
katello-3.16.0-0.3.rc1.el7sat.noarch
tfm-rubygem-hammer_cli-2.1.1-1.el7sat.noarch
tfm-rubygem-hammer_cli_foreman-2.1.1-1.el7sat.noarch
tfm-rubygem-hammer_cli_katello-0.22.2-1.el7sat.noarch

Comment 12 errata-xmlrpc 2020-10-27 13:32: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 (Satellite 6.8 Satellite Tools Release), 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-2020:4367