Project

General

Profile

Actions

Bug #24108

closed

Unknown column 'fact_names.name' - uploading reports fails due to missing table

Added by Ben Howell almost 6 years ago. Updated almost 6 years ago.

Status:
Resolved
Priority:
Normal
Assignee:
Category:
Foreman Integration
Target version:
-
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

Description

I've observed this behavior in both MySQL and Postgres. The table fact_names does not get created and the report uploader errors out when trying to enter it into the database. I have not tested it on any other database.

2018-06-28T16:08:47 fd9d964e [app] [I] Started POST "/api/hosts/facts" for 192.168.1.239 at 2018-06-28 16:08:47 +0000
2018-06-28T16:08:47 fd9d964e [app] [I] Processing by Api::V2::HostsController#facts as JSON
2018-06-28T16:08:47 fd9d964e [app] [I]   Parameters: {"name"=>"foreman-rutabaga.thecitybase.net", "facts"=>"[FILTERED]", "apiv"=>"v2", "host"=>{"name"=>"foreman-rutabaga.thecitybase.net"}}
2018-06-28T16:08:47 fd9d964e [app] [I] Current user: foreman_api_admin (administrator)
2018-06-28T16:08:47 fd9d964e [audit] [I] [foreman-rutabaga.thecitybase.net] deleted 0 (6.3ms)
2018-06-28T16:08:47 fd9d964e [audit] [I] [foreman-rutabaga.thecitybase.net] updated 0 (4.8ms)
2018-06-28T16:08:47 fd9d964e [app] [W] Action failed
 | ActiveRecord::StatementInvalid: Mysql2::Error: Unknown column 'fact_names.name' in 'field list': SELECT fact_names.name FROM `fact_values` WHERE `fact_values`.`host_id` = 2 AND `fact_values`.`fact_name_id` IN (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 81, 82, 84, 85, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203)
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/mysql2-0.4.10/lib/mysql2/client.rb:120:in `_query'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/mysql2-0.4.10/lib/mysql2/client.rb:120:in `block in query'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/mysql2-0.4.10/lib/mysql2/client.rb:119:in `handle_interrupt'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/mysql2-0.4.10/lib/mysql2/client.rb:119:in `query'

This appears immediately following a state.highstate using the "Run Salt" command.

Foreman 1.17.1, Foreman Salt 10.0.

Actions #1

Updated by Ben Howell almost 6 years ago

Here's the same error with Postgres:

2018-06-28T14:20:47 836b75d7 [app] [I] Started POST "/api/hosts/facts" for 192.168.1.239 at 2018-06-28 14:20:47 -0500
2018-06-28T14:20:47 836b75d7 [app] [I] Processing by Api::V2::HostsController#facts as JSON
2018-06-28T14:20:47 836b75d7 [app] [I]   Parameters: {"name"=>"foreman-rutabaga.thecitybase.net", "facts"=>"[FILTERED]", "apiv"=>"v2", "host"=>{"name"=>"foreman-rutabaga.thecitybase.net"}}
2018-06-28T14:20:47 836b75d7 [app] [I] Current user: foreman_api_admin (administrator)
2018-06-28T14:20:47 836b75d7 [audit] [I] [foreman-rutabaga.thecitybase.net] deleted 0 (6.6ms)
2018-06-28T14:20:47 836b75d7 [audit] [I] [foreman-rutabaga.thecitybase.net] updated 0 (5.0ms)
2018-06-28T14:20:47 836b75d7 [app] [W] Action failed
 | ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR:  missing FROM-clause entry for table "fact_names" 
 | LINE 1: SELECT fact_names.name FROM "fact_values" WHERE "fact_values...
 |                ^
 | : SELECT fact_names.name FROM "fact_values" WHERE "fact_values"."host_id" = $1 AND "fact_values"."fact_name_id" IN (363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, 463, 464, 465, 466, 467, 468, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 481, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 492, 493, 494, 495, 496, 497, 498, 499, 500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 525, 526, 527, 528, 529, 530, 531, 532, 533, 534, 535, 536, 537, 538, 539, 540, 541, 542, 543, 544, 545, 546, 547, 548, 549, 550, 551, 552, 553, 554, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567)
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/activerecord-5.1.4/lib/active_record/connection_adapters/postgresql_adapter.rb:614:in `async_exec'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/activerecord-5.1.4/lib/active_record/connection_adapters/postgresql_adapter.rb:614:in `block (2 levels) in exec_no_cache'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.1.4/lib/active_support/dependencies/interlock.rb:46:in `block in permit_concurrent_loads'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.1.4/lib/active_support/concurrency/share_lock.rb:185:in `yield_shares'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.1.4/lib/active_support/dependencies/interlock.rb:45:in `permit_concurrent_loads'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/activerecord-5.1.4/lib/active_record/connection_adapters/postgresql_adapter.rb:613:in `block in exec_no_cache'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract_adapter.rb:612:in `block (2 levels) in log'
 | /usr/lib/ruby/2.3.0/monitor.rb:214:in `mon_synchronize'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract_adapter.rb:611:in `block in log'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.1.4/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract_adapter.rb:603:in `log'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/activerecord-5.1.4/lib/active_record/connection_adapters/postgresql_adapter.rb:612:in `exec_no_cache'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/activerecord-5.1.4/lib/active_record/connection_adapters/postgresql_adapter.rb:601:in `execute_and_clear'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/activerecord-5.1.4/lib/active_record/connection_adapters/postgresql/database_statements.rb:79:in `exec_query'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract/database_statements.rb:371:in `select'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract/database_statements.rb:42:in `select_all'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract/query_cache.rb:95:in `block in select_all'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract/query_cache.rb:117:in `block in cache_sql'
 | /usr/lib/ruby/2.3.0/monitor.rb:214:in `mon_synchronize'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract/query_cache.rb:104:in `cache_sql'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract/query_cache.rb:95:in `select_all'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/activerecord-5.1.4/lib/active_record/relation/calculations.rb:169:in `pluck'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/foreman_salt-10.0.0/app/services/foreman_salt/fact_importer.rb:56:in `facts_to_create'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/foreman_salt-10.0.0/app/services/foreman_salt/fact_importer.rb:48:in `add_fact'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/foreman_salt-10.0.0/app/services/foreman_salt/fact_importer.rb:42:in `block in add_missing_facts'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/foreman_salt-10.0.0/app/services/foreman_salt/fact_importer.rb:26:in `each'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/foreman_salt-10.0.0/app/services/foreman_salt/fact_importer.rb:26:in `add_missing_facts'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/foreman_salt-10.0.0/app/services/foreman_salt/fact_importer.rb:21:in `add_new_facts'
