Skip to content

Exit codes

submit and supervise

These two run the foreground supervisor, and their exit code reports how supervision ended.

Code Meaning
0 The job Succeeded and nothing is outstanding.
2 The job Failed (including give-up), and its escalation was delivered. The failure was printed.
3 The job was Cancelled.
4 The supervisor gave up on infrastructure: for longer than supervise.giveup (10 minutes by default) the record could not be read, or the loop made no progress, for example because the scheduler stayed unreachable. The job is left Unattended.
5 An outcome was reached, but something was still outstanding when the post-outcome wait ended.
6 The job is not supervised here: a newer dunscaith wrote cause kinds this build does not know. See Exit 6.
128 + n Ended by signal n after draining. SIGINT gives 130, SIGTERM 143, SIGHUP 129.
1 dunscaith itself failed.

Codes 2, 3 and 0 are the outcome. 4, 5 and the signal codes say supervision was cut short. 6 says this build left the job alone.

Exit 2 also means a wiring failure at startup

If dunscaith cannot even construct its command tree it exits 2 before running anything. That is a defect in the build, not a failed job. It prints a message to stderr, unlike a Failed job.

Which code wins

When more than one applies, the highest in this list is reported:

  1. A signal (128 + n)
  2. 6, not supervised here
  3. 4, the supervisor gave up
  4. 5, work outstanding
  5. The outcome's code (0, 2 or 3)

A Failed job with an object still stopping exits 5, and the outcome is printed above the exit.

The signal code is not an exit call. After the drain the process re-raises the signal and dies by it, which the shell reports as 128 + n. That holds during the post-outcome wait too: a signal there ends the wait and gives 128 + n, never 5. A drain that itself fails exits with that error's code instead.

Exit 5

Once the job has an outcome, the foreground supervisor keeps working for supervise.wait (two minutes by default) on whatever is left. It then prints what remains and exits 5. Outstanding means one or more of:

  • clean-up: objects of the job are still stopping on the scheduler;
  • escalation delivery: an escalation is undelivered, for example because the escalation command keeps failing. This applies whatever the outcome, so a Failed job whose escalation never reached your command exits 5, not 2;
  • settlement: an unmatched attempt or a foreign object is waiting for you to run abandon.

Run dunscaith reconcile, which carries it on from the current host's records, or dunscaith supervise <job>.

Exit 6

A newer dunscaith can record cause kinds this one does not know. This build reads such a job, shows it and cancels it, but does not supervise it while it can act on those kinds. submit and supervise print why on stderr and exit 6 without taking the job's lock, or after handing it back, so a newer supervisor can take it:

job 01J... is not supervised here: its recovery policy names cause kinds this build does not know: gpu-fault, hung; a dunscaith that knows them can supervise it, and `dunscaith cancel 01J...` ends it

There are two reasons:

  • The recovery policy names a kind this build does not know. It does not supervise the job until it has an outcome. A finished job is supervised as usual, since settling it reads no rule.
  • The execution ended with a kind this build cannot place. It records an unplaced: escalation, commits no outcome, and hands the job back. The job stays recovering until a newer dunscaith decides it, or you end it with cancel or give-up.

Run the job's supervision from a dunscaith that knows the kinds, or end the job. Until then, status, list and the Unattended notice every command prints on the owning host say the job needs a dunscaith that knows <kinds>, and do not suggest supervise.

Other reasons for exit 1

  • job <id> is already supervised: another supervisor holds the job's lock.
  • record settled without an outcome: the record is settled but names no outcome.
  • job file <name>: ...: the job file was refused, before anything was submitted.

All other commands

0 for success, 1 for any error, including a usage error such as an unknown flag.

reconcile exits 0 when the only jobs it could not reconcile are ones this build does not supervise (see Exit 6): it prints a warning for each and carries on. Any other failure beside them still exits 1, printed below the warnings.

A command that was forwarded to another host exits with the remote command's own status. If the remote command failed with status 1, you see forwarded command failed on <host> with status 1 and exit 1; any other status is passed through.

validate exits 0 when the job file is valid and 1 when it is refused, cannot be read, or the configured cluster's declarations refuse the job.

watch and status are ended by a signal like any other command. watch exits 0 when the job reaches an outcome, and 1 when its record is not there.

In a script

dunscaith submit job.yaml
case $? in
  0) echo succeeded ;;
  2) echo failed ;;
  3) echo cancelled ;;
  4) echo "gave up; job is unattended: run dunscaith supervise" ;;
  5) echo "outcome reached with work outstanding: run dunscaith reconcile" ;;
  6) echo "not supervised here: a newer dunscaith wrote cause kinds this one does not know" ;;
  1) echo "dunscaith error" ;;
  *) echo "ended by signal $(( $? - 128 ))" ;;
esac