[IMP] runbot: faster docker update after change

This commit is contained in:
Xavier-Do 2024-08-06 10:03:40 +02:00 committed by Christophe Monniez
parent d2872f8e16
commit 9c6124d645
3 changed files with 15 additions and 6 deletions

View File

@ -41,7 +41,7 @@ class DockerLayer(models.Model):
referencing_dockerlayer_ids = fields.One2many('runbot.docker_layer', 'reference_docker_layer_id', string='Layers referencing this one direcly', readonly=True)
all_referencing_dockerlayer_ids = fields.One2many('runbot.docker_layer', compute="_compute_references", string='Layers referencing this one', readonly=True)
reference_count = fields.Integer('Number of references', compute='_compute_references')
has_xml_id = fields.Boolean(compute='_compute_has_xml_id', store=True)
has_xml_id = fields.Boolean(compute='_compute_has_xml_id')
@api.depends('referencing_dockerlayer_ids', 'dockerfile_id.referencing_dockerlayer_ids')
def _compute_references(self):

View File

@ -21,12 +21,14 @@
<notebook>
<page string="Layers">
<field name="layer_ids">
<tree>
<tree default_order="sequence,id">
<field name="sequence" widget="handle"/>
<field name="rendered" decoration-it="layer_type in ('reference_layer', 'reference_file')" decoration-bg-info="layer_type == 'template'" decoration-bg-success="layer_type == 'raw'"/>
<field name="rendered" decoration-it="layer_type in ('reference_layer', 'reference_file')" decoration-bg-info="layer_type == 'template' or (layer_type == 'reference_layer' and (packages or values))" decoration-bg-success="layer_type == 'raw'"/>
<field name="reference_count" string="#" decoration="True" decoration-bg-danger="referencing_dockerlayer_ids" decoration-bg-warning="reference_count != 0"/>
<field name="referencing_dockerlayer_ids" column_invisible="True"/>
<field name="layer_type" column_invisible="True"/>
<field name="packages" column_invisible="True"/>
<field name="values" column_invisible="True"/>
</tree>
</field>
</page>
@ -148,9 +150,11 @@
<field name="dockerfile_id"/>
<field name="layer_type"/>
<field name="referencing_dockerlayer_ids" column_invisible="True"/>
<field name="packages" column_invisible="True"/>
<field name="values" column_invisible="True"/>
<field name="reference_count" string="#refs" decoration-danger="referencing_dockerlayer_ids" decoration-warning="reference_count != 0"/>
<field name="all_referencing_dockerlayer_ids" string="#referencing" widget="many2many_tags"/>
<field name="rendered" decoration-warning="layer_type in ('reference_layer', 'reference_file')" decoration-info="layer_type == 'template'" decoration-success="layer_type == 'raw'"/>
<field name="rendered" decoration-warning="layer_type in ('reference_layer', 'reference_file')" decoration-info="layer_type == 'template' or (layer_type == 'reference_layer' and (packages or values))" decoration-success="layer_type == 'raw'"/>
</tree>
</field>
</record>

View File

@ -20,13 +20,18 @@ class BuilderClient(RunbotClient):
for repo in self.env['runbot.repo'].search([('mode', '!=', 'disabled')]):
repo._update(force=True)
self.last_docker_update = None
def loop_turn(self):
last_docker_update = max(self.env['runbot.dockerfile'].search([('to_build', '=', True)]).mapped('write_date'))
if self.count == 1 or self.last_docker_update != last_docker_update:
self.host._docker_build()
self.last_docker_update = last_docker_update
if self.count == 1: # cleanup at second iteration
self.env['runbot.runbot']._source_cleanup()
self.env['runbot.build']._local_cleanup()
self.env['runbot.runbot']._docker_cleanup()
self.host._set_psql_conn_count()
self.host._docker_build()
self.env['runbot.repo']._update_git_config()
self.env.cr.commit()
self.git_gc()