Bug 1896628

Summary: Hammer Command Fails to List Job Invocation Details if Organization is Used
Product: Red Hat Satellite Reporter: myoder
Component: Remote ExecutionAssignee: Adam Ruzicka <aruzicka>
Status: CLOSED ERRATA QA Contact: Peter Ondrejka <pondrejk>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.8.0CC: apatel, aruzicka, kgaikwad, lhellebr, lstejska, mknittel, ofedoren, pcreech, rabajaj, wwinter, yvan.broccard
Target Milestone: 6.11.0Keywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: tfm-rubygem-foreman_remote_execution-5.0.0 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-07-05 14:28:25 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:

Description myoder 2020-11-11 05:22:48 UTC
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 ch1.ooo.mu --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 ch1.ooo.mu 


PLAY [all] *********************************************************************

TASK [Gathering Facts] *********************************************************

fatal: [ch1.ooo.mu]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: ssh: Could not resolve hostname ch1.ooo.mu: Name or service not known", "unreachable": true}
PLAY RECAP *********************************************************************
ch1.ooo.mu                 : 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+%22ch1.ooo.mu%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 = \"ch1.ooo.mu\"", "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:

Comment 3 Adam Ruzicka 2021-07-13 13:54:22 UTC
Created redmine issue https://projects.theforeman.org/issues/33007 from this bug

Comment 6 Peter Ondrejka 2022-01-07 14:34:58 UTC
Verified on Satellite 7 snap 4, passing an organization flag no longer results in error

Comment 9 errata-xmlrpc 2022-07-05 14:28:25 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 (Moderate: Satellite 6.11 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/RHSA-2022:5498