mirror of
https://github.com/odoo/runbot.git
synced 2025-03-15 23:45:44 +07:00
[IMP] runbot: auto disable host when git fetch fail
From times to times, a git repo gets corrupted, making builds fail in chain. With this commit, the host on which the git fetch fails will be reserved if not more than half the hosts are reserved.
This commit is contained in:
parent
6b52687ed1
commit
820adae5ac
@ -103,3 +103,11 @@ class RunboHost(models.Model):
|
||||
|
||||
def _total_workers(self):
|
||||
return sum(host.get_nb_worker() for host in self)
|
||||
|
||||
def disable(self):
|
||||
""" Reserve host if possible """
|
||||
self.ensure_one()
|
||||
nb_hosts = self.env['runbot.host'].search_count([])
|
||||
nb_reserved = self.env['runbot.host'].search_count([('assigned_only', '=', True)])
|
||||
if nb_reserved < (nb_hosts / 2):
|
||||
self.assigned_only = True
|
||||
|
@ -425,7 +425,13 @@ class runbot_repo(models.Model):
|
||||
# Extracted from update_git to be easily overriden in external module
|
||||
self.ensure_one()
|
||||
repo = self
|
||||
repo._git(['fetch', '-p', 'origin', '+refs/heads/*:refs/heads/*', '+refs/pull/*/head:refs/pull/*'])
|
||||
try:
|
||||
repo._git(['fetch', '-p', 'origin', '+refs/heads/*:refs/heads/*', '+refs/pull/*/head:refs/pull/*'])
|
||||
except subprocess.CalledProcessError as e:
|
||||
message = 'Failed to fetch repo %s with return code %s. Original command was %s' % (repo.name, e.returncode, e.cmd)
|
||||
_logger.exception(message)
|
||||
host = self.env['runbot.host'].search([('name', '=', fqdn())])
|
||||
host.disable()
|
||||
|
||||
def _update(self, force=True):
|
||||
""" Update the physical git reposotories on FS"""
|
||||
|
Loading…
Reference in New Issue
Block a user