From 574105b66cbdafa725fcb175227430e8bb5ce1a5 Mon Sep 17 00:00:00 2001 From: Christophe Monniez Date: Thu, 28 Mar 2019 13:46:20 +0100 Subject: [PATCH] [FIX] runbot: allow to kill a duplicate Asking for the kill of a build which is the duplicate of another fails because the state of this build is "duplicate", so the _ask_kill method has no effect on it. With this commit, the effect of _ask_kill is applied on the duplicate in the above mentioned case. --- runbot/models/build.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/runbot/models/build.py b/runbot/models/build.py index 894c783b..8a4abfb4 100644 --- a/runbot/models/build.py +++ b/runbot/models/build.py @@ -679,12 +679,13 @@ class runbot_build(models.Model): self.ensure_one() user = request.env.user if request else self.env.user uid = user.id - if self.state == 'pending': - self._skip() - self._log('_ask_kill', 'Skipping build %s, requested by %s (user #%s)' % (self.dest, user.name, uid)) - elif self.state in ['testing', 'running']: - self.write({'state': 'deathrow'}) - self._log('_ask_kill', 'Killing build %s, requested by %s (user #%s)' % (self.dest, user.name, uid)) + build = self.duplicate_id if self.state == 'duplicate' else self + if build.state == 'pending': + build._skip() + build._log('_ask_kill', 'Skipping build %s, requested by %s (user #%s)' % (build.dest, user.name, uid)) + elif build.state in ['testing', 'running']: + build.write({'state': 'deathrow'}) + build._log('_ask_kill', 'Killing build %s, requested by %s (user #%s)' % (build.dest, user.name, uid)) def _cmd(self): """Return a tuple describing the command to start the build