[IMP] runbot: kill older builds when a new one is created

When a new commit is found and a new build is created, if a user
pushes more commits in the same branch a few minutes later, it causes
more builds in testing phase, resulting in a CPU waste.

With this commit, previous builds in testing phase in non sticky
branches are killed when a new build is created.

Closes: #20
This commit is contained in:
Christophe Monniez 2018-06-06 16:31:33 +02:00 committed by GitHub
parent c6fe87e18b
commit b1f155c1a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -205,6 +205,16 @@ class runbot_repo(models.Model):
builds_to_skip._skip(reason='New ref found')
if builds_to_skip:
build_info['sequence'] = builds_to_skip[0].sequence
# testing builds are killed
builds_to_kill = Build.search([
('branch_id', '=', branch.id),
('state', '=', 'testing'),
('committer', '=', committer)
])
builds_to_kill.write({'state': 'deathrow'})
for btk in builds_to_kill:
btk._log('repo._update_git', 'Build automatically killed, newer build found.')
new_build = Build.create(build_info)
# create a reverse dependency build if needed
if branch.sticky: