Skip to content

Commit

Permalink
Fixes #26352 - ActiveJob task arguments loading
Browse files Browse the repository at this point in the history
  • Loading branch information
ezr-ondrej authored and iNecas committed Mar 15, 2019
1 parent 073d5a9 commit c505485
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
21 changes: 14 additions & 7 deletions app/models/foreman_tasks/task/dynflow_task.rb
Expand Up @@ -83,7 +83,7 @@ def label
end

def input
return execution_plan_action.input['job_arguments'] if active_job?
return active_job_data['arguments'] if active_job?
main_action.task_input if main_action.respond_to?(:task_input)
end

Expand Down Expand Up @@ -113,12 +113,8 @@ def cli_example
def main_action
return @main_action if defined?(@main_action)
if active_job?
args = if execution_plan.delay_record
execution_plan.delay_record.args.first
else
execution_plan_action.input
end
@main_action = active_job_action(args['job_class'], args['job_arguments'])
job_data = active_job_data
@main_action = active_job_action(job_data['job_class'], job_data['arguments'])
else
@main_action = execution_plan && execution_plan.root_plan_step.try(:action, execution_plan)
end
Expand All @@ -140,6 +136,17 @@ def active_job?
execution_plan_action.class == ::Dynflow::ActiveJob::QueueAdapters::JobWrapper
end

def active_job_data
args = if execution_plan.delay_record
execution_plan.delay_record.args.first
else
execution_plan_action.input
end
return args['job_data'] if args.key?('job_data')
# For dynflow <= 1.2.1
{ 'job_class' => args['job_class'], 'arguments' => args['job_arguments'] }
end

def execution_plan_action
execution_plan.root_plan_step.action(execution_plan)
end
Expand Down
2 changes: 1 addition & 1 deletion foreman-tasks.gemspec
Expand Up @@ -29,7 +29,7 @@ same resource. It also optionally provides Dynflow infrastructure for using it f
s.extra_rdoc_files = Dir['README*', 'LICENSE']

s.add_dependency "foreman-tasks-core"
s.add_dependency "dynflow", '>= 1.2.1'
s.add_dependency "dynflow", '>= 1.2.2'
s.add_dependency "sinatra" # for Dynflow web console
s.add_dependency "parse-cron", '~> 0.1.4'
s.add_dependency "get_process_mem" # for memory polling
Expand Down

0 comments on commit c505485

Please sign in to comment.