mirror of
https://github.com/odoo/runbot.git
synced 2025-03-27 13:25:47 +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)
|
_logger.info('Started Docker container %s', container_name)
|
||||||
return
|
return
|
||||||
|
|
||||||
def docker_stop(container_name):
|
def docker_stop(container_name, build_dir=None):
|
||||||
"""Stops the container named container_name"""
|
"""Stops the container named container_name"""
|
||||||
_logger.info('Stopping container %s', container_name)
|
_logger.info('Stopping container %s', container_name)
|
||||||
dstop = subprocess.run(['docker', 'stop', container_name])
|
if build_dir:
|
||||||
# todo delete os.path.join(build_dir, 'end-%s' % container_name)
|
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):
|
def docker_is_running(container_name):
|
||||||
dinspect = subprocess.run(['docker', 'container', 'inspect', container_name], stderr=subprocess.DEVNULL, stdout=subprocess.DEVNULL)
|
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._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 == 'UNKNOWN' and build.active_step._is_docker_step():
|
elif _docker_state == 'UNKNOWN' and (build.local_state == 'running' or build.active_step._is_docker_step()):
|
||||||
if build.job_time < 60:
|
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())
|
_logger.debug('container "%s" seems too take a while to start', build._get_docker_name())
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
@ -850,7 +852,7 @@ class runbot_build(models.Model):
|
|||||||
if build.host != host:
|
if build.host != host:
|
||||||
continue
|
continue
|
||||||
build._log('kill', 'Kill build %s' % build.dest)
|
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?
|
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:
|
if not build.build_end:
|
||||||
v['build_end'] = now()
|
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 t-if="bu.global_result in ['killed', 'manually_killed']"><t t-set="klass">killed</t></t>
|
||||||
</t>
|
</t>
|
||||||
<td t-attf-class="{{klass}}">
|
<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']=='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['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']">
|
<t t-if="bu['subject']">
|
||||||
|
Loading…
Reference in New Issue
Block a user