Project

General

Profile

Actions

Bug #30733

closed

Hammer CLI foreman-tasks not able to find task by ID when render json: job_invocations is returned

Added by Chris Roberts over 3 years ago. Updated about 3 years ago.

Status:
Resolved
Priority:
Normal
Assignee:
Category:
Dynflow
Target version:
-
Difficulty:
easy
Triaged:
No
Fixed in Releases:
Found in Releases:

Description

For resolve traces in Katello we render json with the job_invocations here:

https://github.com/Katello/katello/blob/master/app/controllers/katello/api/v2/host_tracer_controller.rb#L53

This causes an issue in hammer with finding the task to show the correct output to the user

```ruby
[DEBUG 2020-08-28T16:36:26 API] {
"error" => {
"message" => "Resource task not found by id '[{\"id\"=>30,+\"targeting_id\"=>30,+\"job_category\"=>\"Katello\",+\"task_id\"=>\"911a059c-47a5-4dd8-96d2-18faf4e0cfa9\",+\"task_group_id\"=>30,+\"triggering_id\"=>30,+\"description\"=>\"Restart+Services\",+\"concurrency_level\"=>nil,+\"time_span\"=>nil,+\"execution_timeout_interval\"=>nil,+\"password\"=>nil,+\"key_passphrase\"=>nil,+\"remote_execution_feature_id\"=>8,+\"sudo_password\"=>nil}]'"
}
}
[DEBUG 2020-08-28T16:36:26 Exception] Using exception handler HammerCLIKatello::ExceptionHandler#handle_not_found
[ERROR 2020-08-28T16:36:26 Exception] Resource task not found by id '[{"id"=>30,+"targeting_id"=>30,+"job_category"=>"Katello",+"task_id"=>"911a059c-47a5-4dd8-96d2-18faf4e0cfa9",+"task_group_id"=>30,+"triggering_id"=>30,+"description"=>"Restart+Services",+"concurrency_level"=>nil,+"time_span"=>nil,+"execution_timeout_interval"=>nil,+"password"=>nil,+"key_passphrase"=>nil,+"remote_execution_feature_id"=>8,+"sudo_password"=>nil}]'
Could not resolve traces:
Resource task not found by id '[{"id"=>30,+"targeting_id"=>30,+"job_category"=>"Katello",+"task_id"=>"911a059c-47a5-4dd8-96d2-18faf4e0cfa9",+"task_group_id"=>30,+"triggering_id"=>30,+"description"=>"Restart+Services",+"concurrency_level"=>nil,+"time_span"=>nil,+"execution_timeout_interval"=>nil,+"password"=>nil,+"key_passphrase"=>nil,+"remote_execution_feature_id"=>8,+"sudo_password"=>nil}]'
[ERROR 2020-08-28T16:36:26 Exception]

RestClient::NotFound (404 Not Found):
/home/vagrant/.gem/ruby/gems/rest-client-2.1.0/lib/restclient/abstract_response.rb:249:in `exception_with_response'
/home/vagrant/.gem/ruby/gems/rest-client-2.1.0/lib/restclient/abstract_response.rb:129:in `return!'
/home/vagrant/.gem/ruby/gems/apipie-bindings-0.4.0/lib/apipie_bindings/api.rb:353:in `block in rest_client_call_block'
/home/vagrant/.gem/ruby/gems/rest-client-2.1.0/lib/restclient/request.rb:834:in `process_result'
/home/vagrant/.gem/ruby/gems/rest-client-2.1.0/lib/restclient/request.rb:743:in `block in transmit'
/opt/rh/rh-ruby25/root/usr/share/ruby/net/http.rb:910:in `start'
/home/vagrant/.gem/ruby/gems/rest-client-2.1.0/lib/restclient/request.rb:727:in `transmit'
/home/vagrant/.gem/ruby/gems/rest-client-2.1.0/lib/restclient/request.rb:163:in `execute'
/home/vagrant/.gem/ruby/gems/rest-client-2.1.0/lib/restclient/request.rb:63:in `execute'
/home/vagrant/.gem/ruby/gems/rest-client-2.1.0/lib/restclient/resource.rb:51:in `get'
/home/vagrant/.gem/ruby/gems/apipie-bindings-0.4.0/lib/apipie_bindings/api.rb:327:in `call_client'
/home/vagrant/.gem/ruby/gems/apipie-bindings-0.4.0/lib/apipie_bindings/api.rb:240:in `http_call'
/home/vagrant/.gem/ruby/gems/apipie-bindings-0.4.0/lib/apipie_bindings/api.rb:190:in `call_action'
/home/vagrant/.gem/ruby/gems/apipie-bindings-0.4.0/lib/apipie_bindings/api.rb:185:in `call'
/home/vagrant/.gem/ruby/gems/apipie-bindings-0.4.0/lib/apipie_bindings/resource.rb:21:in `call'
/home/vagrant/hammer-cli-foreman-tasks/lib/hammer_cli_foreman_tasks/helper.rb:21:in `load_task'
/home/vagrant/hammer-cli-foreman-tasks/lib/hammer_cli_foreman_tasks/helper.rb:12:in `block in task_progress'
/home/vagrant/hammer-cli-foreman-tasks/lib/hammer_cli_foreman_tasks/task_progress.rb:54:in `update_task'
/home/vagrant/hammer-cli-foreman-tasks/lib/hammer_cli_foreman_tasks/task_progress.rb:14:in `render'
/home/vagrant/hammer-cli-foreman-tasks/lib/hammer_cli_foreman_tasks/helper.rb:13:in `task_progress'
/home/vagrant/hammer-cli-foreman-tasks/lib/hammer_cli_foreman_tasks/async_command.rb:14:in `execute'
```

We can see that difference between a normal task and ours:

Normal:
```ruby
=> "84100bcd-f7da-4f52-a730-9010544de1a3"
[2] pry(#<HammerCLIKatello::SubscriptionCommand::RefreshManifestCommand>)> task_or_id.is_a?(Hash)
=> true
```
Ours:
```ruby
[1] pry(#<HammerCLIKatello::HostTraces::ResolveCommand>)> task_id
=> [{"id"=>23,
"targeting_id"=>23,
"job_category"=>"Katello",
"task_id"=>"2fb2d86f-40f7-4384-b81b-04e32d4cfbb1",
"task_group_id"=>23,
"triggering_id"=>23,
"description"=>"Restart Services",
"concurrency_level"=>nil,
"time_span"=>nil,
"execution_timeout_interval"=>nil,
"password"=>nil,
"key_passphrase"=>nil,
"remote_execution_feature_id"=>8,
"sudo_password"=>nil}]
[2] pry(#<HammerCLIKatello::HostTraces::ResolveCommand>)> task_or_id.is_a?(Hash)
=> false
```

Actions #1

Updated by The Foreman Bot over 3 years ago

  • Status changed from New to Ready For Testing
  • Pull request https://github.com/theforeman/hammer-cli-foreman-tasks/pull/44 added
Actions #2

Updated by Adam Ruzicka about 3 years ago

  • Status changed from Ready For Testing to Resolved

This wasn't needed after all.

Actions

Also available in: Atom PDF