mirror of
https://github.com/odoo/runbot.git
synced 2025-03-15 23:45:44 +07:00
[FIX] runbot: fix docker state and rebuild button
When docker is stopped, end command cannot execute. Thus the state is considered as running.
This commit is contained in:
parent
426b7af2cb
commit
cede4b936e
@ -168,11 +168,15 @@ def docker_run(run_cmd, log_path, build_dir, container_name, exposed_ports=None,
|
||||
_logger.info('Started Docker container %s', container_name)
|
||||
return
|
||||
|
||||
def docker_stop(container_name):
|
||||
def docker_stop(container_name, build_dir=None):
|
||||
"""Stops the container named container_name"""
|
||||
_logger.info('Stopping container %s', container_name)
|
||||
dstop = subprocess.run(['docker', 'stop', container_name])
|
||||
# todo delete os.path.join(build_dir, 'end-%s' % container_name)
|
||||
if build_dir:
|
||||
end_file = os.path.join(build_dir, 'end-%s' % container_name)
|
||||
subprocess.run(['touch', end_file])
|
||||
else:
|
||||
_logger.info('Stopping docker without defined build_dir')
|
||||
subprocess.run(['docker', 'stop', container_name])
|
||||
|
||||
def docker_is_running(container_name):
|
||||
dinspect = subprocess.run(['docker', 'container', 'inspect', container_name], stderr=subprocess.DEVNULL, stdout=subprocess.DEVNULL)
|
||||
|
@ -663,8 +663,10 @@ class runbot_build(models.Model):
|
||||
build._log('_schedule', '%s time exceeded (%ss)' % (build.active_step.name if build.active_step else "?", build.job_time))
|
||||
build._kill(result='killed')
|
||||
continue
|
||||
elif _docker_state == 'UNKNOWN' and build.active_step._is_docker_step():
|
||||
if build.job_time < 60:
|
||||
elif _docker_state == 'UNKNOWN' and (build.local_state == 'running' or build.active_step._is_docker_step()):
|
||||
if build.job_time < 5:
|
||||
continue
|
||||
elif build.job_time < 60:
|
||||
_logger.debug('container "%s" seems too take a while to start', build._get_docker_name())
|
||||
continue
|
||||
else:
|
||||
@ -850,7 +852,7 @@ class runbot_build(models.Model):
|
||||
if build.host != host:
|
||||
continue
|
||||
build._log('kill', 'Kill build %s' % build.dest)
|
||||
docker_stop(build._get_docker_name())
|
||||
docker_stop(build._get_docker_name(), build._path())
|
||||
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()
|
||||
|
@ -135,7 +135,10 @@
|
||||
<t t-if="bu.global_result in ['killed', 'manually_killed']"><t t-set="klass">killed</t></t>
|
||||
</t>
|
||||
<td t-attf-class="{{klass}}">
|
||||
<t t-call="runbot.build_button"><t t-set="klass">btn-group-sm</t></t>
|
||||
<t t-call="runbot.build_button">
|
||||
<t t-set="klass">btn-group-sm</t>
|
||||
<t t-set="show_rebuild_button" t-value="bu==br['builds'][0]"></t>
|
||||
</t>
|
||||
<t t-if="bu['build_type']=='scheduled'"><i class="fa fa-moon-o" t-att-title="bu.build_type_label()" t-att-aria-label="bu.build_type_label()"/></t>
|
||||
<t t-if="bu['build_type'] in ('rebuild', 'indirect')"><i class="fa fa-recycle" t-att-title="bu.build_type_label()" t-att-aria-label="bu.build_type_label()"/></t>
|
||||
<t t-if="bu['subject']">
|
||||
|
Loading…
Reference in New Issue
Block a user