Project

General

Profile

Bug #21893

GET /docker/api/v2/containers returns SQL error when sending optional compute_resource_id

Added by Sebastian Gräßl over 2 years ago. Updated over 2 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
-
Target version:
-
Difficulty:
Triaged:
No
Bugzilla link:
Fixed in Releases:
Found in Releases:

Description

Cloned from https://bugzilla.redhat.com/show_bug.cgi?id=1466240

Description of problem:

  1. With compute_resource_id
    > $ curl -s -H "Content-Type: application/json" -H "Accept:application/json" -k -u "admin:changeme" -X GET -d '{"compute_resource_id": 1}' https://sat6.com/docker/api/v2/containers                                                                                                                 
    > {
    >   "error": {"message":"PG::Error: ERROR:  argument of WHERE must be type boolean, not type integer\nLINE 1: SELECT  \"containers\".* FROM \"containers\" WHERE (1) LIMIT 20 ...\n                                                        ^\n: SELECT  \"containers\".* FROM \"containers\" WHERE (1) LIMIT 20 OFFSET 0"}
    > }
    
  1. Without compute_resource_id
> $ curl -s -H "Content-Type: application/json" -H "Accept:application/json" -k -u "admin:changeme" -X GET https://sat6.com/docker/api/v2/containers                                                                                                                  
> {
>  "total": 0,
> ...
> }

production log:

> 2017-06-29 04:42:18 a4fb040e [app] [I] Started GET "/docker/api/v2/containers" for 10.36.116.61 at 2017-06-29 04:42:18 -0400
> 2017-06-29 04:42:18 a4fb040e [app] [I] Processing by Api::V2::ContainersController#index as JSON
> 2017-06-29 04:42:18 a4fb040e [app] [I]   Parameters: {"compute_resource_id"=>1, "apiv"=>"v2", "container"=>{"compute_resource_id"=>1}}
> 2017-06-29 04:42:18 a4fb040e [app] [I]   Rendered /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_docker-3.1.0/app/views/api/v2/containers/index.json.rabl within api/v2/layouts/index_layout (4.1ms)
> 2017-06-29 04:42:18 a4fb040e [app] [W] Action failed
> | ActiveRecord::StatementInvalid: PG::Error: ERROR:  argument of WHERE must be type boolean, not type integer
> | LINE 1: SELECT  "containers".* FROM "containers" WHERE (1) LIMIT 20 ...
> |                                                         ^
> | : SELECT  "containers".* FROM "containers" WHERE (1) LIMIT 20 OFFSET 0

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

  • katello-3.4.1-1.el7sat.noarch
  • foreman-1.15.1-1.el7sat.noarch
  • satellite-6.3.0-16.0.beta.el7sat.noarch
  • tfm-rubygem-foreman_docker-3.1.0-1.fm1_15.el7sat.noarch
  • tfm-rubygem-docker-api-1.28.0-2.el7sat.noarch

How reproducible:
Always

Steps to Reproduce:
1. curl -s -H "Content-Type: application/json" -H "Accept:application/json" -k -u "admin:changeme" -X GET -d '{"compute_resource_id": 1}' http://localhost:3000/docker/api/v2/containers
2.
3.

Actual results:
SQL error

Expected results:
Containers should be listed


Related issues

Related to Docker - Refactor #19694: Align Rubocop with foreman core settingsClosed2017-05-29

Associated revisions

Revision 40825a11 (diff)
Added by Marek Hulán over 2 years ago

Fixes #21893 - fix listing containers for specific CR

Revision 40825a11 (diff)
Added by Marek Hulán over 2 years ago

Fixes #21893 - fix listing containers for specific CR

Revision 04b6e05e (diff)
Added by Daniel Lobato Garcia over 2 years ago

Refs #21893 - rubocop trailing whitespace

Revision 04b6e05e (diff)
Added by Daniel Lobato Garcia over 2 years ago

Refs #21893 - rubocop trailing whitespace

History

#1 Updated by Marek Hulán over 2 years ago

  • Related to Refactor #19694: Align Rubocop with foreman core settings added

#2 Updated by The Foreman Bot over 2 years ago

  • Assignee set to Marek Hulán
  • Status changed from New to Ready For Testing
  • Pull request https://github.com/theforeman/foreman-docker/pull/204 added

#3 Updated by Anonymous over 2 years ago

  • % Done changed from 0 to 100
  • Status changed from Ready For Testing to Closed

Also available in: Atom PDF