Project

General

Profile

Bug #9088

While defining discovery rule, any fact with integer value suggested by auto search raises PGError in production.log

Added by Sachin Ghai over 7 years ago. Updated over 6 years ago.

Status:
Closed
Priority:
Low
Assignee:
-
Category:
Discovery plugin
Target version:
-
Difficulty:
Triaged:
No
Bugzilla link:
Pull request:
Fixed in Releases:
Found in Releases:

Description

Please see here.. I defined the "cpu_count = 1" in discovery rule, it was added from UI, but raises following error in production.log:

Processing by DiscoveredHostsController#auto_complete_search as JSON
Parameters: {"search"=>" cpu_count = 1"}
Operation FAILED: PGError: ERROR: operator does not exist: integer ~~ unknown
LINE 1: ...s" WHERE ("discovery_attribute_sets"."cpu_count" LIKE '1%')...
^
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
: SELECT DISTINCT "discovery_attribute_sets"."cpu_count" FROM "discovery_attribute_sets" WHERE ("discovery_attribute_sets"."cpu_count" LIKE '1%') ORDER BY "discovery_attribute_sets"."cpu_count" LIMIT 20
Rendered common/500.html.erb (10.8ms)
Completed 500 Internal Server Error in 54ms (Views: 12.4ms | ActiveRecord: 6.1ms)
Processing by DiscoveryRulesController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"R5Z9f4JSOla3H2Q3XusGWJx+w3u9MT2gN57+IHuFYVI=", "discovery_rule"=>{"name"=>"test", "search"=>" cpu_count = 1", "hostgroup_id"=>"1", "hostname"=>"", "max_count"=>"0", "priority"=>"0", "enabled"=>"1"}}
Redirected to https://dhcp207-190.lab.eng.pnq.redhat.com/discovery_rules
Completed 302 Found in 55ms (ActiveRecord: 15.7ms)

Then I defined other rule (disks_size = 8589934592) suggested by auto-search and this time to same error appears in prduction.log and rule was accepted by UI

Processing by DiscoveredHostsController#auto_complete_search as JSON
Parameters: {"search"=>" disks_size = 8589934592"}
Operation FAILED: PGError: ERROR: operator does not exist: bigint ~~ unknown
LINE 1: ..." WHERE ("discovery_attribute_sets"."disks_size" LIKE '8589...
^
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
: SELECT DISTINCT "discovery_attribute_sets"."disks_size" FROM "discovery_attribute_sets" WHERE ("discovery_attribute_sets"."disks_size" LIKE '8589934592%') ORDER BY "discovery_attribute_sets"."disks_size" LIMIT 20
Rendered common/500.html.erb (10.9ms)
Completed 500 Internal Server Error in 61ms (Views: 12.7ms | ActiveRecord: 5.0ms)
Processing by DiscoveryRulesController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"R5Z9f4JSOla3H2Q3XusGWJx+w3u9MT2gN57+IHuFYVI=", "discovery_rule"=>{"name"=>"test2", "search"=>" disks_size = 8589934592", "hostgroup_id"=>"1", "hostname"=>"", "max_count"=>"0", "priority"=>"0", "enabled"=>"1"}}
Redirected to https://dhcp207-190.lab.eng.pnq.redhat.com/discovery_rules
Completed 302 Found in 53ms (ActiveRecord: 14.9ms)

This is happening when defining any fact with integer value.. Ideally no such error should be appeared in production.log

Reproducible with:
rubygem-smart_proxy_discovery-1.0.1-1.el6.noarch
ruby193-rubygem-foreman_discovery-2.0.0-0.1.rc1.el6.noarch

foreman-release-1.8.0-0.develop.201501211657git1cf860b.el6.noarch
foreman-1.8.0-0.develop.201501211657git1cf860b.el6.noarch


Related issues

Blocked by Foreman - Feature #8502: Move to scoped_search 3.xClosed2014-11-25

History

#1 Updated by Lukas Zapletal over 7 years ago

  • Priority changed from Normal to Urgent

Ori, this one might need some changes to scoped_search. I hope we don't have a design issue (all scoped_search fields are expected to be text).

#2 Updated by Ori Rabin over 7 years ago

  • Status changed from New to Assigned
  • Assignee changed from Lukas Zapletal to Ori Rabin

#3 Updated by Ori Rabin over 7 years ago

  • Status changed from Assigned to New
  • Assignee deleted (Ori Rabin)
  • Priority changed from Urgent to Low

Lowering the priority since the functionality of search in intact and the error is not shown in the UI.

Sachin Ghai, nice catch.
This is a bug in scoped_search when trying to auto_complete integer values.
While you are writing the search 'disks_size = 8589934592' when you got to: 'disks_size = 8' scoped_search tried to complete the possible disk sizes by running a query to check for disks_size that contain '8':

WHERE ("discovery_attribute_sets"."disks_size" LIKE '8'..)

This failed since disks_size is an integer and you can't use the LIKE operator on it.
As a result you still saw all options for disks_size and not only those starting with '8'.

We can eliminate the error by removing the auto_complete from all integer fields.
I don't think this is a good idea since the search itself does work and the auto_complete works only for the full value which is still better then not working at all.

#4 Updated by Ori Rabin over 7 years ago

#5 Updated by Lukas Zapletal over 7 years ago

  • Bugzilla link set to 1190601

#6 Updated by Lukas Zapletal over 7 years ago

This was fixed in the scoped_search dependency: https://github.com/wvanbergen/scoped_search/pull/121

#7 Updated by Lukas Zapletal over 7 years ago

#8 Updated by Lukas Zapletal over 6 years ago

  • Status changed from New to Closed

Also available in: Atom PDF