So you’ve gotten yourself into a state where you have WAY more builds going on Builder than you meant to have and the number of waiting jobs is increasing exponentially…do not fear, some SQL and bash are here to save the day!
First, ssh into the builder live datastore node and get to a psql prompt as instructed in this wiki post.
Now, we can get a list of all the groups that are currently dispatching AND output the results of the query to a file in a single postgres command:
\COPY (select id from groups where group_state = 'Dispatching') To '/tmp/groups_to_cancel.csv' With CSV
Now, copy this script to your workstation:
#!/bin/bash list=$(cat $1) echo $1 for ident in $list; do hab bldr job cancel $ident done
Save it, let’s say I saved it as “cancel_script.sh”.
Now, invoke the script and pass it the file with the list of groups in it:
NOTE: You will need to confirm “Yes” for each group it cancels.
And watch the number of waiting jobs go down!