How to setup hammer API request timeout on Satellite 6
Environment
- Red Hat Satellite 6
- hammer
Issue
hammer -u <USER> -p <PASS> product list --organization Default_Organization --per-page 1000ended with timed out error, whereashammer -u <USER> -p <PASS> pingdid not end with a timeout error.- How to set longer timeout for
hammercommands? - We have >500 content-hosts listed in Satellite, running
hammer content-host list --organization <orgname>ends up withError: Request Timeoutafter approximately 2 minutes.
Resolution
Running hammer with timeout disabled:
- Edit
/etc/foreman-installer/scenarios.d/satellite-answers.yaml:
.
.
foreman::cli:
foreman_url:
request_timeout: -1 <----
.
.
- Run:
# satellite-installer
These steps should result in updating /etc/hammer/cli.modules.d/foreman.yml like this:
.
.
# API request timeout in seconds, set -1 for infinity
:request_timeout: -1
.
.
Running hammer with timeout disabled just for some hammer call(s):
For this, we use a customized configuration file:
- Create file
/tmp/hammer_no_timeout.ymlwith content:
:foreman:
:request_timeout: -1
- Load the configuration via
-cparameter:
# hammer -u <UESR> -p <PASS> -c /tmp/hammer_no_timeout.yml -vvv product list --organization <ORG> --per-page 1000
Running hammer with paged results:
-
If normal calls of
hammerare resulting inError: Request Timeout, it might still be possible to get the results paged. For this,--per-page <number>should be added, for example:# hammer host list --organization <orgname> --per-page 300 -
It is also possible to restrict the result with search criteria, restricting the number of results so the timeout is not hit:
# hammer host list --organization <orgname> --search "a*"
For more KB articles/solutions related to Red Hat Satellite 6.x hammer Issues, please refer to the Consolidated Troubleshooting Article for Red Hat Satellite 6.x hammer-related Issues
Root Cause
-
Errors which can be experienced with
hammerinclude:- Timeout error
- Timed out connecting to server
- Timed out reading data from server
-
By default the timeout for a request is 120 seconds. The same timeout is used for socket open, data read and data write operations.
Diagnostic Steps
-
Run
hammer -u <UESR> -p <PASS> ping# hammer -u <UESR> -p <PASS> ping candlepin: Status: ok Server Response: Duration: 88ms candlepin_auth: Status: ok Server Response: Duration: 34ms pulp: Status: ok Server Response: Duration: 23ms pulp_auth: Status: ok Server Response: Duration: 30ms elasticsearch: Status: ok Server Response: Duration: 28ms foreman_tasks: Status: ok Server Response: Duration: 0ms -
Run
hammer -u <USER> -p <PASS> -vvv product list --organization <ORG> --per-page 1000:# hammer -u <UESR> -p <PASS> -vvv product list --organization <ORG> --per-page 1000 [ERROR 2014-11-21 16:08:38 Exception] Error: Request Timeout Error: Request Timeout [ERROR 2014-11-21 16:08:38 Exception] RestClient::RequestTimeout (Request Timeout): /usr/share/gems/gems/rest-client-1.6.7/lib/restclient/request.rb:184:in `rescue in transmit' /usr/share/gems/gems/rest-client-1.6.7/lib/restclient/request.rb:140:in `transmit' /usr/share/gems/gems/rest-client-1.6.7/lib/restclient/request.rb:64:in `execute' /usr/share/gems/gems/rest-client-1.6.7/lib/restclient/request.rb:33:in `execute' /usr/share/gems/gems/rest-client-1.6.7/lib/restclient/resource.rb:51:in `get' /usr/share/gems/gems/apipie-bindings-0.0.8/lib/apipie_bindings/api.rb:195:in `http_call' /usr/share/gems/gems/apipie-bindings-0.0.8/lib/apipie_bindings/api.rb:150:in `call' /usr/share/gems/gems/apipie-bindings-0.0.8/lib/apipie_bindings/resource.rb:14:in `call' /usr/share/gems/gems/hammer_cli-0.1.1/lib/hammer_cli/apipie/command.rb:42:in `send_request' /usr/share/gems/gems/hammer_cli_foreman-0.1.1/lib/hammer_cli_foreman/commands.rb:164:in `send_request' /usr/share/gems/gems/hammer_cli_foreman-0.1.1/lib/hammer_cli_foreman/commands.rb:208:in `send_request' /usr/share/gems/gems/hammer_cli_foreman-0.1.1/lib/hammer_cli_foreman/commands.rb:254:in `retrieve_and_print' /usr/share/gems/gems/hammer_cli_foreman-0.1.1/lib/hammer_cli_foreman/commands.rb:241:in `browse_collection' /usr/share/gems/gems/hammer_cli_foreman-0.1.1/lib/hammer_cli_foreman/commands.rb:226:in `execute' /usr/share/gems/gems/clamp-0.6.2/lib/clamp/command.rb:67:in `run' /usr/share/gems/gems/hammer_cli-0.1.1/lib/hammer_cli/abstract.rb:22:in `run' /usr/share/gems/gems/clamp-0.6.2/lib/clamp/subcommand/execution.rb:11:in `execute' /usr/share/gems/gems/clamp-0.6.2/lib/clamp/command.rb:67:in `run' /usr/share/gems/gems/hammer_cli-0.1.1/lib/hammer_cli/abstract.rb:22:in `run' /usr/share/gems/gems/clamp-0.6.2/lib/clamp/subcommand/execution.rb:11:in `execute' /usr/share/gems/gems/clamp-0.6.2/lib/clamp/command.rb:67:in `run' /usr/share/gems/gems/hammer_cli-0.1.1/lib/hammer_cli/abstract.rb:22:in `run' /usr/share/gems/gems/clamp-0.6.2/lib/clamp/command.rb:125:in `run' /usr/share/gems/gems/hammer_cli-0.1.1/bin/hammer:102:in `<top (required)>' /usr/bin/hammer:23:in `load' /usr/bin/hammer:23:in `<main>'
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.