From 7f4f82a881d590e066d85cc53ea1fbe5e5ea6b64 Mon Sep 17 00:00:00 2001 From: Xavier-Do Date: Mon, 21 Oct 2019 17:41:59 +0200 Subject: [PATCH] [FIX] runbot: docker cleanup should be run on workers only --- runbot/models/repo.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/runbot/models/repo.py b/runbot/models/repo.py index 71d2eac9..2d50eeaa 100644 --- a/runbot/models/repo.py +++ b/runbot/models/repo.py @@ -544,14 +544,6 @@ class runbot_repo(models.Model): if hostname != fqdn(): return 'Not for me' - # docker cleanup - containers = {int(dc.split('-', 1)[0]):dc for dc in docker_ps() if dest_reg.match(dc)} - if containers: - candidates = env['runbot.build'].search([('id', 'in', list(containers.keys())), ('local_state', '=', 'done')]) - for c in candidates: - _logger.info('container %s found running with build state done', containers[c.id]) - docker_stop(containers[c.id]) - start_time = time.time() timeout = self._get_cron_period() icp = self.env['ir.config_parameter'] @@ -584,6 +576,14 @@ class runbot_repo(models.Model): # -> Keep them as long as possible self.env['runbot.build']._local_cleanup() + # 3. docker cleanup + containers = {int(dc.split('-', 1)[0]):dc for dc in docker_ps() if dest_reg.match(dc)} + if containers: + candidates = self.env['runbot.build'].search([('id', 'in', list(containers.keys())), ('local_state', '=', 'done')]) + for c in candidates: + _logger.info('container %s found running with build state done', containers[c.id]) + docker_stop(containers[c.id]) + timeout = self._get_cron_period() icp = self.env['ir.config_parameter'] update_frequency = int(icp.get_param('runbot.runbot_update_frequency', default=10))