Skip to content

Commit

Permalink
Fixes #15114 - initialize Katello plugin sooner (#6059)
Browse files Browse the repository at this point in the history
Initializing the Katello plugin too late causes issues when resuming
Dynflow tasks (for example the loggers not being initialized)

Foreman recommends before :finisher_hook as alternative hook to be used

https://github.com/theforeman/foreman/blob/1.11.0/config/initializers/assets_paths.rb#L17

Blocks theforeman/foreman-tasks#185
  • Loading branch information
iNecas authored and ehelms committed May 24, 2016
1 parent 117cfda commit 28cb3ef
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions lib/katello/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,22 @@ def find_assets(args = {})
require 'katello/apipie/validators'
end

initializer "katello.register_actions", :before => 'foreman_tasks.initialize_dynflow' do |_app|
# make sure the Katello plugin is initialized before `after_initialize`
# hook so that the resumed Dynflow tasks can rely on everything ready.
initializer 'katello.register_plugin', :before => :finisher_hook do
require 'katello/plugin'
require 'katello/permissions'
end

initializer "katello.register_actions", :before => :finisher_hook do |_app|
ForemanTasks.dynflow.require!
action_paths = %W(#{Katello::Engine.root}/app/lib/actions
#{Katello::Engine.root}/app/lib/headpin/actions
#{Katello::Engine.root}/app/lib/katello/actions)
ForemanTasks.dynflow.config.eager_load_paths.concat(action_paths)
end

initializer "katello.set_dynflow_middlewares", :before => 'foreman_tasks.initialize_dynflow' do |_app|
initializer "katello.set_dynflow_middlewares", :before => :finisher_hook do |_app|
# We don't enable this in test env, as it adds the new field into the actions input
# that we are not interested in tests
unless Rails.env.test?
Expand All @@ -105,7 +112,7 @@ def find_assets(args = {})
end
end

initializer "katello.initialize_cp_listener", after: "foreman_tasks.initialize_dynflow" do
initializer "katello.initialize_cp_listener", :before => :finisher_hook do
unless ForemanTasks.dynflow.config.remote? || File.basename($PROGRAM_NAME) == 'rake' || Rails.env.test?
ForemanTasks.dynflow.config.on_init do |world|
::Actions::Candlepin::ListenOnCandlepinEvents.ensure_running(world)
Expand Down Expand Up @@ -236,11 +243,6 @@ def find_assets(args = {})
load 'katello/repository_types.rb'
end

config.after_initialize do
require 'katello/plugin'
require 'katello/permissions'
end

rake_tasks do
load "#{Katello::Engine.root}/lib/katello/tasks/test.rake"
load "#{Katello::Engine.root}/lib/katello/tasks/jenkins.rake"
Expand Down

0 comments on commit 28cb3ef

Please sign in to comment.