[FIX] runbot: fix host id

This commit is contained in:
Xavier-Do 2024-08-08 15:39:13 +02:00
parent 917e39dd65
commit eaadd7886d
2 changed files with 4 additions and 7 deletions

View File

@ -287,7 +287,7 @@ class Dockerfile(models.Model):
'content': 'USER {USERNAME}',
})
def _build(self):
def _build(self, host=None):
start = time.time()
docker_build_path = self.env['runbot.runbot']._path('docker', self.image_tag)
os.makedirs(docker_build_path, exist_ok=True)
@ -299,7 +299,7 @@ class Dockerfile(models.Model):
docker_build_identifier, msg = docker_build(docker_build_path, self.image_tag)
duration = time.time() - start
docker_build_result_values = {'dockerfile_id': self.id, 'output': msg, 'duration': duration, 'content': content, 'host_id': self.id}
docker_build_result_values = {'dockerfile_id': self.id, 'output': msg, 'duration': duration, 'content': content, 'host_id': host and host.id}
duration = time.time() - start
if docker_build_identifier:
docker_build_result_values['result'] = 'success'
@ -315,7 +315,7 @@ class Dockerfile(models.Model):
# check previous result anyway
previous_result = self.env['runbot.docker_build_result'].search([
('dockerfile_id', '=', self.id),
('host_id', '=', self.id),
('host_id', '=', host and host.id),
], order='id desc', limit=1)
# identifier changed
if docker_build_identifier.id != previous_result.identifier:

View File

@ -122,12 +122,9 @@ class Host(models.Model):
_logger.info('Building docker images...')
self.ensure_one()
for dockerfile in self.env['runbot.dockerfile'].search([('to_build', '=', True)]):
self._docker_build_dockerfile(dockerfile)
dockerfile._build(self)
_logger.info('Done...')
def _docker_build_dockerfile(self, dockerfile):
dockerfile._build()
@ormcache()
def _host_list(self):
return {host.name: host.id for host in self.search([])}