From 0e14e6d9229f8c7a332eb3672e48ee6557eed8eb Mon Sep 17 00:00:00 2001 From: Xavier-Do Date: Tue, 29 Nov 2022 12:08:28 +0100 Subject: [PATCH] [IMP] runbot: serealisation imps Trying to log when the transaction is in error is useless and create noise in the logs. Flushing is also useless there now that we have the local logs, and it makes the error confusing since the error does not come from the log_counter update but from the update of the global state on the parents global_results. --- runbot/models/build.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/runbot/models/build.py b/runbot/models/build.py index 9c878a3e..173f7751 100644 --- a/runbot/models/build.py +++ b/runbot/models/build.py @@ -19,6 +19,7 @@ from odoo.tools.safe_eval import safe_eval from collections import defaultdict from pathlib import Path from psycopg2 import sql +from psycopg2.extensions import TransactionRollbackError import getpass _logger = logging.getLogger(__name__) @@ -704,7 +705,7 @@ class BuildResult(models.Model): build._log('_schedule', 'Docker with state %s not started after 60 seconds, skipping' % _docker_state, level='ERROR') if hosts_by_build[build.id]._fetch_local_logs(build_ids=build.ids): continue # avoid to make results with remaining logs - # No job running, make result and select nex job + # No job running, make result and select next job build_values = { 'job_end': now(), 'docker_start': False, @@ -730,6 +731,7 @@ class BuildResult(models.Model): build_values.update(build._next_job_values()) # find next active_step or set to done + ending_build = build.local_state not in ('done', 'running') and build_values.get('local_state') in ('done', 'running') if ending_build: build.update_build_end() @@ -752,6 +754,8 @@ class BuildResult(models.Model): os.makedirs(build._path('datadir'), exist_ok=True) try: build.active_step._run(build) # run should be on build? + except TransactionRollbackError: + raise except Exception as e: if isinstance(e, RunbotException): message = e.args[0]