Unable to open Foreman settings - error displayed

Problem:
When I press on “Administer - Settings” Foreman displays error -
**Oops, we're sorry but something went wrong undefined method** templates_by_kind’ for ProvisioningTemplate:Class Did you mean? template_ids_for`

Expected outcome:
Settings menu opened

Foreman and Proxy versions:
Foreman and Proxy version: 3.10.0

Foreman and Proxy plugin versions:
Plugins:

  • foreman-tasks 9.1.1
  • foreman_fog_proxmox 0.15.0
  • foreman_openscap 7.1.1
  • foreman_puppet 6.2.0
  • foreman_remote_execution 13.0.0
  • foreman_rescue 4.0.0
  • katello 4.12.0
  • puppetdb_foreman 6.0.2

Distribution and version:
CentOS Stream release 9
Linux 5.14.0-446.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Fri May 3 16:10:18 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

Other relevant data:

foreman-rake errors:fetch_log request_id=7ad36480
Foreman version: 3.10.0
Plugins: 
 - foreman-tasks 9.1.1
 - foreman_fog_proxmox 0.15.0
 - foreman_openscap 7.1.1
 - foreman_puppet 6.2.0
 - foreman_remote_execution 13.0.0
 - foreman_rescue 4.0.0
 - katello 4.12.0
 - puppetdb_foreman 6.0.2

