[FIX] runbot: avoid trying to push unexisting image

When an image is build for the first time and the build fails, an
ImageNotfound Exception is raised when trying to push the image.

Whith this commit, a warning is emmited instead of crashing in such a
case.
This commit is contained in:
Christophe Monniez 2024-10-09 16:09:12 +02:00 committed by xdo
parent a8b3d6e205
commit dda0170a89

View File

@ -1,6 +1,7 @@
import logging
from collections import defaultdict
from docker.errors import ImageNotFound
from odoo import models, fields, api
from odoo.tools import config, ormcache
@ -145,7 +146,10 @@ class Host(models.Model):
for dockerfile in self.env['runbot.dockerfile'].search([('to_build', '=', True)]):
dockerfile._build(self)
if is_registry:
try:
docker_push(dockerfile.image_tag)
except ImageNotFound:
_logger.warning("Image tag `%s` not found. Skipping push", dockerfile.image_tag)
_logger.info('Cleaning docker images...')
for image in docker_images():