Bug #33007
closedHammer Command Fails to List Job Invocation Details if Organization is Used
Description
Cloned from https://bugzilla.redhat.com/show_bug.cgi?id=1896628
Description of problem:
When using hammer command to get details about a job-invocation task, when using the organization flag, there is a 500 error thrown:
- hammer job-invocation output --id 1 --host something.somewhere.com --organization-id=1
Internal Server Error: the server was unable to finish the request. This may be caused by unavailability of some required service, incorrect API call or a server-side bug. There may be more information in the server's logs.
Without the flag, the job invocation returns normally:
- hammer job-invocation output --id 1 --host something.somewhere.com
PLAY [all] *************************************************************
TASK [Gathering Facts] *************************************************
fatal: [something.somewhere.com]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: ssh: Could not resolve hostname something.somewhere.com: Name or service not known", "unreachable": true}
PLAY RECAP *************************************************************
something.somewhere.com : ok=0 changed=0 unreachable=1 failed=0 skipped=0 rescued=0 ignored=0
Exit status: 1
In the /var/log/foreman/production.log:
FAILED HAMMER COMMAND:
2020-11-11T00:16:49 [I|app|cdbf086d] Completed 200 OK in 188ms (Views: 34.1ms | ActiveRecord: 39.9ms)
2020-11-11T00:16:49 [I|app|971abc27] Started GET "/api/job_invocations/1/hosts/8?organization_id=1&since" for 192.168.0.24 at 2020-11-11 00:16:49 -0500
2020-11-11T00:16:49 [I|app|971abc27] Processing by Api::V2::JobInvocationsController#output as JSON
2020-11-11T00:16:49 [I|app|971abc27] Parameters: {"organization_id"=>"1", "since"=>nil, "apiv"=>"v2", "job_invocation_id"=>"1", "host_id"=>"8", "job_invocation"=>{}}
2020-11-11T00:16:49 [D|app|971abc27] Authenticated user admin against INTERNAL authentication source
2020-11-11T00:16:49 [I|app|971abc27] Authorized user admin(Admin User)
2020-11-11T00:16:49 [D|tax|971abc27] Current location set to none
2020-11-11T00:16:49 [D|tax|971abc27] Current organization set to Studio-14
2020-11-11T00:16:49 [D|tax|971abc27] Current location set to none
2020-11-11T00:16:49 [D|tax|971abc27] Current organization set to Studio-14
2020-11-11T00:16:49 [W|app|971abc27] Action failed
2020-11-11T00:16:49 [D|app|971abc27] Backtrace for 'Action failed' error (NoMethodError): undefined method `task' for #<Organization:0x00007f6e43f82f10>
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activemodel-5.2.1/lib/active_model/attribute_methods.rb:430:in `method_missing'
/opt/theforeman/tfm/root/usr/share/gems/gems/audited-4.9.0/lib/audited/auditor.rb:99:in `method_missing'
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman_remote_execution-2.0.10.2/app/controllers/api/v2/job_invocations_controller.rb:81:in `output'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/abstract_controller/base.rb:194:in `process_action'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_controller/metal/rendering.rb:30:in `process_action'
< - - skipped - ->
/usr/share/gems/gems/passenger-4.0.18/lib/phusion_passenger/request_handler/thread_handler.rb:140:in `accept_and_process_next_request'
/usr/share/gems/gems/passenger-4.0.18/lib/phusion_passenger/request_handler/thread_handler.rb:108:in `main_loop'
/usr/share/gems/gems/passenger-4.0.18/lib/phusion_passenger/request_handler.rb:441:in `block (3 levels) in start_threads'
/opt/theforeman/tfm/root/usr/share/gems/gems/logging-2.2.2/lib/logging/diagnostic_context.rb:474:in `block in create_with_logging_context'
2020-11-11T00:16:49 [I|app|971abc27] Rendering api/v2/errors/custom_error.json.rabl within api/v2/layouts/error_layout
2020-11-11T00:16:49 [I|app|971abc27] Rendered api/v2/errors/custom_error.json.rabl within api/v2/layouts/error_layout (0.7ms)
2020-11-11T00:16:49 [I|app|971abc27] Completed 500 Internal Server Error in 181ms (Views: 1.8ms | ActiveRecord: 31.2ms)
SUCCESSFUL HAMMER COMMAND:
2020-11-11T00:16:54 [I|app|5a6b1e37] Started GET "/api/hosts?search=name+%3D+%22something.somewhere.com%22&per_page=1000&page=1" for 192.168.0.24 at 2020-11-11 00:16:54 -0500
2020-11-11T00:16:54 [I|app|5a6b1e37] Processing by Api::V2::HostsController#index as JSON
2020-11-11T00:16:54 [I|app|5a6b1e37] Parameters: {"search"=>"name = \"something.somewhere.com\"", "per_page"=>"1000", "page"=>"1", "apiv"=>"v2", "host"=>{}}
2020-11-11T00:16:54 [I|app|5a6b1e37] Authorized user admin(Admin User)
2020-11-11T00:16:55 [I|app|5a6b1e37] Rendering api/v2/hosts/index.json.rabl within api/v2/layouts/index_layout
2020-11-11T00:16:55 [I|app|5a6b1e37] Rendered api/v2/hosts/index.json.rabl within api/v2/layouts/index_layout (38.8ms)
2020-11-11T00:16:55 [I|app|5a6b1e37] Completed 200 OK in 196ms (Views: 37.1ms | ActiveRecord: 44.0ms)
2020-11-11T00:16:55 [I|app|e086311a] Started GET "/api/job_invocations/1/hosts/8?since" for 192.168.0.24 at 2020-11-11 00:16:55 -0500
2020-11-11T00:16:55 [I|app|e086311a] Processing by Api::V2::JobInvocationsController#output as JSON
2020-11-11T00:16:55 [I|app|e086311a] Parameters: {"since"=>nil, "apiv"=>"v2", "job_invocation_id"=>"1", "host_id"=>"8", "job_invocation"=>{}}
2020-11-11T00:16:55 [I|app|e086311a] Authorized user admin(Admin User)
2020-11-11T00:16:55 [I|app|e086311a] Completed 200 OK in 195ms (Views: 0.6ms | ActiveRecord: 46.3ms)
Version-Release number of selected component (if applicable):
Satellite 6.8
How reproducible:
always
Steps to Reproduce:
1. Run a job invocation task on a host
2. Try to inspect the job invocation with hammer, while specifying an organization
3.
Actual results:
Hammer command fails with 500 internal error
Expected results:
Hammer command should succeed
Additional info:
Updated by The Foreman Bot almost 4 years ago
- Status changed from New to Ready For Testing
- Assignee set to Adam Ruzicka
- Pull request https://github.com/theforeman/hammer_cli_foreman_remote_execution/pull/40 added
Updated by The Foreman Bot almost 4 years ago
- Pull request https://github.com/theforeman/foreman_remote_execution/pull/615 added
Updated by Adam Ruzicka over 3 years ago
- Status changed from Ready For Testing to Closed
Applied in changeset foreman_plugin|fe4613c6f2e7a0f1d184e51b3b5325115cdedb02.
Updated by Adam Ruzicka over 3 years ago
- Fixed in Releases foreman_remote_execution-5.0.0 added