Bug 1692698 - hammer throws "too few arguments (ArgumentError)" when Satellite returns 500
Summary: hammer throws "too few arguments (ArgumentError)" when Satellite returns 500
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Hammer
Version: 6.5.0
Hardware: Unspecified
OS: Unspecified
low vote
Target Milestone: 6.8.0
Assignee: Oleh Fedorenko
QA Contact: Mirek Długosz
: 1707792 (view as bug list)
Depends On:
TreeView+ depends on / blocked
Reported: 2019-03-26 09:25 UTC by Evgeni Golov
Modified: 2020-07-10 07:57 UTC (History)
9 users (show)

Fixed In Version: tfm-rubygem-hammer_cli_katello-0.21.0
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Last Closed:
Target Upstream Version:

Attachments (Terms of Use)
hammer -d ping output (531.61 KB, text/plain)
2019-03-27 18:15 UTC, Evgeni Golov
no flags Details

System ID Priority Status Summary Last Updated
Foreman Issue Tracker 27548 Normal Closed hammer throws "too few arguments (ArgumentError)" when Satellite returns 500 2020-09-01 09:52:18 UTC

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):

How reproducible:

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- `<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- `run'
	 9: from /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli- `rescue in run'
	 8: from /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli- `handle_exception'
	 7: from /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli- `handle_exception'
	 6: from /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli- `handle_general_exception'
	 5: from /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli- `print_error'
	 4: from /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli- `print_error'
	 3: from /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli- `print_error'
	 2: from /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli- `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@redhat.com

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:
$ 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)

On 6.8:
$ hammer ping
Error: 502 Bad Gateway

Tested on:
Satellite 6.8.0 snap 5

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