(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
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.
Foreman's plugin registry is not a part of code reloading and that seems to be by design.
The reason for reloader.to_prepare is that application code is involved. One example is foreman-tasks:
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.