2024-05-17T14:51:39 [I|app|7ad36480] Started GET "/settings" for 10.10.10.2 at 2024-05-17 14:51:39 +0300
2024-05-17T14:51:39 [I|app|7ad36480] Processing by SettingsController#index as HTML
2024-05-17T14:51:39 [I|app|7ad36480]   Rendered settings/index.html.erb within layouts/application (Duration: 167.4ms | Allocations: 27065)
2024-05-17T14:51:39 [I|app|7ad36480]   Rendered layout layouts/application.html.erb (Duration: 167.9ms | Allocations: 27151)
2024-05-17T14:51:39 [W|app|7ad36480] undefined method `templates_by_kind' for ProvisioningTemplate:Class
 7ad36480 | Did you mean?  template_ids_for
2024-05-17T14:51:39 [I|app|7ad36480] Backtrace for 'undefined method `templates_by_kind' for ProvisioningTemplate:Class
 7ad36480 | Did you mean?  template_ids_for' error (ActionView::Template::Error): undefined method `templates_by_kind' for ProvisioningTemplate:Class
 7ad36480 | Did you mean?  template_ids_for
 7ad36480 | /usr/share/gems/gems/activerecord-6.1.7.7/lib/active_record/dynamic_matchers.rb:22:in `method_missing'
 7ad36480 | /usr/share/gems/gems/foreman_rescue-4.0.0/lib/foreman_rescue/engine.rb:28:in `block (5 levels) in <class:Engine>'
 7ad36480 | /usr/share/foreman/app/services/setting_select_collection.rb:18:in `collection_for'
 7ad36480 | /usr/share/foreman/app/presenters/setting_presenter.rb:112:in `select_values'
 7ad36480 | /usr/share/foreman/app/helpers/settings_helper.rb:17:in `setting_to_hash'
 7ad36480 | /usr/share/foreman/app/helpers/settings_helper.rb:3:in `block in grouped_settings'
 7ad36480 | /usr/share/foreman/app/services/setting_registry.rb:72:in `each'
 7ad36480 | /usr/share/foreman/app/services/setting_registry.rb:72:in `each'
 7ad36480 | /usr/share/foreman/app/helpers/settings_helper.rb:3:in `map'
 7ad36480 | /usr/share/foreman/app/helpers/settings_helper.rb:3:in `grouped_settings'
 7ad36480 | /usr/share/foreman/app/views/settings/index.html.erb:4:in `_app_views_settings_index_html_erb__650195388708158845_120500'
 7ad36480 | /usr/share/gems/gems/actionview-6.1.7.7/lib/action_view/base.rb:247:in `public_send'
 7ad36480 | /usr/share/gems/gems/actionview-6.1.7.7/lib/action_view/base.rb:247:in `_run'
 7ad36480 | /usr/share/gems/gems/actionview-6.1.7.7/lib/action_view/template.rb:154:in `block in render'
 7ad36480 | /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/notifications.rb:205:in `instrument'
 7ad36480 | /usr/share/gems/gems/actionview-6.1.7.7/lib/action_view/template.rb:345:in `instrument_render_template'
 7ad36480 | /usr/share/gems/gems/actionview-6.1.7.7/lib/action_view/template.rb:152:in `render'
 7ad36480 | /usr/share/gems/gems/actionview-6.1.7.7/lib/action_view/renderer/template_renderer.rb:61:in `block (2 levels) in render_template'
 7ad36480 | /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/notifications.rb:203:in `block in instrument'
 7ad36480 | /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
 7ad36480 | /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/notifications.rb:203:in `instrument'
 7ad36480 | /usr/share/gems/gems/actionview-6.1.7.7/lib/action_view/renderer/template_renderer.rb:56:in `block in render_template'
 7ad36480 | /usr/share/gems/gems/actionview-6.1.7.7/lib/action_view/renderer/template_renderer.rb:71:in `block in render_with_layout'
 7ad36480 | /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/notifications.rb:203:in `block in instrument'
 7ad36480 | /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
 7ad36480 | /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/notifications.rb:203:in `instrument'
 7ad36480 | /usr/share/gems/gems/actionview-6.1.7.7/lib/action_view/renderer/template_renderer.rb:70:in `render_with_layout'
 7ad36480 | /usr/share/gems/gems/actionview-6.1.7.7/lib/action_view/renderer/template_renderer.rb:55:in `render_template'
 7ad36480 | /usr/share/gems/gems/actionview-6.1.7.7/lib/action_view/renderer/template_renderer.rb:11:in `render'
 7ad36480 | /usr/share/gems/gems/actionview-6.1.7.7/lib/action_view/renderer/renderer.rb:61:in `render_template_to_object'
 7ad36480 | /usr/share/gems/gems/actionview-6.1.7.7/lib/action_view/renderer/renderer.rb:29:in `render_to_object'
 7ad36480 | /usr/share/gems/gems/actionview-6.1.7.7/lib/action_view/rendering.rb:117:in `block in _render_template'
 7ad36480 | /usr/share/gems/gems/actionview-6.1.7.7/lib/action_view/base.rb:273:in `in_rendering_context'
 7ad36480 | /usr/share/gems/gems/actionview-6.1.7.7/lib/action_view/rendering.rb:116:in `_render_template'
 7ad36480 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_controller/metal/streaming.rb:218:in `_render_template'
 7ad36480 | /usr/share/gems/gems/actionview-6.1.7.7/lib/action_view/rendering.rb:103:in `render_to_body'
 7ad36480 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_controller/metal/rendering.rb:52:in `render_to_body'
 7ad36480 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_controller/metal/renderers.rb:142:in `render_to_body'
 7ad36480 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/abstract_controller/rendering.rb:25:in `render'
 7ad36480 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_controller/metal/rendering.rb:36:in `render'
 7ad36480 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_controller/metal/instrumentation.rb:46:in `block (2 levels) in render'
 7ad36480 | /usr/share/ruby/benchmark.rb:308:in `realtime'
 7ad36480 | /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/core_ext/benchmark.rb:14:in `ms'
 7ad36480 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_controller/metal/instrumentation.rb:46:in `block in render'
 7ad36480 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_controller/metal/instrumentation.rb:86:in `cleanup_view_runtime'
 7ad36480 | /usr/share/gems/gems/activerecord-6.1.7.7/lib/active_record/railties/controller_runtime.rb:34:in `cleanup_view_runtime'
 7ad36480 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_controller/metal/instrumentation.rb:45:in `render'
 7ad36480 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_controller/metal/implicit_render.rb:35:in `default_render'
 7ad36480 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_controller/metal/basic_implicit_render.rb:6:in `block in send_action'
 7ad36480 | <internal:kernel>:90:in `tap'
 7ad36480 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
 7ad36480 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/abstract_controller/base.rb:228:in `process_action'
 7ad36480 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_controller/metal/rendering.rb:30:in `process_action'
 7ad36480 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/abstract_controller/callbacks.rb:42:in `block in process_action'
 7ad36480 | /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/callbacks.rb:117:in `block in run_callbacks'
 7ad36480 | /usr/share/foreman/app/controllers/concerns/foreman/controller/timezone.rb:10:in `set_timezone'
 7ad36480 | /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/callbacks.rb:126:in `block in run_callbacks'
 7ad36480 | /usr/share/foreman/app/models/concerns/foreman/thread_session.rb:32:in `clear_thread'
 7ad36480 | /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/callbacks.rb:126:in `block in run_callbacks'
 7ad36480 | /usr/share/foreman/app/controllers/concerns/foreman/controller/topbar_sweeper.rb:12:in `set_topbar_sweeper_controller'
 7ad36480 | /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/callbacks.rb:126:in `block in run_callbacks'
 7ad36480 | /usr/share/gems/gems/audited-5.4.3/lib/audited/sweeper.rb:16:in `around'
 7ad36480 | /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/callbacks.rb:126:in `block in run_callbacks'
 7ad36480 | /usr/share/gems/gems/audited-5.4.3/lib/audited/sweeper.rb:16:in `around'
 7ad36480 | /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/callbacks.rb:126:in `block in run_callbacks'
 7ad36480 | /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/callbacks.rb:137:in `run_callbacks'
 7ad36480 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/abstract_controller/callbacks.rb:41:in `process_action'
 7ad36480 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_controller/metal/rescue.rb:22:in `process_action'
 7ad36480 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_controller/metal/instrumentation.rb:34:in `block in process_action'
 7ad36480 | /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/notifications.rb:203:in `block in instrument'
 7ad36480 | /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
 7ad36480 | /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/notifications.rb:203:in `instrument'
 7ad36480 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_controller/metal/instrumentation.rb:33:in `process_action'
 7ad36480 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_controller/metal/params_wrapper.rb:249:in `process_action'
 7ad36480 | /usr/share/gems/gems/activerecord-6.1.7.7/lib/active_record/railties/controller_runtime.rb:27:in `process_action'
 7ad36480 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/abstract_controller/base.rb:165:in `process'
 7ad36480 | /usr/share/gems/gems/actionview-6.1.7.7/lib/action_view/rendering.rb:39:in `process'
 7ad36480 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_controller/metal.rb:190:in `dispatch'
 7ad36480 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_controller/metal.rb:254:in `dispatch'
 7ad36480 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_dispatch/routing/route_set.rb:50:in `dispatch'
 7ad36480 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_dispatch/routing/route_set.rb:33:in `serve'
 7ad36480 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_dispatch/journey/router.rb:50:in `block in serve'
 7ad36480 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_dispatch/journey/router.rb:32:in `each'
 7ad36480 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_dispatch/journey/router.rb:32:in `serve'
 7ad36480 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_dispatch/routing/route_set.rb:842:in `call'
 7ad36480 | /usr/share/gems/gems/katello-4.12.0/lib/katello/middleware/organization_created_enforcer.rb:18:in `call'
 7ad36480 | /usr/share/gems/gems/katello-4.12.0/lib/katello/middleware/event_daemon.rb:10:in `call'
 7ad36480 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_dispatch/middleware/static.rb:24:in `call'
 7ad36480 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_dispatch/middleware/static.rb:24:in `call'
 7ad36480 | /usr/share/gems/gems/apipie-dsl-2.6.2/lib/apipie_dsl/static_dispatcher.rb:67:in `call'
 7ad36480 | /usr/share/gems/gems/apipie-rails-1.3.0/lib/apipie/static_dispatcher.rb:74:in `call'
 7ad36480 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_dispatch/middleware/static.rb:24:in `call'
 7ad36480 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_dispatch/middleware/static.rb:24:in `call'
 7ad36480 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_dispatch/middleware/static.rb:24:in `call'
 7ad36480 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_dispatch/middleware/static.rb:24:in `call'
 7ad36480 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_dispatch/middleware/static.rb:24:in `call'
 7ad36480 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_dispatch/middleware/static.rb:24:in `call'
 7ad36480 | /usr/share/foreman/lib/foreman/middleware/libvirt_connection_cleaner.rb:9:in `call'
 7ad36480 | /usr/share/foreman/lib/foreman/middleware/telemetry.rb:10:in `call'
 7ad36480 | /usr/share/gems/gems/apipie-rails-1.3.0/lib/apipie/middleware/checksum_in_headers.rb:27:in `call'
 7ad36480 | /usr/share/gems/gems/rack-2.2.8/lib/rack/tempfile_reaper.rb:15:in `call'
 7ad36480 | /usr/share/gems/gems/rack-2.2.8/lib/rack/etag.rb:27:in `call'
 7ad36480 | /usr/share/gems/gems/rack-2.2.8/lib/rack/conditional_get.rb:27:in `call'
 7ad36480 | /usr/share/gems/gems/rack-2.2.8/lib/rack/head.rb:12:in `call'
 7ad36480 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_dispatch/http/permissions_policy.rb:22:in `call'
 7ad36480 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_dispatch/http/content_security_policy.rb:19:in `call'
 7ad36480 | /usr/share/foreman/lib/foreman/middleware/logging_context_session.rb:22:in `call'
 7ad36480 | /usr/share/gems/gems/rack-2.2.8/lib/rack/session/abstract/id.rb:266:in `context'
 7ad36480 | /usr/share/gems/gems/rack-2.2.8/lib/rack/session/abstract/id.rb:260:in `call'
 7ad36480 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_dispatch/middleware/cookies.rb:697:in `call'
 7ad36480 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_dispatch/middleware/callbacks.rb:27:in `block in call'
 7ad36480 | /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/callbacks.rb:98:in `run_callbacks'
 7ad36480 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_dispatch/middleware/callbacks.rb:26:in `call'
 7ad36480 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_dispatch/middleware/actionable_exceptions.rb:18:in `call'
 7ad36480 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_dispatch/middleware/debug_exceptions.rb:29:in `call'
 7ad36480 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
 7ad36480 | /usr/share/gems/gems/railties-6.1.7.7/lib/rails/rack/logger.rb:37:in `call_app'
 7ad36480 | /usr/share/gems/gems/railties-6.1.7.7/lib/rails/rack/logger.rb:28:in `call'
 7ad36480 | /usr/share/gems/gems/sprockets-rails-3.4.2/lib/sprockets/rails/quiet_assets.rb:13:in `call'
 7ad36480 | /usr/share/foreman/lib/foreman/middleware/logging_context_request.rb:11:in `call'
 7ad36480 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
 7ad36480 | /usr/share/gems/gems/request_store-1.6.0/lib/request_store/middleware.rb:19:in `call'
 7ad36480 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_dispatch/middleware/request_id.rb:26:in `call'
 7ad36480 | /usr/share/gems/gems/katello-4.12.0/lib/katello/prevent_json_parsing.rb:12:in `call'
 7ad36480 | /usr/share/gems/gems/rack-2.2.8/lib/rack/method_override.rb:24:in `call'
 7ad36480 | /usr/share/gems/gems/rack-2.2.8/lib/rack/runtime.rb:22:in `call'
 7ad36480 | /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
 7ad36480 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_dispatch/middleware/executor.rb:14:in `call'
 7ad36480 | /usr/share/gems/gems/rack-2.2.8/lib/rack/sendfile.rb:110:in `call'
 7ad36480 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_dispatch/middleware/ssl.rb:77:in `call'
 7ad36480 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_dispatch/middleware/host_authorization.rb:142:in `call'
 7ad36480 | /usr/share/gems/gems/secure_headers-6.5.0/lib/secure_headers/middleware.rb:11:in `call'
 7ad36480 | /usr/share/gems/gems/railties-6.1.7.7/lib/rails/engine.rb:539:in `call'
 7ad36480 | /usr/share/gems/gems/railties-6.1.7.7/lib/rails/railtie.rb:207:in `public_send'
 7ad36480 | /usr/share/gems/gems/railties-6.1.7.7/lib/rails/railtie.rb:207:in `method_missing'
 7ad36480 | /usr/share/gems/gems/rack-2.2.8/lib/rack/urlmap.rb:74:in `block in call'
 7ad36480 | /usr/share/gems/gems/rack-2.2.8/lib/rack/urlmap.rb:58:in `each'
 7ad36480 | /usr/share/gems/gems/rack-2.2.8/lib/rack/urlmap.rb:58:in `call'
 7ad36480 | /usr/share/gems/gems/puma-6.4.2/lib/puma/configuration.rb:272:in `call'
 7ad36480 | /usr/share/gems/gems/puma-6.4.2/lib/puma/request.rb:100:in `block in handle_request'
 7ad36480 | /usr/share/gems/gems/puma-6.4.2/lib/puma/thread_pool.rb:378:in `with_force_shutdown'
 7ad36480 | /usr/share/gems/gems/puma-6.4.2/lib/puma/request.rb:99:in `handle_request'
 7ad36480 | /usr/share/gems/gems/puma-6.4.2/lib/puma/server.rb:464:in `process_client'
 7ad36480 | /usr/share/gems/gems/puma-6.4.2/lib/puma/server.rb:245:in `block in run'
 7ad36480 | /usr/share/gems/gems/puma-6.4.2/lib/puma/thread_pool.rb:155:in `block in spawn_thread'
 7ad36480 | /usr/share/gems/gems/logging-2.3.1/lib/logging/diagnostic_context.rb:474:in `block in create_with_logging_context'
2024-05-17T14:51:39 [I|app|7ad36480]   Rendered common/500.html.erb within layouts/application (Duration: 6.5ms | Allocations: 1285)
2024-05-17T14:51:39 [I|app|7ad36480]   Rendered layouts/base.html.erb (Duration: 10.4ms | Allocations: 2362)
2024-05-17T14:51:39 [I|app|7ad36480]   Rendered layout layouts/application.html.erb (Duration: 18.5ms | Allocations: 3950)
2024-05-17T14:51:39 [I|app|7ad36480] Completed 500 Internal Server Error in 237ms (Views: 20.3ms | ActiveRecord: 32.3ms | Allocations: 37014)

:eyes: @laugmanuel

Cause of problem
/usr/share/gems/gems/foreman_rescue-4.0.0/lib/foreman_rescue/engine.rb line 28

Tried solution, FAILED
foreman-installer -i
Disable foreman-rescue plugin

Expected result
Removal of foreman-rescue plugin

Actual result
foreman-rescue plugin remains in filesystem, problem not solved.

Working solution
Manual removal of foreman-rescue plugin via at first disabling plugin in foreman-installer and then removing it from filesystem manually:

sudo rm -rf /usr/share/gems/gems/foreman_rescue-4.0.0
sudo rm /usr/share/gems/specifications/foreman_rescue-4.0.0.gemspec
sudo rm /usr/share/foreman/bundler.d/foreman_rescue.rb
sudo reboot

Yes, i know, restarting services would have helped too. Just rebooting at this point was faster solution for me.

Sorry for the inconvenience…

I had a look at it and fixed it in: fixes error during settings rendering because method is not found by laugmanuel · Pull Request #28 · dm-drogeriemarkt/foreman_rescue · GitHub
As soon as it’s merged, I’ll prepare the required packaging PRs to get the fixed version into Foreman 3.9 / 3.10 and develop

foreman_rescue 4.0.1 was released and is now part of foreman develop.

Packaging for Foreman 3.9 and Foreman 3.10 is ongoing.

2 Likes

Packages are building and should hit the CDN in the next 10-15 minutes.

1 Like