Skip to content

Commit

Permalink
Fixes #20661 - use separate queue for rex jobs (#330)
Browse files Browse the repository at this point in the history
  • Loading branch information
iNecas authored and adamruzicka committed Apr 25, 2018
1 parent 4b4bb45 commit bd6e83f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
4 changes: 4 additions & 0 deletions app/lib/actions/remote_execution/run_host_job.rb
Expand Up @@ -7,6 +7,10 @@ class RunHostJob < Actions::EntryAction
middleware.do_not_use Dynflow::Middleware::Common::Transaction
middleware.use Actions::Middleware::HideSecrets

def queue
ForemanRemoteExecution::DYNFLOW_QUEUE
end

def resource_locks
:link
end
Expand Down
4 changes: 4 additions & 0 deletions app/lib/actions/remote_execution/run_hosts_job.rb
Expand Up @@ -8,6 +8,10 @@ class RunHostsJob < Actions::ActionWithSubPlans
middleware.use Actions::Middleware::BindJobInvocation
middleware.use Actions::Middleware::RecurringLogic

def queue
ForemanRemoteExecution::DYNFLOW_QUEUE
end

def delay(delay_options, job_invocation)
task.add_missing_task_groups(job_invocation.task_group)
job_invocation.targeting.resolve_hosts! if job_invocation.targeting.static? && !job_invocation.targeting.resolved?
Expand Down
10 changes: 7 additions & 3 deletions app/models/setting/remote_execution.rb
Expand Up @@ -2,7 +2,7 @@ class Setting::RemoteExecution < Setting

::Setting::BLANK_ATTRS.concat %w{remote_execution_ssh_password remote_execution_ssh_key_passphrase}

# rubocop:disable Metrics/MethodLength
# rubocop:disable Metrics/MethodLength,Metrics/AbcSize
def self.load_defaults
# Check the table exists
return unless super
Expand Down Expand Up @@ -63,12 +63,16 @@ def self.load_defaults
nil,
N_('Default SSH key passphrase'),
nil,
{ :encrypted => true })
{ :encrypted => true }),
self.set('remote_execution_workers_pool_size',
N_('Amount of workers in the pool to handle the execution of the remote execution jobs. Restart of the dynflowd/foreman-tasks service is required.'),
5,
N_('Workers pool size'))
].each { |s| self.create! s.update(:category => 'Setting::RemoteExecution') }
end

true
end
# rubocop:enable AbcSize
# rubocop:enable Metrics/MethodLength
# rubocop:enable Metrics/MethodLength,Metrics/AbcSize
end
3 changes: 3 additions & 0 deletions lib/foreman_remote_execution/engine.rb
@@ -1,6 +1,8 @@
require 'foreman_remote_execution_core'

module ForemanRemoteExecution
DYNFLOW_QUEUE = :remote_execution

class Engine < ::Rails::Engine
engine_name 'foreman_remote_execution'

Expand All @@ -26,6 +28,7 @@ class Engine < ::Rails::Engine

initializer 'foreman_remote_execution.require_dynflow', :before => 'foreman_tasks.initialize_dynflow' do |app|
ForemanTasks.dynflow.require!
ForemanTasks.dynflow.config.queues.add(DYNFLOW_QUEUE, :pool_size => Setting['remote_execution_workers_pool_size']) if Setting.table_exists? rescue(false)
ForemanTasks.dynflow.config.eager_load_paths << File.join(ForemanRemoteExecution::Engine.root, 'app/lib/actions')
end

Expand Down

0 comments on commit bd6e83f

Please sign in to comment.