Actions #2

Updated by Greg Sutcliffe almost 6 years ago

  • Category set to Foreman Integration
  • Status changed from New to Resolved
  • Assignee set to Shimon Shtein
  • Pull request https://github.com/theforeman/foreman_salt/pull/78 added

Thanks for the report! I ran across this myself last week but forgot to create a bug for it.

Shim has already investigated it for me and created a PR (https://github.com/theforeman/foreman_salt/pull/78) which has been merged to master, please feel free to try it out on your install and let us know how it goes.

Sadly this seems to have broken a few other things on the UI side, so I can't release a new gem until we get that ironed out.

Actions #3

Updated by Ben Howell almost 6 years ago

Greg Sutcliffe wrote:

Thanks for the report! I ran across this myself last week but forgot to create a bug for it.

Shim has already investigated it for me and created a PR (https://github.com/theforeman/foreman_salt/pull/78) which has been merged to master, please feel free to try it out on your install and let us know how it goes.

Sadly this seems to have broken a few other things on the UI side, so I can't release a new gem until we get that ironed out.

What's broken in the UI? I haven't seen any issues yet. I can confirm that reporting is working properly on this build though.

Actions #4

Updated by Ben Howell almost 6 years ago

FYI there was also another issue, I don't know if it's related to this, but I kept running into an error in 1.17.1 which uses Rails 5.1, "unable to convert unpermitted parameters to hash". I wound up rolling back to 5.0 and changing all of the Gems to 5.0.7, did a bundle update as the Foreman user, and everything is working properly now.

Files changed:

bundler.d/foreman_salt.rb (this adds the updates from master to fix fact_names)

gem 'foreman_salt', :git => 'git://github.com/theforeman/foreman_salt.git', :branch => 'master'

config/boot_settings.rb
SETTINGS[:rails] ||= '5.0'

Gemfile
when '5.0'
  gem 'rails', '5.0.7'
else

Gemfile(.lock) (I just used a vim command, sed might also work)
%s/5\.1\.4/5\.0\.7/g

Rollback rails to 5.0, as the foreman user
export GEM_HOME=$HOME/vendor/ruby/2.3.0
export GEM_PATH=$GEM_HOME:/var/lib/gems/2.3.0

/usr/bin/foreman-ruby /usr/bin/gem install bundler
/usr/bin/foreman-ruby $GEM_HOME/bin/bundle update

Actions #5

Updated by Greg Sutcliffe almost 6 years ago

The unpermitted params problem is what was blowing up my reporting, but I figured out what was needed so I didn't need to roll back. If you've got the stacktrace handy for your version of that, can you log a new bug with it? I can confirm if it's a new one or the same one as me, before I do a bugfix release of ForemanSalt :)

Actions #6

Updated by Ben Howell almost 6 years ago

Sure, I'll rebuild my test environment with no modifications and create a new bug with the relevant errors.

Actions

Also available in: Atom PDF