Bug #9088
closedWhile defining discovery rule, any fact with integer value suggested by auto search raises PGError in production.log
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