How to cancel all pulp tasks on a Capsule or Satellite?
Environment
Red Hat Satellite or Capsule 6.9 or older
Issue
Invoked hundreds of pulp tasks on a Satellite or Capsule that we know they are redundant, is there an easy way to cancel all of them?
Resolution
This solution is applicable to 6.9 or older versions. For Satellite 6.10 or newer, please follow this solution.
-
First, cancel the
pulptasks themselves:pulpAdminPassword=$(grep ^default_password /etc/pulp/server.conf | cut -d' ' -f2) mongo pulp_database --eval "DBQuery.shellBatchSize = 1000000000; db.task_status.find({'state': {\$nin: [ 'finished', 'error', 'canceled' ]}}, {'task_id': 1, 'state': 1, '_id': 0})" | grep task_id | cut -d\" -f4 > tasks_to_delete.txt for taskid in $(cat tasks_to_delete.txt); do curl -ks -u admin:$pulpAdminPassword -X DELETE https://$(hostname -f)/pulp/api/v2/tasks/${taskid}/ echo done rm -f tasks_to_delete.txt -
Afterwards, optionally, remove messages with the tasks requests by removing the queue that keeps them (a service restart will re-create the queue safely):
for i in pulp_celerybeat pulp_resource_manager pulp_workers; do service $i stop; done qpid-config --ssl-certificate=/etc/pki/pulp/qpid/client.crt -b amqps://localhost:5671 del queue resource_manager --force for i in pulp_celerybeat pulp_resource_manager pulp_workers; do service $i start; done -
Apart from this, as the tasks were triggered by some Satellite task(s), it is worth canceling\cleaning them as well. It is recommended to follow this solution for the cleanup.
For more KB articles/solutions related to Red Hat Satellite 6.x Pulp 2.0 Issues, please refer to the Consolidated Troubleshooting Article for Red Hat Satellite 6.x Pulp 2.0-related Issues
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.