Bug #140

dashboard fails when using postgresql backend

Added by Bob B. almost 5 years ago. Updated almost 2 years ago.

Status:ClosedStart date:12/18/2009
Priority:NormalDue date:
Assigned To:Bob B.% Done:

100%

Category:Database
Target version:0.1-4
Difficulty: Bugzilla link:
Found in release: Pull request:
Story points-
Velocity based estimate-

Description

The dashboard returns a 500 with the following error:

Processing DashboardController#index (for x.x.x.x at 2009-12-18 15:57:52) [GET]
Parameters: {"action"=>"index", "controller"=>"dashboard"}

ActiveRecord::StatementInvalid (PGError: ERROR: argument of AND must be type boolean, not type integer
LINE 2: (puppet_status >> 12 & 63) or
^
: SELECT count(*) AS count_all FROM "hosts" WHERE (((puppet_status > 0) and
(puppet_status >> 12 & 63) or
(puppet_status >> 18 & 63) or
(puppet_status >> 24 & 63)) AND (last_report > '2009-12-18 15:22:52.485923')) ):
(DELEGATION):2:in `__send__'
(DELEGATION):2:in `with_scope'
(DELEGATION):2:in `__send__'
(DELEGATION):2:in `with_scope'
(DELEGATION):2:in `__send__'
(DELEGATION):2:in `with_scope'
app/controllers/dashboard_controller.rb:8:in `index'

Rendering /var/rails/foreman/public/500.html (500 Internal Server Error)

Additionally, this also happens if the above error is eliminated:

Processing DashboardController#index (for x.x.x.x at 2009-12-18 17:17:23) [GET]
Parameters: {"action"=>"index", "controller"=>"dashboard"}

ActiveRecord::StatementInvalid (PGError: ERROR: operator does not exist: timestamp without time zone <> integer
LINE 1: ...unt() AS count_all FROM "reports" WHERE (reported_at != 0)
^
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
: SELECT count(
) AS count_all FROM "reports" WHERE (reported_at != 0) ):
(DELEGATION):2:in `__send__'
(DELEGATION):2:in `with_scope'
app/controllers/dashboard_controller.rb:19:in `index'

Rendering /var/rails/foreman/public/500.html (500 Internal Server Error)

I'm not entirely sure how the puppet_status manipulations happen, but I believe the error is caused by how other dbs evaluate truth as 0 and non-0. I think this can be avoided by something simliar to:

(puppet_status >> #{Report::BIT_NUM*Report::METRIC.index("failed")} & #{Report::MAX}) or

becomes:

((puppet_status >> #{Report::BIT_NUM*Report::METRIC.index("applied")} & #{Report::MAX}) !=0) or

(in models/host.rb)

For the additional date error (on reported_at), I think it's just trying to find if a report exists? (I'm not all that familiar with the code, or ruby) Maybe checking for NULL instead of 0?

postgresql-fix-host.rb.patch Magnifier (1.79 KB) Bob B., 12/21/2009 04:40 PM

Associated revisions

Revision 8f823b83
Added by Ohad Levy over 4 years ago

fixes #140 - dashboard fails when using postgresql backend

History

#1 Updated by Ohad Levy almost 5 years ago

  • Target version set to 0.1-4

Bob B. wrote:

becomes:

((puppet_status >> #{Report::BIT_NUM*Report::METRIC.index("applied")} & #{Report::MAX}) !=0) or

could you give this a try? i don't have db available at this moment.

(in models/host.rb)

For the additional date error (on reported_at), I think it's just trying to find if a report exists?

This has already been fix in #133, it was a simple typo.

#2 Updated by Ohad Levy almost 5 years ago

  • Status changed from New to Need more information
  • Assigned To changed from Ohad Levy to Bob B.

#3 Updated by Bob B. over 4 years ago

It seemed to work with that change (no error), but I did not test it against other dbs, or if the correct behavior results. Patch attached

#4 Updated by Ohad Levy over 4 years ago

  • Status changed from Need more information to Ready For Testing
  • % Done changed from 0 to 100

#5 Updated by Ohad Levy over 4 years ago

  • Status changed from Ready For Testing to Closed

Also available in: Atom PDF