mirror of
https://github.com/odoo/runbot.git
synced 2025-03-27 13:25:47 +07:00
[FIX] runbot: avoid docker state UNKNOWN after slow fetch
This commit is contained in:
parent
e22c403102
commit
ee715360ff
@ -175,6 +175,7 @@ class BuildResult(models.Model):
|
|||||||
job_end = fields.Datetime('Job end')
|
job_end = fields.Datetime('Job end')
|
||||||
build_start = fields.Datetime('Build start')
|
build_start = fields.Datetime('Build start')
|
||||||
build_end = fields.Datetime('Build end')
|
build_end = fields.Datetime('Build end')
|
||||||
|
docker_start = fields.Datetime('Docker start')
|
||||||
job_time = fields.Integer(compute='_compute_job_time', string='Job time')
|
job_time = fields.Integer(compute='_compute_job_time', string='Job time')
|
||||||
build_time = fields.Integer(compute='_compute_build_time', string='Build time')
|
build_time = fields.Integer(compute='_compute_build_time', string='Build time')
|
||||||
|
|
||||||
@ -651,10 +652,11 @@ class BuildResult(models.Model):
|
|||||||
build._log('_schedule', '%s time exceeded (%ss)' % (build.active_step.name if build.active_step else "?", build.job_time))
|
build._log('_schedule', '%s time exceeded (%ss)' % (build.active_step.name if build.active_step else "?", build.job_time))
|
||||||
build._kill(result='killed')
|
build._kill(result='killed')
|
||||||
continue
|
continue
|
||||||
elif _docker_state in ('UNKNOWN', 'GHOST') and (build.local_state == 'running' or build.active_step._is_docker_step()):
|
elif _docker_state in ('UNKNOWN', 'GHOST') and (build.local_state == 'running' or build.active_step._is_docker_step()): # todo replace with docker_start
|
||||||
if build.job_time < 5:
|
docker_time = time.time() - dt2time(build.docker_start or build.job_start)
|
||||||
|
if docker_time < 5:
|
||||||
continue
|
continue
|
||||||
elif build.job_time < 60:
|
elif docker_time < 60:
|
||||||
_logger.info('container "%s" seems too take a while to start :%s' % (build.job_time, build._get_docker_name()))
|
_logger.info('container "%s" seems too take a while to start :%s' % (build.job_time, build._get_docker_name()))
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
@ -662,6 +664,7 @@ class BuildResult(models.Model):
|
|||||||
# No job running, make result and select nex job
|
# No job running, make result and select nex job
|
||||||
build_values = {
|
build_values = {
|
||||||
'job_end': now(),
|
'job_end': now(),
|
||||||
|
'docker_start': False,
|
||||||
}
|
}
|
||||||
# make result of previous job
|
# make result of previous job
|
||||||
try:
|
try:
|
||||||
@ -723,6 +726,11 @@ class BuildResult(models.Model):
|
|||||||
containers_memory_limit = self.env['ir.config_parameter'].sudo().get_param('runbot.runbot_containers_memory', 0)
|
containers_memory_limit = self.env['ir.config_parameter'].sudo().get_param('runbot.runbot_containers_memory', 0)
|
||||||
if containers_memory_limit and 'memory' not in kwargs:
|
if containers_memory_limit and 'memory' not in kwargs:
|
||||||
kwargs['memory'] = int(float(containers_memory_limit) * 1024 ** 3)
|
kwargs['memory'] = int(float(containers_memory_limit) * 1024 ** 3)
|
||||||
|
self.docker_start = now()
|
||||||
|
if self.job_start:
|
||||||
|
start_step_time = int(dt2time(self.docker_start) - dt2time(self.job_start))
|
||||||
|
if start_step_time > 60:
|
||||||
|
_logger.info('Step took %s seconds before starting docker', start_step_time)
|
||||||
docker_run(**kwargs)
|
docker_run(**kwargs)
|
||||||
|
|
||||||
def _path(self, *l, **kw):
|
def _path(self, *l, **kw):
|
||||||
@ -749,6 +757,7 @@ class BuildResult(models.Model):
|
|||||||
def _checkout(self):
|
def _checkout(self):
|
||||||
self.ensure_one() # will raise exception if hash not found, we don't want to fail for all build.
|
self.ensure_one() # will raise exception if hash not found, we don't want to fail for all build.
|
||||||
# checkout branch
|
# checkout branch
|
||||||
|
start = time.time()
|
||||||
exports = {}
|
exports = {}
|
||||||
for commit in self.env.context.get('defined_commit_ids') or self.params_id.commit_ids:
|
for commit in self.env.context.get('defined_commit_ids') or self.params_id.commit_ids:
|
||||||
build_export_path = self._docker_source_folder(commit)
|
build_export_path = self._docker_source_folder(commit)
|
||||||
|
@ -308,8 +308,6 @@ class ConfigStep(models.Model):
|
|||||||
return
|
return
|
||||||
|
|
||||||
exports = build._checkout()
|
exports = build._checkout()
|
||||||
# update job_start AFTER checkout to avoid build being killed too soon if checkout took some time and docker take some time to start
|
|
||||||
build.job_start = now()
|
|
||||||
|
|
||||||
# adjust job_end to record an accurate job_20 job_time
|
# adjust job_end to record an accurate job_20 job_time
|
||||||
build._log('run', 'Start running build %s' % build.dest)
|
build._log('run', 'Start running build %s' % build.dest)
|
||||||
@ -358,8 +356,6 @@ class ConfigStep(models.Model):
|
|||||||
|
|
||||||
def _run_install_odoo(self, build, log_path):
|
def _run_install_odoo(self, build, log_path):
|
||||||
exports = build._checkout()
|
exports = build._checkout()
|
||||||
# update job_start AFTER checkout to avoid build being killed too soon if checkout took some time and docker take some time to start
|
|
||||||
build.job_start = now()
|
|
||||||
|
|
||||||
modules_to_install = self._modules_to_install(build)
|
modules_to_install = self._modules_to_install(build)
|
||||||
mods = ",".join(modules_to_install)
|
mods = ",".join(modules_to_install)
|
||||||
|
Loading…
Reference in New Issue
Block a user