Project

General

Profile

Actions

Bug #140

closed

dashboard fails when using postgresql backend

Added by Bob B. almost 15 years ago. Updated almost 12 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Database
Target version:
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

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?


Files

postgresql-fix-host.rb.patch postgresql-fix-host.rb.patch 1.79 KB Bob B., 12/21/2009 04:40 PM
Actions #1

Updated by Ohad Levy almost 15 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.

Actions #2

Updated by Ohad Levy almost 15 years ago

  • Status changed from New to Need more information
  • Assignee changed from Ohad Levy to Bob B.
Actions #3

Updated by Bob B. almost 15 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

Actions #4

Updated by Ohad Levy almost 15 years ago

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

Updated by Ohad Levy almost 15 years ago

  • Status changed from Ready For Testing to Closed
Actions

Also available in: Atom PDF