Unknown class Trend, ignoring

Problem:
I have noticed this error in production.log of my main foreman server. It seems to come 9 times twice an hour at minutes 00 and 30. I does not seem to affect the system.

Expected outcome:
No errors.

Foreman and Proxy versions:
Foreman 3.1.2, Katello 4.3.1

Distribution and version:
CentOS 7.9

Other relevant data:

2022-04-19T14:30:09 [W|app|] unknown class Trend, ignoring
2022-04-19T14:30:09 [I|app|] Backtrace for 'unknown class Trend, ignoring' error (NameError): uninitialized constant Trend
 | /opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/inflector/methods.rb:282:in `const_get'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/inflector/methods.rb:282:in `block in constantize'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/inflector/methods.rb:280:in `each'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/inflector/methods.rb:280:in `inject'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/inflector/methods.rb:280:in `constantize'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/core_ext/string/inflections.rb:68:in `constantize'
 | /usr/share/foreman/app/models/filter.rb:85:in `get_resource_class'
 | /usr/share/foreman/app/models/filter.rb:117:in `resource_class'
 | /usr/share/foreman/app/models/filter.rb:124:in `granular?'
 | /usr/share/foreman/app/models/filter.rb:135:in `resource_taxable_by_organization?'
 | /usr/share/foreman/app/models/filter.rb:181:in `build_taxonomy_search_string'
 | /usr/share/foreman/app/models/filter.rb:173:in `build_taxonomy_search'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/callbacks.rb:428:in `block in make_lambda'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/callbacks.rb:200:in `block (2 levels) in halting'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/callbacks.rb:605:in `block (2 levels) in default_terminator'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/callbacks.rb:604:in `catch'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/callbacks.rb:604:in `block in default_terminator'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/callbacks.rb:201:in `block in halting'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/callbacks.rb:513:in `block in invoke_before'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/callbacks.rb:513:in `each'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/callbacks.rb:513:in `invoke_before'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/callbacks.rb:134:in `run_callbacks'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/callbacks.rb:825:in `_run_validation_callbacks'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/activemodel-6.0.3.7/lib/active_model/validations/callbacks.rb:117:in `run_validations!'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/activemodel-6.0.3.7/lib/active_model/validations.rb:337:in `valid?'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/validations.rb:68:in `valid?'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/validations.rb:84:in `perform_validations'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/validations.rb:47:in `save'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/transactions.rb:314:in `block in save'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/transactions.rb:375:in `block in with_transaction_returning_status'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract/database_statements.rb:278:in `transaction'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/transactions.rb:212:in `transaction'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/transactions.rb:366:in `with_transaction_returning_status'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/transactions.rb:314:in `save'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/suppressor.rb:44:in `save'
 | /usr/share/foreman/app/models/role.rb:279:in `block in sync_inheriting_filters'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/relation/batches.rb:70:in `block (2 levels) in find_each'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/relation/batches.rb:70:in `each'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/relation/batches.rb:70:in `block in find_each'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/relation/batches.rb:136:in `block in find_in_batches'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/relation/batches.rb:238:in `block in in_batches'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/relation/batches.rb:222:in `loop'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/relation/batches.rb:222:in `in_batches'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/relation/batches.rb:135:in `find_in_batches'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/relation/batches.rb:69:in `find_each'
 | /usr/share/foreman/app/models/role.rb:278:in `sync_inheriting_filters'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/callbacks.rb:428:in `block in make_lambda'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/callbacks.rb:238:in `block in halting_and_conditional'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/callbacks.rb:517:in `block in invoke_after'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/callbacks.rb:517:in `each'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/callbacks.rb:517:in `invoke_after'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/callbacks.rb:136:in `run_callbacks'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/callbacks.rb:825:in `_run_save_callbacks'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/callbacks.rb:327:in `create_or_update'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/timestamp.rb:128:in `create_or_update'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/persistence.rb:503:in `save!'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/validations.rb:53:in `save!'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/transactions.rb:318:in `block in save!'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/transactions.rb:375:in `block in with_transaction_returning_status'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract/database_statements.rb:280:in `block in transaction'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract/transaction.rb:280:in `block in within_new_transaction'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:26:in `block (2 levels) in synchronize'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract/transaction.rb:278:in `within_new_transaction'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract/database_statements.rb:280:in `transaction'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/transactions.rb:212:in `transaction'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/transactions.rb:366:in `with_transaction_returning_status'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/transactions.rb:318:in `save!'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/suppressor.rb:48:in `save!'
 | /usr/share/foreman/app/models/role.rb:209:in `add_permissions!'
 | /usr/share/foreman/app/registries/foreman/plugin/rbac_support.rb:102:in `block (3 levels) in include_permissions_for_role'
 | /usr/share/foreman/app/models/concerns/authorizable.rb:103:in `skip_permission_check'
 | /usr/share/foreman/app/registries/foreman/plugin/rbac_support.rb:101:in `block (2 levels) in include_permissions_for_role'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/audited-4.9.0/lib/audited/auditor.rb:376:in `without_auditing'
 | /usr/share/foreman/app/registries/foreman/plugin/rbac_support.rb:98:in `block in include_permissions_for_role'
 | /usr/share/foreman/app/models/role.rb:237:in `ignore_locking'
 | /usr/share/foreman/app/registries/foreman/plugin/rbac_support.rb:97:in `include_permissions_for_role'
 | /usr/share/foreman/app/registries/foreman/plugin/rbac_support.rb:36:in `block in add_permissions_to_default_roles'
 | /usr/share/foreman/app/registries/foreman/plugin/rbac_support.rb:32:in `each'
 | /usr/share/foreman/app/registries/foreman/plugin/rbac_support.rb:32:in `add_permissions_to_default_roles'
 | /usr/share/foreman/app/registries/foreman/plugin.rb:403:in `block (2 levels) in add_permissions_to_default_roles'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/audited-4.9.0/lib/audited/auditor.rb:376:in `without_auditing'
 | /usr/share/foreman/app/registries/foreman/plugin.rb:402:in `block in add_permissions_to_default_roles'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/audited-4.9.0/lib/audited/auditor.rb:376:in `without_auditing'
 | /usr/share/foreman/app/registries/foreman/plugin.rb:401:in `add_permissions_to_default_roles'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_remote_execution-5.0.5/lib/foreman_remote_execution/engine.rb:218:in `block (2 levels) in <class:Engine>'
 | /usr/share/foreman/app/registries/foreman/plugin.rb:107:in `instance_eval'
 | /usr/share/foreman/app/registries/foreman/plugin.rb:107:in `register'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_remote_execution-5.0.5/lib/foreman_remote_execution/engine.rb:49:in `block in <class:Engine>'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/railties-6.0.3.7/lib/rails/initializable.rb:32:in `instance_exec'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/railties-6.0.3.7/lib/rails/initializable.rb:32:in `run'
 | /usr/share/foreman/config/initializers/0_print_time_spent.rb:45:in `block in run'
 | /usr/share/foreman/config/initializers/0_print_time_spent.rb:17:in `benchmark'
 | /usr/share/foreman/config/initializers/0_print_time_spent.rb:45:in `run'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/railties-6.0.3.7/lib/rails/initializable.rb:61:in `block in run_initializers'
 | /opt/rh/rh-ruby27/root/usr/share/ruby/tsort.rb:228:in `block in tsort_each'
 | /opt/rh/rh-ruby27/root/usr/share/ruby/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
 | /opt/rh/rh-ruby27/root/usr/share/ruby/tsort.rb:422:in `block (2 levels) in each_strongly_connected_component_from'
 | /opt/rh/rh-ruby27/root/usr/share/ruby/tsort.rb:431:in `each_strongly_connected_component_from'
 | /opt/rh/rh-ruby27/root/usr/share/ruby/tsort.rb:421:in `block in each_strongly_connected_component_from'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/railties-6.0.3.7/lib/rails/initializable.rb:50:in `each'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/railties-6.0.3.7/lib/rails/initializable.rb:50:in `tsort_each_child'
 | /opt/rh/rh-ruby27/root/usr/share/ruby/tsort.rb:415:in `call'
 | /opt/rh/rh-ruby27/root/usr/share/ruby/tsort.rb:415:in `each_strongly_connected_component_from'
 | /opt/rh/rh-ruby27/root/usr/share/ruby/tsort.rb:349:in `block in each_strongly_connected_component'
 | /opt/rh/rh-ruby27/root/usr/share/ruby/tsort.rb:347:in `each'
 | /opt/rh/rh-ruby27/root/usr/share/ruby/tsort.rb:347:in `call'
 | /opt/rh/rh-ruby27/root/usr/share/ruby/tsort.rb:347:in `each_strongly_connected_component'
 | /opt/rh/rh-ruby27/root/usr/share/ruby/tsort.rb:226:in `tsort_each'
 | /opt/rh/rh-ruby27/root/usr/share/ruby/tsort.rb:205:in `tsort_each'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/railties-6.0.3.7/lib/rails/initializable.rb:60:in `run_initializers'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/railties-6.0.3.7/lib/rails/application.rb:363:in `initialize!'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/railties-6.0.3.7/lib/rails/railtie.rb:190:in `public_send'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/railties-6.0.3.7/lib/rails/railtie.rb:190:in `method_missing'
 | /usr/share/foreman/config/environment.rb:5:in `<top (required)>'
 | /opt/rh/rh-ruby27/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:83:in `require'
 | /opt/rh/rh-ruby27/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:83:in `require'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/railties-6.0.3.7/lib/rails/application.rb:339:in `require_environment!'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/railties-6.0.3.7/lib/rails/application.rb:523:in `block in run_tasks_blocks'
 | /opt/rh/rh-ruby27/root/usr/share/gems/gems/rake-13.0.1/lib/rake/task.rb:281:in `block in execute'
 | /opt/rh/rh-ruby27/root/usr/share/gems/gems/rake-13.0.1/lib/rake/task.rb:281:in `each'
 | /opt/rh/rh-ruby27/root/usr/share/gems/gems/rake-13.0.1/lib/rake/task.rb:281:in `execute'
 | /opt/rh/rh-ruby27/root/usr/share/gems/gems/rake-13.0.1/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
 | /opt/rh/rh-ruby27/root/usr/share/gems/gems/rake-13.0.1/lib/rake/task.rb:199:in `synchronize'
 | /opt/rh/rh-ruby27/root/usr/share/gems/gems/rake-13.0.1/lib/rake/task.rb:199:in `invoke_with_call_chain'
 | /opt/rh/rh-ruby27/root/usr/share/gems/gems/rake-13.0.1/lib/rake/task.rb:243:in `block in invoke_prerequisites'
 | /opt/rh/rh-ruby27/root/usr/share/gems/gems/rake-13.0.1/lib/rake/task.rb:241:in `each'
 | /opt/rh/rh-ruby27/root/usr/share/gems/gems/rake-13.0.1/lib/rake/task.rb:241:in `invoke_prerequisites'
 | /opt/rh/rh-ruby27/root/usr/share/gems/gems/rake-13.0.1/lib/rake/task.rb:218:in `block in invoke_with_call_chain'
 | /opt/rh/rh-ruby27/root/usr/share/gems/gems/rake-13.0.1/lib/rake/task.rb:199:in `synchronize'
 | /opt/rh/rh-ruby27/root/usr/share/gems/gems/rake-13.0.1/lib/rake/task.rb:199:in `invoke_with_call_chain'
 | /opt/rh/rh-ruby27/root/usr/share/gems/gems/rake-13.0.1/lib/rake/task.rb:188:in `invoke'
 | /opt/rh/rh-ruby27/root/usr/share/gems/gems/rake-13.0.1/lib/rake/application.rb:160:in `invoke_task'
 | /opt/rh/rh-ruby27/root/usr/share/gems/gems/rake-13.0.1/lib/rake/application.rb:116:in `block (2 levels) in top_level'
 | /opt/rh/rh-ruby27/root/usr/share/gems/gems/rake-13.0.1/lib/rake/application.rb:116:in `each'
 | /opt/rh/rh-ruby27/root/usr/share/gems/gems/rake-13.0.1/lib/rake/application.rb:116:in `block in top_level'
 | /opt/rh/rh-ruby27/root/usr/share/gems/gems/rake-13.0.1/lib/rake/application.rb:125:in `run_with_threads'
 | /opt/rh/rh-ruby27/root/usr/share/gems/gems/rake-13.0.1/lib/rake/application.rb:110:in `top_level'
 | /opt/rh/rh-ruby27/root/usr/share/gems/gems/rake-13.0.1/lib/rake/application.rb:83:in `block in run'
 | /opt/rh/rh-ruby27/root/usr/share/gems/gems/rake-13.0.1/lib/rake/application.rb:186:in `standard_exception_handling'
 | /opt/rh/rh-ruby27/root/usr/share/gems/gems/rake-13.0.1/lib/rake/application.rb:80:in `run'
 | /opt/rh/rh-ruby27/root/usr/share/gems/gems/rake-13.0.1/exe/rake:27:in `<top (required)>'
 | /opt/rh/rh-ruby27/root/usr/bin/rake:23:in `load'
 | /opt/rh/rh-ruby27/root/usr/bin/rake:23:in `<main>'

This is harmless. It seems your database still contains some data from trends, which was extracted to the plugin long time ago. It may be some permissions in custome roles. I actually see some permissions like this too on my setup. You can check that via console

foreman-rake console
Permission.where(:resource_type => 'Trend')
Permission.where(:resource_type => 'Trend').map(&:filterings)

We no longer seed them, but it seems we didn’t cleaned them after the extraction.

if you want to proceed further, make a DB backup at this point

You can delete them from console by

Permission.where(:resource_type => 'Trend').map(&:destroy)

This can leave Filters without any filterings, to get rid of those:

Filter.all.each {|f| f.destroy if f.filterings.empty? }

If you instead want to use Trends, just install the afformentioned plugin.

1 Like

Thanks. I can make a snapshot of my vm before changing. I don’t use the plugin.

However, what might go wrong with deleting those, or better: how do I know afterwards it’s working O.K. and no damage is done?

Well, the backup is rather for the case, something goes wrong and you delete some more permissions than expected. If you see non-admin users not being able to achieve/perform things they did before, that would be an issue. But I actually think the commands above are quite safe :slight_smile: If it worked, you should not see the logs anymore.

O.K. Cleaned it up. I have seen no issues and got no complaints…