mirror of
https://github.com/odoo/runbot.git
synced 2025-03-27 13:25:47 +07:00
[FIX] runbot: recover from failed job method call
Catch exceptions occurring within job methods, to avoid stalling the runbot by repeatedly trying to call it - and crashing every time. Mark the build as failed immediately and skip it.
This commit is contained in:
parent
1d46bf9ff5
commit
99c200afcb
@ -1160,8 +1160,14 @@ class runbot_build(osv.osv):
|
|||||||
mkdirs([build._path('logs')])
|
mkdirs([build._path('logs')])
|
||||||
lock_path = build._path('logs', '%s.lock' % build.job)
|
lock_path = build._path('logs', '%s.lock' % build.job)
|
||||||
log_path = build._path('logs', '%s.txt' % build.job)
|
log_path = build._path('logs', '%s.txt' % build.job)
|
||||||
pid = job_method(cr, uid, build, lock_path, log_path)
|
try:
|
||||||
build.write({'pid': pid})
|
pid = job_method(cr, uid, build, lock_path, log_path)
|
||||||
|
build.write({'pid': pid})
|
||||||
|
except Exception:
|
||||||
|
_logger.exception('%s failed running method %s', build.dest, build.job)
|
||||||
|
build._log(build.job, "failed running job method, see runbot log")
|
||||||
|
build._kill(result='ko')
|
||||||
|
continue
|
||||||
# needed to prevent losing pids if multiple jobs are started and one them raise an exception
|
# needed to prevent losing pids if multiple jobs are started and one them raise an exception
|
||||||
cr.commit()
|
cr.commit()
|
||||||
|
|
||||||
@ -1234,11 +1240,12 @@ class runbot_build(osv.osv):
|
|||||||
if build.host != host:
|
if build.host != host:
|
||||||
continue
|
continue
|
||||||
build._log('kill', 'Kill build %s' % build.dest)
|
build._log('kill', 'Kill build %s' % build.dest)
|
||||||
build._logger('killing %s', build.pid)
|
if build.pid:
|
||||||
try:
|
build._logger('killing %s', build.pid)
|
||||||
os.killpg(build.pid, signal.SIGKILL)
|
try:
|
||||||
except OSError:
|
os.killpg(build.pid, signal.SIGKILL)
|
||||||
pass
|
except OSError:
|
||||||
|
pass
|
||||||
v = {'state': 'done', 'job': False}
|
v = {'state': 'done', 'job': False}
|
||||||
if result:
|
if result:
|
||||||
v['result'] = result
|
v['result'] = result
|
||||||
|
Loading…
Reference in New Issue
Block a user