[FIX] runbot: don't kill build if build may be used.

The current stratey to check if a build can be killed is to ensure that
no slot unskipped slots points to the same build. Since the check is
only done after a prepare, it should ensure that the new slot have the
build linked before checking if the previous batch can kill it's build.
Since the slot are now filled latter on (after the minimal check) it is
possible that a build is considered killable an killed before being
linked again.

To fix this, we just need to consier params instead of builds to define
if a build is killable or not. If the params of a builds are linked
elsewere, don't kill them.
This commit is contained in:
Xavier-Do 2024-04-17 16:21:21 +02:00
parent e241f03321
commit 0eae784a1e
2 changed files with 3 additions and 1 deletions

View File

@ -92,7 +92,7 @@ class Batch(models.Model):
build = slot.build_id
if build.global_state in ('running', 'done'):
continue
testing_slots = build.slot_ids.filtered(lambda s: not s.skipped)
testing_slots = build.params_id.slot_ids.filtered(lambda s: not s.skipped)
if not testing_slots:
if build.global_state == 'pending':
build._skip('Newer build found')

View File

@ -76,6 +76,8 @@ class BuildParameters(models.Model):
fingerprint = fields.Char('Fingerprint', compute='_compute_fingerprint', store=True, index=True)
slot_ids = fields.One2many('runbot.batch.slot', 'params_id')
_sql_constraints = [
('unique_fingerprint', 'unique (fingerprint)', 'avoid duplicate params'),
]