summaryrefslogtreecommitdiff
path: root/exterminate-jobs-whose-minion-is-lost
blob: 4e9ff017e450f902ae00a660c88d833ee5f48dfe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/sh
#
# Sometimes a MINION dies and never tells WEBAPP that a job is
# finished. This makes the list of jobs grow to max size, which
# stops WEBAPP from scheduling more jobs to run. This scripts
# EXTERMINATEs such jobs. Do NOT run it casually, you MUST check
# that it is OK to EXTERMINATE the job first. Davros has spoken.
#
# This is a STOPGAP until Lorry Controller deals with this
# automatically.

# Not using -e so that curl failing won't stop things. curl may
# fail if the job isn't in the expected state. We want to
# EXTERMINATE it anyway.
set -u

for jobid in "$@"
do
	curl -s -X POST --data "job_id=$jobid" http://localhost:12765/1.0/stop-job
	curl -s -X POST --data "job_id=$jobid&exit=125&stdout=&stderr=" http://localhost:12765/1.0/job-update
	curl -s -X POST --data "job_id=$jobid" http://localhost:12765/1.0/remove-job
done > /dev/null