[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.
This commit is contained in:
Christophe Monniez 2019-03-28 13:46:20 +01:00
parent eb68de40f3
commit 574105b66c

View File

@ -679,12 +679,13 @@ class runbot_build(models.Model):
self.ensure_one() self.ensure_one()
user = request.env.user if request else self.env.user user = request.env.user if request else self.env.user
uid = user.id uid = user.id
if self.state == 'pending': build = self.duplicate_id if self.state == 'duplicate' else self
self._skip() if build.state == 'pending':
self._log('_ask_kill', 'Skipping build %s, requested by %s (user #%s)' % (self.dest, user.name, uid)) build._skip()
elif self.state in ['testing', 'running']: build._log('_ask_kill', 'Skipping build %s, requested by %s (user #%s)' % (build.dest, user.name, uid))
self.write({'state': 'deathrow'}) elif build.state in ['testing', 'running']:
self._log('_ask_kill', 'Killing build %s, requested by %s (user #%s)' % (self.dest, user.name, uid)) build.write({'state': 'deathrow'})
build._log('_ask_kill', 'Killing build %s, requested by %s (user #%s)' % (build.dest, user.name, uid))
def _cmd(self): def _cmd(self):
"""Return a tuple describing the command to start the build """Return a tuple describing the command to start the build