Skip to content

Commit 8d2f1fa

Browse files
committed
[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.
1 parent 6fdd35e commit 8d2f1fa

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

runbot/models/build.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from collections import defaultdict
2020
from pathlib import Path
2121
from psycopg2 import sql
22+
from psycopg2.extensions import TransactionRollbackError
2223
import getpass
2324

2425
_logger = logging.getLogger(__name__)
@@ -341,8 +342,6 @@ def write(self, values):
341342
else:
342343
raise ValidationError('Local result cannot be set to a less critical level')
343344
res = super(BuildResult, self).write(values)
344-
if 'log_counter' in values: # not 100% usefull but more correct ( see test_ir_logging)
345-
self.flush()
346345
return res
347346

348347
def _add_child(self, param_values, orphan=False, description=False, additionnal_commit_links=False):
@@ -700,7 +699,7 @@ def _schedule(self):
700699
build._log('_schedule', 'Docker with state %s not started after 60 seconds, skipping' % _docker_state, level='ERROR')
701700
if hosts_by_build[build.id]._fetch_local_logs(build_ids=build.ids):
702701
continue # avoid to make results with remaining logs
703-
# No job running, make result and select nex job
702+
# No job running, make result and select next job
704703
build_values = {
705704
'job_end': now(),
706705
'docker_start': False,
@@ -726,6 +725,7 @@ def _schedule(self):
726725

727726
build_values.update(build._next_job_values()) # find next active_step or set to done
728727

728+
729729
ending_build = build.local_state not in ('done', 'running') and build_values.get('local_state') in ('done', 'running')
730730
if ending_build:
731731
build.update_build_end()
@@ -748,6 +748,8 @@ def _run_job(self):
748748
os.makedirs(build._path('datadir'), exist_ok=True)
749749
try:
750750
build.active_step._run(build) # run should be on build?
751+
except TransactionRollbackError:
752+
raise
751753
except Exception as e:
752754
if isinstance(e, RunbotException):
753755
message = e.args[0]

0 commit comments

Comments
 (0)