Attention une mise à jour du service Gitlab va être effectuée le mardi 30 novembre entre 17h30 et 18h00. Cette mise à jour va générer une interruption du service dont nous ne maîtrisons pas complètement la durée mais qui ne devrait pas excéder quelques minutes. Cette mise à jour intermédiaire en version 14.0.12 nous permettra de rapidement pouvoir mettre à votre disposition une version plus récente.

Commit 2cfd30b8 authored by BAIRE Anthony's avatar BAIRE Anthony
Browse files

update the job container command

- to have SIGTERM forwarded to the process
- to propagate the exit code of the process
parent 9a4b2818
......@@ -995,28 +995,47 @@ class JobManager(Manager):
# - no output is lost (we go though a pipe in case the
# app has multiple processes writing to stdout/stderr
# concurrently)
# FIXME: maybe ">>allgo.log 2>&1" is sufficent
# - we get the exit code of the app (not the exit code of
# cat)
# - we are failsafe (if fifo creation fails then the app
# is run anyway, with the exit code of cat)
# - we have no unusual dependencies (only sh, cat and
# mkfifo)
# - SIGTERM is forwarded to the process (and we call wait
# a second time becauce of EINTR)
# - we have no unusual dependencies (only sh, cat, trap,
# kill and mkfifo)
# - we display a warning if the memory limit was reached
# during the job
command = ["/bin/sh", "-c", """
pid=
interrupted=
sighnd() {{
(echo
echo '==== ALLGO JOB ABORT ===='
kill "$pid") >>allgo.log 2>&1
trap '' TERM
interrupted=1
}}
trap sighnd TERM
fifo=/.allgo.fifo.{job_id}
if mkfifo "$fifo"
then
exec cat <"$fifo" >allgo.log &
exec "$@" >"$fifo" 2>&1 &
wait %1
mkfifo "$fifo" 2>>allgo.log || exit $?
exec cat <"$fifo" >>allgo.log &
exec "$@" >"$fifo" 2>&1 &
pid=$!
wait %2
code=$?
if [ -n "$interrupted" ] ; then
wait %2
rm "$fifo"
else
"$@" 2>&1 | cat >allgo.log
code=$?
fi
wait %1
failcnt="`cat /sys/fs/cgroup/memory/memory.failcnt`"
if [ "$failcnt" -ne 0 ] ; then
echo "WARNING: out of memory (memory.failcnt=$failcnt)" >>allgo.log
fi
exit $code
""".format(job_id=job.id),
"job%d" % job.id, webapp.entrypoint] + shlex.split(job.param),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment