8931: Fix indentation mistakes. Fix tests.
[arvados.git] / services / crunch-dispatch-slurm / crunch-finish-slurm.sh
index 8be6fdd9e0faae345e94b954356e2b65667ce777..95a37ba4ef4d37c3d7c26d639146d7920312834d 100755 (executable)
@@ -1,7 +1,20 @@
 #!/bin/sh
 
-jobid=$1
+# Script to be called by strigger when a job finishes.  This ensures the job
+# record has the correct state "Complete" even if the node running the job
+# failed.
 
-uuid=$(squeue --jobs=$jobid --states=all --format=%j --noheader)
+ARVADOS_API_HOST=$1
+ARVADOS_API_TOKEN=$2
+ARVADOS_API_HOST_INSECURE=$3
+uuid=$4
+jobid=$5
 
-arv containers update --uuid $uuid --container '{"state": "Completed"}'
+# If it is possible to attach metadata to job records we could look up the
+# above information instead of getting it on the command line.  For example,
+# this is the recipe for getting the job name (container uuid) from the job id.
+#uuid=$(squeue --jobs=$jobid --states=all --format=%j --noheader)
+
+export ARVADOS_API_HOST ARVADOS_API_TOKEN ARVADOS_API_HOST_INSECURE
+
+exec arv container update --uuid $uuid --container '{"state": "Complete"}'