diff --git a/runbot/data/runbot_data.xml b/runbot/data/runbot_data.xml
index cd723d7b..8f812caa 100644
--- a/runbot/data/runbot_data.xml
+++ b/runbot/data/runbot_data.xml
@@ -104,23 +104,4 @@ admin_passwd=running_master_password
model._cron()
code
-
-
-
- Base, staging and tmp management
-
- on_create
-
- 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
-
-
diff --git a/runbot/models/branch.py b/runbot/models/branch.py
index 0b8ae314..74fe54fd 100644
--- a/runbot/models/branch.py
+++ b/runbot/models/branch.py
@@ -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)
diff --git a/runbot/models/build.py b/runbot/models/build.py
index e20f87be..2b7872f3 100644
--- a/runbot/models/build.py
+++ b/runbot/models/build.py
@@ -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')
diff --git a/runbot/models/bundle.py b/runbot/models/bundle.py
index 1feb9747..9ea1b4cc 100644
--- a/runbot/models/bundle.py
+++ b/runbot/models/bundle.py
@@ -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):
diff --git a/runbot/models/host.py b/runbot/models/host.py
index 1880aa54..8766784d 100644
--- a/runbot/models/host.py
+++ b/runbot/models/host.py
@@ -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...')
diff --git a/runbot/models/project.py b/runbot/models/project.py
index 8caeb29b..cf9910b8 100644
--- a/runbot/models/project.py
+++ b/runbot/models/project.py
@@ -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):
diff --git a/runbot/models/version.py b/runbot/models/version.py
index e381e5c0..cd5cde55 100644
--- a/runbot/models/version.py
+++ b/runbot/models/version.py
@@ -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):
diff --git a/runbot_builder/tools.py b/runbot_builder/tools.py
index ddc04497..b1af613c 100644
--- a/runbot_builder/tools.py
+++ b/runbot_builder/tools.py
@@ -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