Bug 1342328 - Organization API, hosts endpoint is broken
Summary: Organization API, hosts endpoint is broken
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: API
Version: 6.2.0
Hardware: Unspecified
OS: Unspecified
unspecified
high
Target Milestone: Unspecified
Assignee: satellite6-bugs
QA Contact: Patrik Segedy
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-06-03 01:31 UTC by Bruno Rocha
Modified: 2019-09-26 16:20 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-02-21 17:31:59 UTC
Target Upstream Version:


Attachments (Terms of Use)

Description Bruno Rocha 2016-06-03 01:31:59 UTC
Description of problem:

 In API /apidoc/v2 documentation there is:
 
   GET /api/organizations/:organization_id/hosts
   List hosts per organization

but I can't find this endpoint in the list of endpoints in api/v2 meither in katello/api/v2

Version-Release number of selected component (if applicable):

Sat 6.2 snap 13

How reproducible:

Always

Steps to Reproduce:

while this works:

/katello/api/v2/organizations/1/sync_plans

this doesn't

/api/v2/organizations/1/hosts

neither

katello/api/v2/organizations/1/hosts

Actual results:

/api/v2/organizations/1/hosts

500 error and

==> /var/log/foreman/production.log <==
2016-06-03 02:55:42 [app] [I] Started GET "/api/v2/organizations/1/hosts" for 10.97.7.50 at 2016-06-03 02:55:42 +0200
2016-06-03 02:55:42 [app] [F] 
 | NoMethodError (undefined method `match' for nil:NilClass):
 |   katello (3.0.0.35) config/routes/overrides.rb:6:in `block in matches?'
 |   katello (3.0.0.35) config/routes/overrides.rb:6:in `map'
 |   katello (3.0.0.35) config/routes/overrides.rb:6:in `matches?'
 |   lib/middleware/catch_json_parse_errors.rb:9:in `call'
 | 
 | 

==> /var/log/httpd/foreman-ssl_access_ssl.log <==
10.97.7.50 - - [03/Jun/2016:02:55:42 +0200] "GET /api/v2/organizations/1/hosts HTTP/1.1" 500 1477 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36 Vivaldi/1.1.453.59"


and with

/katello/api/v2/organizations/1/hosts

404 and

==> /var/log/foreman/production.log <==
2016-06-03 02:52:09 [app] [I] Started GET "/katello/api/v2/organizations/1/hosts" for 10.97.7.50 at 2016-06-03 02:52:09 +0200
2016-06-03 02:52:09 [app] [F] 
 | ActionController::RoutingError (No route matches [GET] "/katello/api/v2/organizations/1/hosts"):
 |   actionpack (4.1.5) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
 |   actionpack (4.1.5) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
 |   railties (4.1.5) lib/rails/rack/logger.rb:38:in `call_app'
 |   railties (4.1.5) lib/rails/rack/logger.rb:22:in `call'
 |   actionpack (4.1.5) lib/action_dispatch/middleware/request_id.rb:21:in `call'
 |   rack (1.5.2) lib/rack/methodoverride.rb:21:in `call'
 |   rack (1.5.2) lib/rack/runtime.rb:17:in `call'
 |   activesupport (4.1.5) lib/active_support/cache/strategy/local_cache_middleware.rb:26:in `call'
 |   actionpack (4.1.5) lib/action_dispatch/middleware/static.rb:64:in `call'
 |   actionpack (4.1.5) lib/action_dispatch/middleware/static.rb:64:in `call'
 |   rack (1.5.2) lib/rack/sendfile.rb:112:in `call'
 |   railties (4.1.5) lib/rails/engine.rb:514:in `call'
 |   railties (4.1.5) lib/rails/application.rb:144:in `call'
 |   railties (4.1.5) lib/rails/railtie.rb:194:in `public_send'
 |   railties (4.1.5) lib/rails/railtie.rb:194:in `method_missing'
 |   rack (1.5.2) lib/rack/builder.rb:138:in `call'
 |   rack (1.5.2) lib/rack/urlmap.rb:65:in `block in call'
 |   rack (1.5.2) lib/rack/urlmap.rb:50:in `each'
 |   rack (1.5.2) lib/rack/urlmap.rb:50:in `call'
 |   /usr/share/gems/gems/passenger-4.0.18/lib/phusion_passenger/rack/thread_handler_extension.rb:77:in `process_request'
 |   /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'
 |   logging (1.8.2) lib/logging/diagnostic_context.rb:323:in `call'
 |   logging (1.8.2) lib/logging/diagnostic_context.rb:323:in `block in create_with_logging_context'
 | 
 | 

==> /var/log/httpd/foreman-ssl_access_ssl.log <==
10.97.7.50 - - [03/Jun/2016:02:52:08 +0200] "GET /katello/api/v2/organizations/1/hosts HTTP/1.1" 404 1564 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36 Vivaldi/1.1.453.59"
Expected results:


All the hosts for organization 

which I could get by:

/api/v2/hosts?organization_id=144

Additional info:

Comment 2 Bryan Kearney 2016-07-26 15:25:24 UTC
Moving 6.2 bugs out to sat-backlog.

Comment 3 Bryan Kearney 2016-07-26 15:28:18 UTC
Moving 6.2 bugs out to sat-backlog.

Comment 5 Ondřej Pražák 2017-02-17 15:01:12 UTC
Hi,
this seems to be already fixed in 6.2.8, I could not reproduce. 

curl -H "Accept: application/json" -H "Content-Type: application/json" -k -X GET -u admin:changeme https://sat-server/api/v2/organizations/1/hosts | json_reformat
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   151    0   151    0     0     33      0 --:--:--  0:00:04 --:--:--    44
{
    "total": 0,
    "subtotal": 0,
    "page": 1,
    "per_page": 20,
    "search": null,
    "sort": {
        "by": null,
        "order": null
    },
    "results": [

    ]
}

/var/log/foreman/production.log output:

2017-02-17 09:46:31 [app] [I] Started GET "/api/v2/organizations/1/hosts" for 10.16.70.13 at 2017-02-17 09:46:31 -0500
2017-02-17 09:46:31 [app] [I] Processing by Api::V2::HostsController#index as JSON
2017-02-17 09:46:31 [app] [I]   Parameters: {"apiv"=>"v2", "organization_id"=>"1", :host=>{}}
2017-02-17 09:46:31 [app] [I] Authorized user admin(Admin User)
2017-02-17 09:46:31 [app] [I]   Rendered api/v2/hosts/index.json.rabl within api/v2/layouts/index_layout (1.2ms)
2017-02-17 09:46:31 [app] [I] Completed 200 OK in 154ms (Views: 9.8ms | ActiveRecord: 25.1ms)


/api/v2/organizations/:organization_id/hosts endpoint worked as expected for me, /katello/api/v2/organizations/:organization_id/hosts is supposed to return 404, because the route does not exist.

Could QE verify?

Comment 6 Bruno Rocha 2017-05-26 06:27:15 UTC
Verified in

[root@cloud-qe-09 ~]# rpm -q satellite
satellite-6.2.10-1.0.el7sat.noarch

Results:

Properly working:


curl -H "Accept: application/json" -H "Content-Type: application/json" -k -X GET -u admin:changeme https://sat62/api/v2/organizations/1/hosts | jq
{
  "total": 3,
  "subtotal": 3,
  "page": 1,
  "per_page": 100,
  "search": null,
  "sort": {
    "by": null,
    "order": null
  },
  "results": [...]
}


will keep ON_QA until verification on 6.3

Comment 8 Bryan Kearney 2018-02-21 17:31:59 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, 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-2018:0336


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