Skip to content

Instantly share code, notes, and snippets.

@jturel
Created May 18, 2025 20:03
Show Gist options
  • Save jturel/cd65c26f65a255fbb234b0e7c27dca07 to your computer and use it in GitHub Desktop.
Save jturel/cd65c26f65a255fbb234b0e7c27dca07 to your computer and use it in GitHub Desktop.
Foreman Plugin Registry Loading

Observations

One

(Some/all?) plugins call Foreman::Plugin.register in a reloader.to_prepare callback which could imply a few things:

  • this needs to happen on app startup
  • this needs to happen on code reload
  • this involves application code

Two

Plugin registration is not consistent across plugins. Katello calls Foreman::Plugin.register via a required file which won't be executed again on reload!. REX and Foreman Tasks do invoke register on dev code reload and that's why reload! is broken.

https://github.com/Katello/katello/blob/87dc8cfc18dedbea67c59233392a6528e14a979e/lib/katello/engine.rb#L85

https://github.com/theforeman/foreman-tasks/blob/2760a7a5fa212d9d160dc02c4251b9b496110031/lib/foreman_tasks/engine.rb#L21

Three

Foreman's plugin registry is not a part of code reloading and that seems to be by design.

Analysis

The reason for reloader.to_prepare is that application code is involved. One example is foreman-tasks:

https://github.com/theforeman/foreman-tasks/blob/2760a7a5fa212d9d160dc02c4251b9b496110031/lib/foreman_tasks/engine.rb#L129

extend_observable_events(::Dynflow::Action.descendants.select { |klass| klass <= ::Actions::ObservableAction }.map(&:namespaced_event_names))

::Actions::ObservableAction is under app/ and without being called from to_prepare, is an undefined constant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment