From 9a9de6ad8599a3c8f5ce9ae3890888f9444fcc4e Mon Sep 17 00:00:00 2001 From: Xavier-Do Date: Fri, 30 Aug 2019 11:28:56 +0200 Subject: [PATCH] [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) --- runbot/models/build.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/runbot/models/build.py b/runbot/models/build.py index c0b28d51..b005a499 100644 --- a/runbot/models/build.py +++ b/runbot/models/build.py @@ -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)