orhpaned_execution_plans_cleanup.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cat <<EOF | foreman-rake console | |
conf.return_format = "" | |
batch_size = 1000 | |
persistence = ForemanTasks.dynflow.world.persistence | |
adapter = persistence.adapter | |
plans_without_tasks = adapter.db.fetch("select dynflow_execution_plans.uuid from dynflow_execution_plans left join foreman_tasks_tasks on (dynflow_execution_plans.uuid = foreman_tasks_tasks.external_id) where foreman_tasks_tasks.id IS NULL") | |
deleted = 0 | |
total = plans_without_tasks.count | |
plans_without_tasks.all.map{|x| x[:uuid]}.in_groups_of(batch_size, false).each do |uuids| | |
delete_count = persistence.delete_execution_plans({ 'uuid' => uuids }, batch_size) | |
deleted += delete_count | |
puts "deleted #{deleted} out of #{total}" | |
end | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment