Skip to content

Instantly share code, notes, and snippets.

@iNecas
Created May 5, 2016 15:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iNecas/956a632dad781d9044408cf59c445a2d to your computer and use it in GitHub Desktop.
Save iNecas/956a632dad781d9044408cf59c445a2d to your computer and use it in GitHub Desktop.
resume_missing_pulp_task.rb
cat <<EOF | foreman-rake console
@world = ForemanTasks.dynflow.world
@persistence = @world.persistence
def reset_pulp_task(uuid)
execution_plan = @persistence.load_execution_plan(uuid)
raise 'execution plan #{execution_plan} is not paused' unless execution_plan.state == :paused
active_steps = execution_plan.steps_in_state(:running, :suspended, :error)
active_steps.each do |step|
action = step.action(execution_plan)
if action.output['pulp_tasks']
# delete a record about previous pulp tasks
action.output.delete('pulp_tasks')
puts "updating execution plan #{uuid} step #{step.id} action #{action.id}"
@persistence.save_action(execution_plan.id, action)
end
end
puts "resuming execution plan #{execution_plan.id}"
@world.execute(execution_plan.id)
end
reset_pulp_task('e038e0ae-4f3e-43c6-9d3d-3e40d3df8c15')
EOF
@pmoravec
Copy link

pmoravec commented May 6, 2016

Note the argument to reset_pulp_task is dynflow UUID, not foreman task UUID - one can get the dynflow UUID by accessing external_id of the foreman task.

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