[FIX] runbot: fix build_end and port

When killed a build could have his build end changed (problematic when
killing a running since build_time must represent the testing time)
-> if a build already has a build end, don't overwrite it.

Port also needs to be reset on wake_up since another build would have
recycle the current one since port unicity is limited to build not in
done state. This was working most of the time before since port unicity
was determined cross runbots, thus we only had one chance over 17
to have a conflict on wake up. (this changed with prevous commit)
This commit is contained in:
Xavier-Do 2019-08-30 11:28:56 +02:00
parent 2e44c51678
commit 9a9de6ad85

View File

@ -558,7 +558,16 @@ class runbot_build(models.Model):
else:
try:
log_path = build._path('logs', 'wake_up.txt')
build.write({'job_start': now(), 'job_end': False, 'active_step': False, 'requested_action': False, 'local_state': 'running'})
port = self._find_port()
build.write({
'job_start': now(),
'job_end': False,
'active_step': False,
'requested_action': False,
'local_state': 'running',
'port': port,
})
build._log('wake_up', 'Waking up build', level='SEPARATOR')
self.env['runbot.build.config.step']._run_odoo_run(build, log_path)
# reload_nginx will be triggered by _run_odoo_run
@ -823,9 +832,9 @@ class runbot_build(models.Model):
continue
build._log('kill', 'Kill build %s' % build.dest)
docker_stop(build._get_docker_name())
v = {'local_state': 'done', 'requested_action': False, 'active_step': False, 'duplicate_id': False, 'build_end': now()} # what if duplicate? state done?
if not build.job_end:
v['job_end'] = now()
v = {'local_state': 'done', 'requested_action': False, 'active_step': False, 'duplicate_id': False, 'job_end': now()} # what if duplicate? state done?
if not build.build_end:
v['build_end'] = now()
if result:
v['local_result'] = result
build.write(v)