[REL] runbot: adapt for 17.0

This commit is contained in:
Xavier-Do 2023-11-28 12:23:06 +01:00
parent e9fc57816b
commit e83db83533
8 changed files with 25 additions and 31 deletions

View File

@ -104,23 +104,4 @@ admin_passwd=running_master_password</field>
<field name="code">model._cron()</field>
<field name="state">code</field>
</record>
<record id="bundle_create" model="base.automation">
<field name="name">Base, staging and tmp management</field>
<field name="model_id" ref="runbot.model_runbot_bundle"/>
<field name="trigger">on_create</field>
<field name="active" eval="True"/>
<field name="state">code</field>
<field name="code">
if record.name.startswith('tmp.'):
record['no_build'] = True
elif record.name.startswith('staging.'):
name = record.name.replace('staging.', '')
base = record.env['runbot.bundle'].search([('name', '=', name), ('project_id', '=', record.project_id.id), ('is_base', '=', True)], limit=1)
record['build_all'] = True
if base:
record['defined_base_id'] = base
</field>
</record>
</odoo>

View File

@ -30,14 +30,14 @@ class Branch(models.Model):
pr_body = fields.Char('Pr Body')
pr_author = fields.Char('Pr Author')
pull_head_name = fields.Char(compute='_compute_branch_infos', string='PR HEAD name', readonly=1, store=True)
pull_head_name = fields.Char(compute='_compute_branch_infos', string='PR HEAD name', readonly=True, store=True)
pull_head_remote_id = fields.Many2one('runbot.remote', 'Pull head repository', compute='_compute_branch_infos', store=True, index=True)
target_branch_name = fields.Char(compute='_compute_branch_infos', string='PR target branch', store=True)
reviewers = fields.Char('Reviewers')
reflog_ids = fields.One2many('runbot.ref.log', 'branch_id')
branch_url = fields.Char(compute='_compute_branch_url', string='Branch url', readonly=1)
branch_url = fields.Char(compute='_compute_branch_url', string='Branch url', readonly=True)
dname = fields.Char('Display name', compute='_compute_dname', search='_search_dname')
alive = fields.Boolean('Alive', default=True)

View File

@ -173,7 +173,7 @@ class BuildResult(models.Model):
keep_host = fields.Boolean('Keep host on rebuild and for children')
port = fields.Integer('Port')
dest = fields.Char(compute='_compute_dest', type='char', string='Dest', readonly=1, store=True)
dest = fields.Char(compute='_compute_dest', type='char', string='Dest', readonly=True, store=True)
domain = fields.Char(compute='_compute_domain', type='char', string='URL')
# logs and stats
log_ids = fields.One2many('ir.logging', 'build_id', string='Logs')

View File

@ -196,17 +196,26 @@ class Bundle(models.Model):
return "/runbot/bundle/%s" % self.id
def create(self, values_list):
res = super().create(values_list)
if res.is_base:
model = self.browse()
model._get_base_ids.clear_cache(model)
return res
records = super().create(values_list)
for record in records:
if records.is_base:
model = self.browse()
model.env.registry.clear_cache()
elif record.project_id.tmp_prefix and record.name.startswith(record.project_id.tmp_prefix):
record['no_build'] = True
elif record.project_id.staging_prefix and record.name.startswith(record.project_id.staging_prefix):
name = record.name.removeprefix(record.project_id.staging_prefix, '')
base = record.env['runbot.bundle'].search([('name', '=', name), ('project_id', '=', record.project_id.id), ('is_base', '=', True)], limit=1)
record['build_all'] = True
if base:
record['defined_base_id'] = base
return records
def write(self, values):
res = super().write(values)
if 'is_base' in values:
model = self.browse()
model._get_base_ids.clear_cache(model)
model.env.registry.clear_cache()
return res
def _force(self, category_id=None):

View File

@ -124,7 +124,6 @@ class Host(models.Model):
""" build docker images needed by locally pending builds"""
_logger.info('Building docker images...')
self.ensure_one()
self.clear_caches() # needed to ensure that content is updated on all hosts
for dockerfile in self.env['runbot.dockerfile'].search([('to_build', '=', True)]):
self._docker_build_dockerfile(dockerfile)
_logger.info('Done...')

View File

@ -18,7 +18,8 @@ class Project(models.Model):
master_bundle_id = fields.Many2one('runbot.bundle', string='Master bundle')
dummy_bundle_id = fields.Many2one('runbot.bundle', string='Dummy bundle')
always_use_foreign = fields.Boolean('Use foreign bundle', help='By default, check for the same bundle name in another project to fill missing commits.', default=False)
tmp_prefix = fields.Char('tmp branches prefix', default="tmp.")
staging_prefix = fields.Char('staging branches prefix', default="staging.")
@api.model_create_multi
def create(self, vals_list):

View File

@ -39,7 +39,7 @@ class Version(models.Model):
@api.model_create_multi
def create(self, vals_list):
model = self.browse()
model._get_id.clear_cache(model)
model.env.registry.clear_cache()
return super().create(vals_list)
def _get(self, name):

View File

@ -59,6 +59,10 @@ class RunbotClient():
try:
self.host.last_start_loop = fields.Datetime.now()
self.env.cr.commit()
if self.env.registry != self.pool.check_signaling():
# the registry has changed, reload self in the new registry
self.env.reset()
self.env = self.env() #not sure
self.count = self.count % self.max_count
if self.host.paused:
sleep_time = 5