diff --git a/runbot/models/build.py b/runbot/models/build.py index 3ee7756d6..ac0721f52 100644 --- a/runbot/models/build.py +++ b/runbot/models/build.py @@ -401,7 +401,7 @@ def write(self, values): for init_local_state, build in zip(init_local_states, self): if init_local_state not in ('done', 'running') and build.local_state in ('done', 'running'): - build.build_end = now() + build.build_end = self.env.cr.now() for init_global_state, build in zip(init_global_states, self): if init_global_state not in ('done', 'running') and build.global_state in ('done', 'running'): @@ -420,6 +420,12 @@ def _add_child(self, param_values, orphan=False, description=False, additionnal_ commit_link_ids |= additionnal_commit_links param_values['commit_link_ids'] = commit_link_ids + if "faketime" in param_values.get('config_data', {}): + current_offset = param_values['config_data'].get('faketime_offset', 0) + new_offest = current_offset + self.build_time + new_config_data = {**param_values.get('config_data', {}), 'faketime_offset': new_offest} + param_values['config_data'] = new_config_data + return self.create({ 'params_id': self.params_id.copy(param_values).id, 'parent_id': self.id, @@ -481,7 +487,7 @@ def _compute_build_time(self): if build.build_end and build.build_start: build.build_time = int(dt2time(build.build_end) - dt2time(build.build_start)) elif build.build_start: - build.build_time = int(time.time() - dt2time(build.build_start)) + build.build_time = int(dt2time(self.env.cr.now()) - dt2time(build.build_start)) else: build.build_time = 0 @@ -682,8 +688,8 @@ def _init_pendings(self): self.ensure_one() build = self build.port = self._find_port() - build.job_start = now() - build.build_start = now() + build.job_start = self.env.cr.now() + build.build_start = self.env.cr.now() build.job_end = False build._log('_schedule', 'Init build environment with config %s ' % build.params_id.config_id.name) try: @@ -719,7 +725,7 @@ def _process_requested_actions(self): port = self._find_port() build.write({ - 'job_start': now(), + 'job_start': self.env.cr.now(), 'job_end': False, 'active_step': False, 'requested_action': False, @@ -772,7 +778,7 @@ def _schedule(self): return True # avoid to make results with remaining logs # No job running, make result and select next job - build.job_end = now() + build.job_end = self.env.cr.now() build.docker_start = False # make result of previous job try: @@ -1054,9 +1060,9 @@ def _kill(self, result=None): return build._log('kill', 'Kill build %s' % build.dest) docker_stop(build._get_docker_name(), build._path()) - v = {'local_state': 'done', 'requested_action': False, 'active_step': False, 'job_end': now()} + v = {'local_state': 'done', 'requested_action': False, 'active_step': False, 'job_end': self.env.cr.now()} if not build.build_end: - v['build_end'] = now() + v['build_end'] = self.env.cr.now() if result: v['local_result'] = result build.write(v) @@ -1142,9 +1148,11 @@ def _cmd(self, python_params=None, py_version=None, local_only=True, sub_command faketime = [] if faketime_params := self.params_id.config_data.get('faketime'): - if self.parent_id: - parent_time_offset = (self.parent_id.build_end or self.create_date) - self.parent_id.build_start - faketime_params = (parser.parse(faketime_params) + parent_time_offset).strftime('%Y-%m-%d %H:%M %Z') + time_offset_seconds = self.build_time + if self.params_id.config_data.get('faketime_offset') or self.parent_id: + time_offset_seconds = self.params_id.config_data.get('faketime_offset', self.parent_id.build_time) + time_offset = datetime.timedelta(seconds=time_offset_seconds) + faketime_params = (parser.parse(faketime_params) + time_offset).strftime('%Y-%m-%d %H:%M %Z') faketime = ['faketime', faketime_params] addons_paths = self._get_addons_path() diff --git a/runbot/models/upgrade.py b/runbot/models/upgrade.py index 96843e168..a81ca05e7 100644 --- a/runbot/models/upgrade.py +++ b/runbot/models/upgrade.py @@ -7,6 +7,7 @@ class UpgradeExceptions(models.Model): _name = 'runbot.upgrade.exception' _description = 'Upgrade exception' _inherit = ['mail.thread', 'mail.activity.mixin'] + _mail_post_access = 'read' active = fields.Boolean('Active', default=True, tracking=True) elements = fields.Text('Elements', required=True, tracking=True)