From 0eae784a1e485bc2fb05b1195b957b52a6ceadf3 Mon Sep 17 00:00:00 2001 From: Xavier-Do Date: Wed, 17 Apr 2024 16:21:21 +0200 Subject: [PATCH] [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. --- runbot/models/batch.py | 2 +- runbot/models/build.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/runbot/models/batch.py b/runbot/models/batch.py index 0b3e40b7..2157aa24 100644 --- a/runbot/models/batch.py +++ b/runbot/models/batch.py @@ -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') diff --git a/runbot/models/build.py b/runbot/models/build.py index 044d94e6..fa71d2e9 100644 --- a/runbot/models/build.py +++ b/runbot/models/build.py @@ -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'), ]