Skip to content

Commit d5e0b5e

Browse files
committed
[IMP] runbot: allow to link non done batch
To make the propagation faster, mostly for the freeze and to test forwardport chains, allowing to link non done batch (preparing, ready) would allow to start two batch in two version at the same time and cross link them. It is only problematic for upgrades where the template build will be used for upgrade and needs to be finished. The latest changes allows to link a pending template build to an upgrade one and the upgrade waits for the template to finish before starting. The leader also waits for the template in the current batch to be created before starting the configure upgrade. The next part to do is to wait for the template to be created in other batches before starting the configure.
1 parent f033057 commit d5e0b5e

3 files changed

Lines changed: 27 additions & 1 deletion

File tree

runbot/models/batch.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,9 @@ def _create_build(self, params, slot):
183183
def _get_latest_batch_per_version(self, skip_versions):
184184
return self.env['runbot.batch'].browse(result[1] for result in self.env['runbot.batch']._read_group(
185185
domain=[
186-
('state', '=', 'done'),
186+
#('state', '=', 'done'),
187+
# should we at least wait for ready? in this case it is really hard to cross reference two preparing
188+
# if not waiting for ready, we need for ready before starting the builds
187189
('bundle_id.project_id', '=', self.bundle_id.project_id.id),
188190
('bundle_id.is_base', '=', True),
189191
('bundle_id.sticky', '=', True),
@@ -483,6 +485,7 @@ def _start_builds(self):
483485
continue
484486
trigger = slot.trigger_id
485487
trigger_custom = trigger_customs.get(trigger, self.env['runbot.bundle.trigger.custom'])
488+
486489
if trigger.starts_after_pending:
487490
missing_triggers = trigger.starts_after_ids - started_trigger
488491
elif trigger.starts_after_failure:
@@ -492,6 +495,18 @@ def _start_builds(self):
492495
if missing_triggers:
493496
if not trigger_custom or (missing_triggers - disabled_triggers):
494497
continue
498+
499+
if trigger.upgrade_dumps_trigger_id and trigger.config_id.uses_referenced_batches:
500+
missing_template = False
501+
for ref_batch in self.reference_batch_ids | self:
502+
if ref_batch.state == 'done':
503+
continue
504+
needed_slot = ref_batch.slot_ids.filtered(lambda s: s.trigger_id in trigger.upgrade_dumps_trigger_id)
505+
if not needed_slot or not needed_slot.build_id:
506+
missing_template = True
507+
break
508+
if missing_template:
509+
continue
495510
force_trigger = trigger_custom and trigger_custom.start_mode == 'force'
496511
skip_trigger = (trigger_custom and trigger_custom.start_mode == 'disabled') or trigger.manual
497512
should_start = slot.trigger_id.id in should_start_triggers_ids

runbot/models/build_config.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,12 @@ class Config(models.Model):
144144
dynamic_config_extension = fields.Text('Dynamic Config Extend File', tracking=True)
145145

146146
use_extra_slot = fields.Boolean('Use extra slot', default=False, tracking=True, help="Allow to use an extra slot for this config, if available")
147+
uses_referenced_batches = fields.Boolean('Uses references builds', compute='_compute_uses_referenced_batches', store=True)
148+
149+
@api.depends('step_order_ids.step_id.uses_referenced_batches')
150+
def _compute_uses_referenced_batches(self):
151+
for record in self:
152+
record.uses_referenced_batches = any(step.uses_referenced_batches for step in record.step_ids)
147153

148154
@api.constrains('default_dynamic_config', 'dynamic_config_extension')
149155
def _check_dynamic_config(self):
@@ -508,7 +514,11 @@ class ConfigStep(models.Model):
508514
file_limit = fields.Integer('File limit', default=450)
509515
break_before_if_ko = fields.Boolean('Break before this step if build is ko')
510516
break_after_if_ko = fields.Boolean('Break after this step if build is ko')
517+
uses_referenced_batches = fields.Boolean('Uses references builds', compute='_compute_uses_referenced_batches', store=True, readonly=False)
511518

519+
def _compute_uses_referenced_batches(self):
520+
for record in self:
521+
record.uses_referenced_batches = record.job_type == 'configure_upgrade'
512522

513523
@api.constrains('python_code')
514524
def _check_python_code(self):

runbot/views/config_views.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@
110110
<field name="allow_similar_build_quick_result"/>
111111
<field name="allow_build_link"/>
112112
<field name="upgrade_matrix_id"/>
113+
<field name="uses_referenced_batches"/>
113114
</group>
114115
<group invisible="job_type not in ('python', 'configure_upgrade', 'dynamic')">
115116
<group class="col" string="Upgrade matrix settings" invisible="not upgrade_matrix_id">

0 commit comments

Comments
 (0)