Sha256: ad953eb01c66c0bdbf052147dc7ee9b586abd10424385e9f0ea8fed076e8250d

Contents?: true

Size: 986 Bytes

Versions: 3

Compression:

Stored size: 986 Bytes

Contents

namespace :katello do
  desc "Cancels all running Pulp 2 to 3 migration tasks."
  task :pulp3_migration_abort => ["environment", "disable_dynflow"] do
    migration_tasks = ForemanTasks::Task::DynflowTask.where(:label => "Actions::Pulp3::ContentMigration").where.not(:state => ["stopped", "paused"])
    cancelled_tasks_count = 0
    migration_tasks.each do |task|
      cancelled_task = false
      task.execution_plan.steps.each do |_number, step|
        if step.cancellable? && step.is_a?(Dynflow::ExecutionPlan::Steps::RunStep)
          ::ForemanTasks.dynflow.world.event(task.execution_plan.id, step.id, Dynflow::Action::Cancellable::Cancel)
          cancelled_task = true
        end
      end
      if ::Katello::ContentMigrationProgress.where(:task_id => task.id).update_all(:canceled => true) > 0
        cancelled_task = true
      end
      cancelled_tasks_count += 1 if cancelled_task
    end

    puts _("\e[33mCancelled #{cancelled_tasks_count} tasks.\e[0m")
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
katello-3.18.1.1 lib/katello/tasks/pulp3_migration_abort.rake
katello-3.18.1 lib/katello/tasks/pulp3_migration_abort.rake
katello-3.18.0 lib/katello/tasks/pulp3_migration_abort.rake