[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()
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